public class Manifest
extends java.lang.Object
Modifier and Type | Class | Description |
---|---|---|
static class |
Manifest.Attribute |
An attribute for the manifest.
|
static class |
Manifest.Section |
A manifest section - you can nest attribute elements into sections.
|
Modifier and Type | Field | Description |
---|---|---|
static java.lang.String |
ATTRIBUTE_CLASSPATH |
The Class-Path Header is special - it can be duplicated
|
static java.lang.String |
ATTRIBUTE_FROM |
The From Header is disallowed in a Manifest
|
static java.lang.String |
ATTRIBUTE_MANIFEST_VERSION |
The standard manifest version header
|
static java.lang.String |
ATTRIBUTE_NAME |
The Name Attribute is the first in a named section
|
static java.lang.String |
ATTRIBUTE_SIGNATURE_VERSION |
The standard Signature Version header
|
static java.lang.String |
DEFAULT_MANIFEST_VERSION |
Default Manifest version if one is not specified
|
static java.lang.String |
EOL |
The End-Of-Line marker in manifests
|
static java.lang.String |
ERROR_FROM_FORBIDDEN |
Error for attributes
|
static java.lang.String |
JAR_ENCODING |
Encoding to be used for JAR files.
|
static int |
MAX_LINE_LENGTH |
The max length of a line in a Manifest
|
static int |
MAX_SECTION_LENGTH |
Max length of a line section which is continued.
|
Constructor | Description |
---|---|
Manifest() |
Construct an empty manifest
|
Manifest(java.io.Reader r) |
Read a manifest file from the given reader
|
Modifier and Type | Method | Description |
---|---|---|
void |
addConfiguredAttribute(Manifest.Attribute attribute) |
Add an attribute to the manifest - it is added to the main section.
|
void |
addConfiguredSection(Manifest.Section section) |
Add a section to the manifest
|
boolean |
equals(java.lang.Object rhs) |
|
static Manifest |
getDefaultManifest() |
Construct a manifest from Ant's default manifest file.
|
Manifest.Section |
getMainSection() |
Get the main section of the manifest
|
java.lang.String |
getManifestVersion() |
Get the version of the manifest
|
Manifest.Section |
getSection(java.lang.String name) |
Get a particular section from the manifest
|
java.util.Enumeration<java.lang.String> |
getSectionNames() |
Get the section names in this manifest.
|
java.util.Enumeration<java.lang.String> |
getWarnings() |
Get the warnings for this manifest.
|
int |
hashCode() |
|
void |
merge(Manifest other) |
Merge the contents of the given manifest into this manifest
without merging Class-Path attributes.
|
void |
merge(Manifest other,
boolean overwriteMain) |
Merge the contents of the given manifest into this manifest
without merging Class-Path attributes.
|
void |
merge(Manifest other,
boolean overwriteMain,
boolean mergeClassPaths) |
Merge the contents of the given manifest into this manifest
|
java.lang.String |
toString() |
Convert the manifest to its string representation
|
void |
write(java.io.PrintWriter writer) |
Write the manifest out to a print writer without flattening
multi-values attributes (i.e.
|
void |
write(java.io.PrintWriter writer,
boolean flatten) |
Write the manifest out to a print writer.
|
public static final java.lang.String ATTRIBUTE_MANIFEST_VERSION
public static final java.lang.String ATTRIBUTE_SIGNATURE_VERSION
public static final java.lang.String ATTRIBUTE_NAME
public static final java.lang.String ATTRIBUTE_FROM
public static final java.lang.String ATTRIBUTE_CLASSPATH
public static final java.lang.String DEFAULT_MANIFEST_VERSION
public static final int MAX_LINE_LENGTH
public static final int MAX_SECTION_LENGTH
public static final java.lang.String EOL
public static final java.lang.String ERROR_FROM_FORBIDDEN
public static final java.lang.String JAR_ENCODING
public Manifest()
public Manifest(java.io.Reader r) throws ManifestException, java.io.IOException
r
- is the reader from which the Manifest is readManifestException
- if the manifest is not valid according
to the JAR specjava.io.IOException
- if the manifest cannot be read from the reader.public static Manifest getDefaultManifest() throws BuildException
BuildException
- if there is a problem loading the
default manifestpublic void addConfiguredSection(Manifest.Section section) throws ManifestException
section
- the manifest section to be addedManifestException
- if the secti0on is not valid.public void addConfiguredAttribute(Manifest.Attribute attribute) throws ManifestException
attribute
- the attribute to be added.ManifestException
- if the attribute is not valid.public void merge(Manifest other) throws ManifestException
other
- the Manifest to be merged with this one.ManifestException
- if there is a problem merging the
manifest according to the Manifest spec.public void merge(Manifest other, boolean overwriteMain) throws ManifestException
other
- the Manifest to be merged with this one.overwriteMain
- whether to overwrite the main section
of the current manifestManifestException
- if there is a problem merging the
manifest according to the Manifest spec.public void merge(Manifest other, boolean overwriteMain, boolean mergeClassPaths) throws ManifestException
other
- the Manifest to be merged with this one.overwriteMain
- whether to overwrite the main section
of the current manifestmergeClassPaths
- whether Class-Path attributes should be
merged.ManifestException
- if there is a problem merging the
manifest according to the Manifest spec.public void write(java.io.PrintWriter writer) throws java.io.IOException
writer
- the Writer to which the manifest is writtenjava.io.IOException
- if the manifest cannot be writtenpublic void write(java.io.PrintWriter writer, boolean flatten) throws java.io.IOException
writer
- the Writer to which the manifest is writtenflatten
- whether to collapse multi-valued attributes
(i.e. potentially Class-Path) Class-Path into a single
attribute.java.io.IOException
- if the manifest cannot be writtenpublic java.lang.String toString()
toString
in class java.lang.Object
public java.util.Enumeration<java.lang.String> getWarnings()
public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public boolean equals(java.lang.Object rhs)
equals
in class java.lang.Object
rhs
- the object to check for equality.Object.equals(java.lang.Object)
public java.lang.String getManifestVersion()
public Manifest.Section getMainSection()
public Manifest.Section getSection(java.lang.String name)
name
- the name of the section desired.public java.util.Enumeration<java.lang.String> getSectionNames()