public class Manifest extends Object
Modifier and Type | Class and 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 and Description |
---|---|
static String |
ATTRIBUTE_CLASSPATH
The Class-Path Header is special - it can be duplicated
|
static String |
ATTRIBUTE_FROM
The From Header is disallowed in a Manifest
|
static String |
ATTRIBUTE_MANIFEST_VERSION
The standard manifest version header
|
static String |
ATTRIBUTE_NAME
The Name Attribute is the first in a named section
|
static String |
ATTRIBUTE_SIGNATURE_VERSION
The standard Signature Version header
|
static String |
DEFAULT_MANIFEST_VERSION
Default Manifest version if one is not specified
|
static String |
EOL
The End-Of-Line marker in manifests
|
static String |
ERROR_FROM_FORBIDDEN
Error for attributes
|
static 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 and Description |
---|
Manifest()
Construct an empty manifest
|
Manifest(Reader r)
Read a manifest file from the given reader
|
Modifier and Type | Method and 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(Object rhs)
Indicates whether some other object is "equal to" this one.
|
static Manifest |
getDefaultManifest()
Construct a manifest from Ant's default manifest file.
|
Manifest.Section |
getMainSection()
Get the main section of the manifest
|
String |
getManifestVersion()
Get the version of the manifest
|
Manifest.Section |
getSection(String name)
Get a particular section from the manifest
|
Enumeration<String> |
getSectionNames()
Get the section names in this manifest.
|
Enumeration<String> |
getWarnings()
Get the warnings for this manifest.
|
int |
hashCode()
Returns a hash code value for the object.
|
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
|
String |
toString()
Convert the manifest to its string representation
|
void |
write(PrintWriter writer)
Write the manifest out to a print writer without flattening
multi-values attributes (i.e.
|
void |
write(PrintWriter writer,
boolean flatten)
Write the manifest out to a print writer.
|
public static final String ATTRIBUTE_CLASSPATH
public static final String ATTRIBUTE_FROM
public static final String ATTRIBUTE_MANIFEST_VERSION
public static final String ATTRIBUTE_NAME
public static final String ATTRIBUTE_SIGNATURE_VERSION
public static final String DEFAULT_MANIFEST_VERSION
public static final String EOL
public static final String ERROR_FROM_FORBIDDEN
public static final String JAR_ENCODING
public static final int MAX_LINE_LENGTH
public static final int MAX_SECTION_LENGTH
public Manifest()
public Manifest(Reader r) throws ManifestException, IOException
r
- is the reader from which the Manifest is readManifestException
- if the manifest is not valid according
to the JAR specIOException
- if the manifest cannot be read from the reader.public void addConfiguredAttribute(Manifest.Attribute attribute) throws ManifestException
attribute
- the attribute to be added.ManifestException
- if the attribute is not valid.public void addConfiguredSection(Manifest.Section section) throws ManifestException
section
- the manifest section to be addedManifestException
- if the secti0on is not valid.public boolean equals(Object rhs)
Object
The equals
method implements an equivalence relation on non-null object references:
x
, x.equals(x)
should return true
.
x
and y
,
x.equals(y)
should return true
if and only if y.equals(x)
returns
true
.
x
, y
, and
z
, if x.equals(y)
returns true
and y.equals(z)
returns
true
, then x.equals(z)
should return true
.
x
and y
, multiple
invocations of x.equals(y)
consistently return true
or consistently return
false
, provided no information used in equals
comparisons on the objects is
modified.
x
, x.equals(null)
should return
false
.
The equals
method for class Object
implements the most discriminating possible
equivalence relation on objects; that is, for any non-null reference values x
and
y
, this method returns true
if and only if x
and y
refer to the
same object (x == y
has the value true
).
Note that it is generally necessary to override the hashCode
method whenever this method
is overridden, so as to maintain the general contract for the hashCode
method, which
states that equal objects must have equal hash codes.
equals
in class Object
rhs
- the object to check for equality.Object.equals(java.lang.Object)
public static Manifest getDefaultManifest() throws BuildException
BuildException
- if there is a problem loading the
default manifestpublic Manifest.Section getMainSection()
public String getManifestVersion()
public Manifest.Section getSection(String name)
name
- the name of the section desired.public Enumeration<String> getSectionNames()
public Enumeration<String> getWarnings()
public int hashCode()
Object
HashMap
.
The general contract of hashCode
is:
hashCode
method must consistently return the same integer, provided no
information used in equals
comparisons on the object is modified. This integer need not
remain consistent from one execution of an application to another execution of the same
application.
equals(Object)
method, then calling the
hashCode
method on each of the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode
method on each of the two objects must produce distinct integer results. However, the programmer
should be aware that producing distinct integer results for unequal objects may improve the
performance of hash tables.
As much as is reasonably practical, the hashCode method defined by class Object
does
return distinct integers for distinct objects. (This is typically implemented by converting the
internal address of the object into an integer, but this implementation technique is not required
by the JavaTM programming language.)
hashCode
in class Object
Object.hashCode()
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 String toString()
public void write(PrintWriter writer) throws IOException
writer
- the Writer to which the manifest is writtenIOException
- if the manifest cannot be writtenpublic void write(PrintWriter writer, boolean flatten) throws 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.IOException
- if the manifest cannot be written