Package org.apache.tools.ant.taskdefs

Examples of org.apache.tools.ant.taskdefs.ManifestException


          // Some jars contain badly formatted manifests.
          System.out.println("Bad manifest");
          continue;
        }
        if (!sectionName.getName().equalsIgnoreCase(ATTRIBUTE_NAME)) {
          throw new ManifestException("Manifest sections should "
              + "start with a \"" + ATTRIBUTE_NAME
              + "\" attribute and not \"" + sectionName.getName()
              + "\"");
        }
        nextSectionName = sectionName.getValue();
View Full Code Here


   *                if the secti0on is not valid.
   */
  public void addConfiguredSection(Section section) throws ManifestException {
    String sectionName = section.getName();
    if (sectionName == null) {
      throw new ManifestException("Sections must have a name");
    }
    sections.put(sectionName, section);
    if (!sectionIndex.contains(sectionName)) {
      sectionIndex.add(sectionName);
    }
View Full Code Here

   *                if the attribute is not valid.
   */
  public void addConfiguredAttribute(Attribute attribute)
      throws ManifestException {
    if (attribute.getKey() == null || attribute.getValue() == null) {
      throw new ManifestException("Attributes must have name and value");
    }
    if (attribute.getKey().equalsIgnoreCase(ATTRIBUTE_MANIFEST_VERSION)) {
      manifestVersion = attribute.getValue();
    } else {
      mainSection.addConfiguredAttribute(attribute);
View Full Code Here

     *             and value
     */
    public void parse(String line) throws ManifestException {
      int index = line.indexOf(": ");
      if (index == -1) {
        throw new ManifestException("Manifest line \"" + line
            + "\" is not valid as it does not "
            + "contain a name and a value separated by ': ' ");
      }
      name = line.substring(0, index);
      setValue(line.substring(index + 2));
View Full Code Here

              // a continuation on the first line is a
              // continuation of the name - concatenate this
              // line and the name
              name += line.substring(1);
            } else {
              throw new ManifestException("Can't start an "
                  + "attribute with a continuation line "
                  + line);
            }
          } else {
            attribute.addContinuation(line);
View Full Code Here

     *             if the sections cannot be merged.
     */
    public void merge(Section section) throws ManifestException {
      if (name == null && section.getName() != null || name != null
          && !(name.equalsIgnoreCase(section.getName()))) {
        throw new ManifestException("Unable to merge sections "
            + "with different names");
      }

      Iterator<String> e = section.getAttributeKeys();
      Attribute classpathAttribute = null;
View Full Code Here

     */
    public void addConfiguredAttribute(Attribute attribute)
        throws ManifestException {
      String check = addAttributeAndCheck(attribute);
      if (check != null) {
        throw new ManifestException(
            "Specify the section name using "
                + "the \"name\" attribute of the <section> element rather "
                + "than using a \"Name\" manifest attribute");
      }
    }
View Full Code Here

     *                if the attribute already exists in this section.
     */
    public String addAttributeAndCheck(Attribute attribute)
        throws ManifestException {
      if (attribute.getName() == null || attribute.getValue() == null) {
        throw new ManifestException(
            "Attributes must have name and value");
      }
      if (attribute.getKey().equalsIgnoreCase(ATTRIBUTE_NAME)) {
        warnings
            .add("\""
                + ATTRIBUTE_NAME
                + "\" attributes "
                + "should not occur in the main section and must be the "
                + "first element in all other sections: \""
                + attribute.getName() + ": "
                + attribute.getValue() + "\"");
        return attribute.getValue();
      }

      if (attribute.getKey().startsWith(ATTRIBUTE_FROM.toLowerCase())) {
        warnings.add("Manifest attributes should not start "
            + "with \"" + ATTRIBUTE_FROM + "\" in \""
            + attribute.getName() + ": " + attribute.getValue()
            + "\"");
      } else {
        // classpath attributes go into a vector
        String attributeKey = attribute.getKey();
        if (attributeKey.equalsIgnoreCase(ATTRIBUTE_CLASSPATH)) {
          Attribute classpathAttribute = (Attribute) attributes
              .get(attributeKey);

          if (classpathAttribute == null) {
            storeAttribute(attribute);
          } else {
            warnings.add("Multiple Class-Path attributes "
                + "are supported but violate the Jar "
                + "specification and may not be correctly "
                + "processed in all environments");
            Iterator<String> e = attribute.getValues();
            while (e.hasNext()) {
              String value = e.next();
              classpathAttribute.addValue(value);
            }
          }
        } else if (attributes.containsKey(attributeKey)) {
          throw new ManifestException("The attribute \""
              + attribute.getName() + "\" may not occur more "
              + "than once in the same section");
        } else {
          storeAttribute(attribute);
        }
View Full Code Here

TOP

Related Classes of org.apache.tools.ant.taskdefs.ManifestException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.