org.codehaus.plexus.archiver.jar
Class Manifest

java.lang.Object
  extended by java.util.jar.Manifest
      extended by org.codehaus.plexus.archiver.jar.Manifest
All Implemented Interfaces:
Cloneable, Iterable<String>

public class Manifest
extends Manifest
implements Iterable<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 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
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.
 
Constructor Summary
Manifest()
          Construct an empty manifest
Manifest(InputStream is)
           
Manifest(Reader r)
          Read a manifest file from the given reader
 
Method Summary
 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()
          Construct a manifest from Ant's default manifest file.
 Manifest.ExistingSection getMainSection()
          Get the main section of the manifest
 String getManifestVersion()
          Get the version of the manifest
 Manifest.ExistingSection getSection(String name)
          Get a particular section from the manifest
 Iterator<String> iterator()
           
static String remap(Attributes backingAttributes, Manifest.Attribute attribute)
           
 String toString()
          Convert the manifest to its string representation
 void write(PrintWriter writer)
          Write the manifest out to a print 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
 

Constructor Detail

Manifest

public Manifest()
Construct an empty manifest


Manifest

public Manifest(Reader r)
         throws ManifestException,
                IOException
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 spec
IOException - if the manifest cannot be read from the reader.

Manifest

public Manifest(InputStream is)
         throws IOException
Throws:
IOException
Method Detail

iterator

public Iterator<String> iterator()
Specified by:
iterator in interface Iterable<String>

getDefaultManifest

public static Manifest getDefaultManifest()
                                   throws ArchiverException
Construct a manifest from Ant's default manifest file.

Returns:
the default manifest.
Throws:
ArchiverException - if there is a problem loading the default manifest

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.

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(PrintWriter writer)
           throws IOException
Write the manifest out to a print writer.

Parameters:
writer - the Writer to which the manifest is written
Throws:
IOException - if the manifest cannot be written

toString

public String toString()
Convert the manifest to its string representation

Overrides:
toString in class Object
Returns:
a multiline string with the Manifest as it appears in a Manifest file.

getManifestVersion

public 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(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

remap

public static String remap(Attributes backingAttributes,
                           Manifest.Attribute attribute)
                    throws ManifestException
Throws:
ManifestException


Copyright © 2008-2012 Sonatype, Inc.. All Rights Reserved.