Class Manifest

java.lang.Object
java.util.jar.Manifest
org.codehaus.plexus.archiver.jar.Manifest
All Implemented Interfaces:
Cloneable, Iterable<String>

public class Manifest extends Manifest implements Iterable<String>
Holds the data of a jar manifest.

Manifests are processed according to the Jar file specification. Specifically, a manifest element consists of a set of attributes and sections. These sections in turn may contain attributes. Note in particular that this may result in manifest lines greater than 72 bytes (including line break) being wrapped and continued on the next line. If an application can not handle the continuation mechanism, it is a defect in the application, not this task.

Since:
Ant 1.4
  • Field Details

    • ATTRIBUTE_NAME

      private static final String ATTRIBUTE_NAME
      The Name Attribute is the first in a named section
      See Also:
    • ATTRIBUTE_FROM

      private static final String ATTRIBUTE_FROM
      The From Header is disallowed in a Manifest
      See Also:
    • DEFAULT_MANIFEST_VERSION

      private static final String DEFAULT_MANIFEST_VERSION
      Default Manifest version if one is not specified
      See Also:
    • MAX_LINE_LENGTH

      private static final int MAX_LINE_LENGTH
      The max length of a line in a Manifest
      See Also:
    • MAX_SECTION_LENGTH

      private static final int MAX_SECTION_LENGTH
      Max length of a line section which is continued. Need to allow for the CRLF.
      See Also:
    • EOL

      static final String EOL
      The End-Of-Line marker in manifests
      See Also:
    • mainSection

      private Manifest.Section mainSection
      The main section of this manifest
  • Constructor Details

  • Method Details

    • getKeys

      private static Collection<String> getKeys(Attributes attributes)
    • iterator

      public Iterator<String> iterator()
      Specified by:
      iterator in interface Iterable<String>
    • getDefaultManifest

      public static Manifest getDefaultManifest(boolean minimalDefaultManifest) throws ArchiverException
      Construct a manifest from Ant's default manifest file.
      Parameters:
      minimalDefaultManifest - indicates whether a minimal manifest will be created, thus having only Manifest-Version: 1.0 in it.
      Returns:
      the default manifest.
      Throws:
      ArchiverException - if there is a problem loading the default manifest
    • getDefaultManifest

      public static Manifest getDefaultManifest() throws ArchiverException
      Throws:
      ArchiverException
      See Also:
    • setManifestVersion

      private void setManifestVersion()
    • addConfiguredSection

      public void addConfiguredSection(Manifest.Section section) throws ManifestException
      Add a section to the manifest
      Parameters:
      section - the manifest section to be added
      Throws:
      ManifestException - if the secti0on is not valid.
    • getOrCreateAttributes

      private Attributes getOrCreateAttributes(String name)
    • addConfiguredAttribute

      public void addConfiguredAttribute(Manifest.Attribute attribute) throws ManifestException
      Add an attribute to the manifest - it is added to the main section.
      Parameters:
      attribute - the attribute to be added.
      Throws:
      ManifestException - if the attribute is not valid.
    • write

      public void write(Writer writer) throws IOException
      Writes the manifest out to a writer.
      Parameters:
      writer - the Writer to which the manifest is written
      Throws:
      IOException - if the manifest cannot be written
    • toString

      public String toString()
      Convert the manifest to its string representation
      Overrides:
      toString in class Object
      Returns:
      a multiline string with the Manifest as it appears in a Manifest file.
    • getWarnings

      Enumeration<String> getWarnings()
      Get the warnings for this manifest.
      Returns:
      an enumeration of warning strings
    • getManifestVersion

      public String getManifestVersion()
      Get the version of the manifest
      Returns:
      the manifest's version string
    • getMainSection

      public Manifest.ExistingSection getMainSection()
      Get the main section of the manifest
      Returns:
      the main section of the manifest
    • getSection

      public Manifest.ExistingSection getSection(String name)
      Get a particular section from the manifest
      Parameters:
      name - the name of the section desired.
      Returns:
      the specified section or null if that section does not exist in the manifest
    • getInputStream

      @Deprecated private static InputStream getInputStream(Reader r) throws IOException
      Deprecated.
      Throws:
      IOException
    • remap

      public static String remap(Attributes backingAttributes, Manifest.Attribute attribute) throws ManifestException
      Throws:
      ManifestException