Package org.codehaus.plexus.archiver.jar
Class Manifest
- java.lang.Object
-
- java.util.jar.Manifest
-
- org.codehaus.plexus.archiver.jar.Manifest
-
- All Implemented Interfaces:
java.lang.Cloneable,java.lang.Iterable<java.lang.String>
public class Manifest extends java.util.jar.Manifest implements java.lang.Iterable<java.lang.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classManifest.AttributeAn attribute for the manifest.static classManifest.BaseAttributeclassManifest.ExistingAttributeclassManifest.ExistingSectionstatic classManifest.SectionA manifest section - you can nest attribute elements into sections.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringATTRIBUTE_FROMThe From Header is disallowed in a Manifestprivate static java.lang.StringATTRIBUTE_NAMEThe Name Attribute is the first in a named sectionprivate static java.lang.StringDEFAULT_MANIFEST_VERSIONDefault Manifest version if one is not specified(package private) static java.lang.StringEOLThe End-Of-Line marker in manifestsprivate Manifest.SectionmainSectionThe main section of this manifestprivate static intMAX_LINE_LENGTHThe max length of a line in a Manifestprivate static intMAX_SECTION_LENGTHMax length of a line section which is continued.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddConfiguredAttribute(Manifest.Attribute attribute)Add an attribute to the manifest - it is added to the main section.voidaddConfiguredSection(Manifest.Section section)Add a section to the manifeststatic ManifestgetDefaultManifest()static ManifestgetDefaultManifest(boolean minimalDefaultManifest)Construct a manifest from Ant's default manifest file.private static java.io.InputStreamgetInputStream(java.io.Reader r)Deprecated.private static java.util.Collection<java.lang.String>getKeys(java.util.jar.Attributes attributes)Manifest.ExistingSectiongetMainSection()Get the main section of the manifestjava.lang.StringgetManifestVersion()Get the version of the manifestprivate java.util.jar.AttributesgetOrCreateAttributes(java.lang.String name)Manifest.ExistingSectiongetSection(java.lang.String name)Get a particular section from the manifest(package private) java.util.Enumeration<java.lang.String>getWarnings()Get the warnings for this manifest.java.util.Iterator<java.lang.String>iterator()static java.lang.Stringremap(java.util.jar.Attributes backingAttributes, Manifest.Attribute attribute)private voidsetManifestVersion()java.lang.StringtoString()Convert the manifest to its string representationvoidwrite(java.io.Writer writer)Writes the manifest out to a writer.-
Methods inherited from class java.util.jar.Manifest
clear, clone, equals, getAttributes, getEntries, getMainAttributes, hashCode, read, write
-
-
-
-
Field Detail
-
ATTRIBUTE_NAME
private static final java.lang.String ATTRIBUTE_NAME
The Name Attribute is the first in a named section- See Also:
- Constant Field Values
-
ATTRIBUTE_FROM
private static final java.lang.String ATTRIBUTE_FROM
The From Header is disallowed in a Manifest- See Also:
- Constant Field Values
-
DEFAULT_MANIFEST_VERSION
private static final java.lang.String DEFAULT_MANIFEST_VERSION
Default Manifest version if one is not specified- See Also:
- Constant Field Values
-
MAX_LINE_LENGTH
private static final int MAX_LINE_LENGTH
The max length of a line in a Manifest- See Also:
- Constant Field Values
-
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:
- Constant Field Values
-
EOL
static final java.lang.String EOL
The End-Of-Line marker in manifests- See Also:
- Constant Field Values
-
mainSection
private Manifest.Section mainSection
The main section of this manifest
-
-
Constructor Detail
-
Manifest
public Manifest()
Construct an empty manifest
-
Manifest
@Deprecated public Manifest(java.io.Reader r) throws ManifestException, java.io.IOExceptionDeprecated.This constructor does not properly map characters to bytes. UseManifest(InputStream). Will be removed in 4.0.Read a manifest file from the given reader- Parameters:
r- is the reader from which the Manifest is read- Throws:
ManifestException- if the manifest is not valid according to the JAR specjava.io.IOException- if the manifest cannot be read from the reader.
-
Manifest
public Manifest(java.io.InputStream is) throws java.io.IOException- Throws:
java.io.IOException
-
-
Method Detail
-
getKeys
private static java.util.Collection<java.lang.String> getKeys(java.util.jar.Attributes attributes)
-
iterator
public java.util.Iterator<java.lang.String> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<java.lang.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 onlyManifest-Version: 1.0in 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:
getDefaultManifest(boolean)
-
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 java.util.jar.Attributes getOrCreateAttributes(java.lang.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(java.io.Writer writer) throws java.io.IOExceptionWrites the manifest out to a writer.- Parameters:
writer- the Writer to which the manifest is written- Throws:
java.io.IOException- if the manifest cannot be written
-
toString
public java.lang.String toString()
Convert the manifest to its string representation- Overrides:
toStringin classjava.lang.Object- Returns:
- a multiline string with the Manifest as it appears in a Manifest file.
-
getWarnings
java.util.Enumeration<java.lang.String> getWarnings()
Get the warnings for this manifest.- Returns:
- an enumeration of warning strings
-
getManifestVersion
public java.lang.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(java.lang.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 java.io.InputStream getInputStream(java.io.Reader r) throws java.io.IOExceptionDeprecated.- Throws:
java.io.IOException
-
remap
public static java.lang.String remap(java.util.jar.Attributes backingAttributes, Manifest.Attribute attribute) throws ManifestException- Throws:
ManifestException
-
-