Package org.codehaus.plexus.archiver.jar
Class Manifest
java.lang.Object
java.util.jar.Manifest
org.codehaus.plexus.archiver.jar.Manifest
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
Modifier and TypeClassDescriptionstatic class
An attribute for the manifest.static class
class
class
static class
A manifest section - you can nest attribute elements into sections. -
Constructor Summary
ConstructorDescriptionManifest()
Construct an empty manifestManifest
(InputStream is) Deprecated.This constructor does not properly map characters to bytes. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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 manifeststatic Manifest
static Manifest
getDefaultManifest
(boolean minimalDefaultManifest) Construct a manifest from Ant's default manifest file.Get the main section of the manifestGet the version of the manifestgetSection
(String name) Get a particular section from the manifestiterator()
static String
remap
(Attributes backingAttributes, Manifest.Attribute attribute) toString()
Convert the manifest to its string representationvoid
Writes the manifest out to a writer.Methods inherited from class java.util.jar.Manifest
clear, clone, equals, getAttributes, getEntries, getMainAttributes, hashCode, read, write
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Manifest
public Manifest()Construct an empty manifest -
Manifest
Deprecated.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 specIOException
- if the manifest cannot be read from the reader.
-
Manifest
- Throws:
IOException
-
-
Method Details
-
iterator
-
getDefaultManifest
Construct a manifest from Ant's default manifest file.- Parameters:
minimalDefaultManifest
- indicates whether a minimal manifest will be created, thus having onlyManifest-Version: 1.0
in it.- Returns:
- the default manifest.
- Throws:
ArchiverException
- if there is a problem loading the default manifest
-
getDefaultManifest
- Throws:
ArchiverException
- See Also:
-
addConfiguredSection
Add a section to the manifest- Parameters:
section
- the manifest section to be added- Throws:
ManifestException
- if the secti0on is not valid.
-
addConfiguredAttribute
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
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
-
getManifestVersion
Get the version of the manifest- Returns:
- the manifest's version string
-
getMainSection
Get the main section of the manifest- Returns:
- the main section of the manifest
-
getSection
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
-
remap
public static String remap(Attributes backingAttributes, Manifest.Attribute attribute) throws ManifestException - Throws:
ManifestException
-