public class Manifest
extends java.util.jar.Manifest
implements java.lang.Iterable<java.lang.String>
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.
Modifier and Type | Class and Description |
---|---|
static class |
Manifest.Attribute
An attribute for the manifest.
|
static class |
Manifest.BaseAttribute |
class |
Manifest.ExistingAttribute |
class |
Manifest.ExistingSection |
static class |
Manifest.Section
A manifest section - you can nest attribute elements into sections.
|
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
ATTRIBUTE_FROM
The From Header is disallowed in a Manifest
|
private static java.lang.String |
ATTRIBUTE_NAME
The Name Attribute is the first in a named section
|
private static java.lang.String |
DEFAULT_MANIFEST_VERSION
Default Manifest version if one is not specified
|
(package private) static java.lang.String |
EOL
The End-Of-Line marker in manifests
|
private Manifest.Section |
mainSection
The main section of this manifest
|
private static int |
MAX_LINE_LENGTH
The max length of a line in a Manifest
|
private static int |
MAX_SECTION_LENGTH
Max length of a line section which is continued.
|
Constructor and Description |
---|
Manifest()
Construct an empty manifest
|
Manifest(java.io.InputStream is) |
Manifest(java.io.Reader r)
Deprecated.
This constructor does not properly map characters to bytes. Use
Manifest(InputStream) . Will be removed in 4.0. |
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
|
static Manifest |
getDefaultManifest() |
static Manifest |
getDefaultManifest(boolean minimalDefaultManifest)
Construct a manifest from Ant's default manifest file.
|
private static java.io.InputStream |
getInputStream(java.io.Reader r)
Deprecated.
|
private static java.util.Collection<java.lang.String> |
getKeys(java.util.jar.Attributes attributes) |
Manifest.ExistingSection |
getMainSection()
Get the main section of the manifest
|
java.lang.String |
getManifestVersion()
Get the version of the manifest
|
private java.util.jar.Attributes |
getOrCreateAttributes(java.lang.String name) |
Manifest.ExistingSection |
getSection(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.String |
remap(java.util.jar.Attributes backingAttributes,
Manifest.Attribute attribute) |
private void |
setManifestVersion() |
java.lang.String |
toString()
Convert the manifest to its string representation
|
void |
write(java.io.Writer writer)
Writes the manifest out to a writer.
|
clear, clone, equals, getAttributes, getEntries, getMainAttributes, hashCode, read, write
private static final java.lang.String ATTRIBUTE_NAME
private static final java.lang.String ATTRIBUTE_FROM
private static final java.lang.String DEFAULT_MANIFEST_VERSION
private static final int MAX_LINE_LENGTH
private static final int MAX_SECTION_LENGTH
static final java.lang.String EOL
private Manifest.Section mainSection
public Manifest()
@Deprecated public Manifest(java.io.Reader r) throws ManifestException, java.io.IOException
Manifest(InputStream)
. Will be removed in 4.0.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 Manifest(java.io.InputStream is) throws java.io.IOException
java.io.IOException
private static java.util.Collection<java.lang.String> getKeys(java.util.jar.Attributes attributes)
public java.util.Iterator<java.lang.String> iterator()
iterator
in interface java.lang.Iterable<java.lang.String>
public static Manifest getDefaultManifest(boolean minimalDefaultManifest) throws ArchiverException
minimalDefaultManifest
- indicates whether a minimal manifest will be created, thus having only
Manifest-Version: 1.0
in it.ArchiverException
- if there is a problem loading the default manifestpublic static Manifest getDefaultManifest() throws ArchiverException
ArchiverException
getDefaultManifest(boolean)
private void setManifestVersion()
public void addConfiguredSection(Manifest.Section section) throws ManifestException
section
- the manifest section to be addedManifestException
- if the secti0on is not valid.private java.util.jar.Attributes getOrCreateAttributes(java.lang.String name)
public void addConfiguredAttribute(Manifest.Attribute attribute) throws ManifestException
attribute
- the attribute to be added.ManifestException
- if the attribute is not valid.public void write(java.io.Writer writer) throws java.io.IOException
writer
- the Writer to which the manifest is writtenjava.io.IOException
- if the manifest cannot be writtenpublic java.lang.String toString()
toString
in class java.lang.Object
java.util.Enumeration<java.lang.String> getWarnings()
public java.lang.String getManifestVersion()
public Manifest.ExistingSection getMainSection()
public Manifest.ExistingSection getSection(java.lang.String name)
name
- the name of the section desired.@Deprecated private static java.io.InputStream getInputStream(java.io.Reader r) throws java.io.IOException
java.io.IOException
public static java.lang.String remap(java.util.jar.Attributes backingAttributes, Manifest.Attribute attribute) throws ManifestException
ManifestException