Exemplo n.º 1
0
  /**
   * Merge the contents of the given manifest into this manifest
   *
   * @param other the Manifest to be merged with this one.
   * @param overwriteMain whether to overwrite the main section of the current manifest
   * @throws ManifestException if there is a problem merging the manifest according to the Manifest
   *     spec.
   */
  public void merge(Manifest other, boolean overwriteMain) throws ManifestException {
    if (other != null) {
      if (overwriteMain) {
        mainSection = (Section) other.mainSection.clone();
      } else {
        mainSection.merge(other.mainSection);
      }

      if (other.manifestVersion != null) {
        manifestVersion = other.manifestVersion;
      }

      Enumeration e = other.getSectionNames();
      while (e.hasMoreElements()) {
        String sectionName = (String) e.nextElement();
        Section ourSection = (Section) sections.get(sectionName);
        Section otherSection = (Section) other.sections.get(sectionName);
        if (ourSection == null) {
          if (otherSection != null) {
            addConfiguredSection((Section) otherSection.clone());
          }
        } else {
          ourSection.merge(otherSection);
        }
      }
    }
  }