org.codehaus.plexus.archiver.jar

Class Manifest.Section

public static class Manifest.Section extends Object

A manifest section - you can nest attribute elements into sections. A section consists of a set of attribute values, separated from other sections by a blank line.
Field Summary
VectorattributeIndex
Index used to retain the attribute ordering
Hashtableattributes
The section's attributes.
Stringname
The section's name if any.
Vectorwarnings
Warnings for this section
Method Summary
StringaddAttributeAndCheck(Manifest.Attribute attribute)
Add an attribute to the section
voidaddConfiguredAttribute(Manifest.Attribute attribute)
Add an attribute to the section.
Objectclone()
Clone this section
booleanequals(Object rhs)
Manifest.AttributegetAttribute(String attributeName)
Get a attribute of the section
EnumerationgetAttributeKeys()
Get the attribute keys.
StringgetAttributeValue(String attributeName)
Get the value of the attribute with the name given.
StringgetName()
Get the Section's name.
EnumerationgetWarnings()
Get the warnings for this section.
inthashCode()
voidmerge(Manifest.Section section)
Merge in another section
Stringread(BufferedReader reader)
Read a section through a reader.
voidremoveAttribute(String attributeName)
Remove tge given attribute from the section
voidsetName(String name)
The name of the section; optional -default is the main section.
voidstoreAttribute(Manifest.Attribute attribute)
Store an attribute and update the index.
voidwrite(PrintWriter writer)
Write the section out to a print writer.

Field Detail

attributeIndex

private Vector attributeIndex
Index used to retain the attribute ordering

attributes

private Hashtable attributes
The section's attributes.

name

private String name
The section's name if any. The main section in a manifest is unnamed.

warnings

private Vector warnings
Warnings for this section

Method Detail

addAttributeAndCheck

public String addAttributeAndCheck(Manifest.Attribute attribute)
Add an attribute to the section

Parameters: attribute the attribute to be added.

Returns: the value of the attribute if it is a name attribute - null other wise

Throws: ManifestException if the attribute already exists in this section.

addConfiguredAttribute

public void addConfiguredAttribute(Manifest.Attribute attribute)
Add an attribute to the section.

Parameters: attribute the attribute to be added to the section

Throws: ManifestException if the attribute is not valid.

clone

public Object clone()
Clone this section

Returns: the cloned Section

Since: Ant 1.5.2

equals

public boolean equals(Object rhs)

See Also: java.lang.Object#equals

getAttribute

public Manifest.Attribute getAttribute(String attributeName)
Get a attribute of the section

Parameters: attributeName the name of the attribute

Returns: a Manifest.Attribute instance if the attribute is single-valued, otherwise a Vector of Manifest.Attribute instances.

getAttributeKeys

public Enumeration getAttributeKeys()
Get the attribute keys.

Returns: an Enumeration of Strings, each string being the lower case key of an attribute of the section.

getAttributeValue

public String getAttributeValue(String attributeName)
Get the value of the attribute with the name given.

Parameters: attributeName the name of the attribute to be returned.

Returns: the attribute's value or null if the attribute does not exist in the section

getName

public String getName()
Get the Section's name.

Returns: the section's name.

getWarnings

public Enumeration getWarnings()
Get the warnings for this section.

Returns: an Enumeration of warning strings.

hashCode

public int hashCode()

See Also: java.lang.Object#hashCode

merge

public void merge(Manifest.Section section)
Merge in another section

Parameters: section the section to be merged with this one.

Throws: ManifestException if the sections cannot be merged.

read

public String read(BufferedReader reader)
Read a section through a reader.

Parameters: reader the reader from which the section is read

Returns: the name of the next section if it has been read as part of this section - This only happens if the Manifest is malformed.

Throws: ManifestException if the section is not valid according to the JAR spec IOException if the section cannot be read from the reader.

removeAttribute

public void removeAttribute(String attributeName)
Remove tge given attribute from the section

Parameters: attributeName the name of the attribute to be removed.

setName

public void setName(String name)
The name of the section; optional -default is the main section.

Parameters: name the section's name

storeAttribute

private void storeAttribute(Manifest.Attribute attribute)
Store an attribute and update the index.

Parameters: attribute the attribute to be stored

write

public void write(PrintWriter writer)
Write the section out to a print writer.

Parameters: writer the Writer to which the section is written

Throws: IOException if the section cannot be written