org.apache.tools.ant.taskdefsClass Manifest.Section
- java.lang.Object
- org.apache.tools.ant.taskdefs.Manifest.Section
- Enclosing class:
- Manifest
public static class Manifest.Section extends java.lang.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.
Constructor Summary
Constructors Constructor and Description Section()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description java.lang.String
addAttributeAndCheck(Manifest.Attribute attribute)
Add an attribute to the sectionvoid
addConfiguredAttribute(Manifest.Attribute attribute)
Add an attribute to the section.java.lang.Object
clone()
Clone this sectionboolean
equals(java.lang.Object rhs)
Manifest.Attribute
getAttribute(java.lang.String attributeName)
Get a attribute of the sectionjava.util.Enumeration<java.lang.String>
getAttributeKeys()
Get the attribute keys.java.lang.String
getAttributeValue(java.lang.String attributeName)
Get the value of the attribute with the name given.java.lang.String
getName()
Get the Section's name.java.util.Enumeration<java.lang.String>
getWarnings()
Get the warnings for this section.int
hashCode()
void
merge(Manifest.Section section)
Merge in another section without merging Class-Path attributes.void
merge(Manifest.Section section, boolean mergeClassPaths)
Merge in another sectionjava.lang.String
read(java.io.BufferedReader reader)
Read a section through a reader.void
removeAttribute(java.lang.String attributeName)
Remove the given attribute from the sectionvoid
setName(java.lang.String name)
The name of the section; optional -default is the main section.void
write(java.io.PrintWriter writer)
Write the section out to a print writer without flattening multi-values attributes (i.e.void
write(java.io.PrintWriter writer, boolean flatten)
Write the section out to a print writer.
Method Detail
setName
public void setName(java.lang.String name)The name of the section; optional -default is the main section.
- Parameters:
name
- the section's name
getName
public java.lang.String getName()Get the Section's name.
- Returns:
- the section's name.
read
public java.lang.String read(java.io.BufferedReader reader) throws ManifestException, java.io.IOExceptionRead 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 specjava.io.IOException
- if the section cannot be read from the reader.
merge
public void merge(Manifest.Section section) throws ManifestExceptionMerge in another section without merging Class-Path attributes.
- Parameters:
section
- the section to be merged with this one.- Throws:
ManifestException
- if the sections cannot be merged.
merge
public void merge(Manifest.Section section, boolean mergeClassPaths) throws ManifestExceptionMerge in another section
- Parameters:
section
- the section to be merged with this one.mergeClassPaths
- whether Class-Path attributes should be merged.- Throws:
ManifestException
- if the sections cannot be merged.
write
public void write(java.io.PrintWriter writer) throws java.io.IOExceptionWrite the section out to a print writer without flattening multi-values attributes (i.e. Class-Path).
- Parameters:
writer
- the Writer to which the section is written- Throws:
java.io.IOException
- if the section cannot be written
write
public void write(java.io.PrintWriter writer, boolean flatten) throws java.io.IOExceptionWrite the section out to a print writer.
- Parameters:
writer
- the Writer to which the section is writtenflatten
- whether to collapse multi-valued attributes (i.e. potentially Class-Path) Class-Path into a single attribute.- Throws:
java.io.IOException
- if the section cannot be written- Since:
- Ant 1.8.0
getAttribute
public Manifest.Attribute getAttribute(java.lang.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 java.util.Enumeration<java.lang.String> 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 java.lang.String getAttributeValue(java.lang.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
removeAttribute
public void removeAttribute(java.lang.String attributeName)Remove the given attribute from the section
- Parameters:
attributeName
- the name of the attribute to be removed.
addConfiguredAttribute
public void addConfiguredAttribute(Manifest.Attribute attribute) throws ManifestExceptionAdd an attribute to the section.
- Parameters:
attribute
- the attribute to be added to the section- Throws:
ManifestException
- if the attribute is not valid.
addAttributeAndCheck
public java.lang.String addAttributeAndCheck(Manifest.Attribute attribute) throws ManifestExceptionAdd 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.
clone
public java.lang.Object clone()Clone this section
- Overrides:
clone
in classjava.lang.Object
- Returns:
- the cloned Section
- Since:
- Ant 1.5.2
getWarnings
public java.util.Enumeration<java.lang.String> getWarnings()Get the warnings for this section.
- Returns:
- an Enumeration of warning strings.
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- a hash value based on the attributes.
- See Also:
Object.hashCode()
equals
public boolean equals(java.lang.Object rhs)
- Overrides:
equals
in classjava.lang.Object
- Parameters:
rhs
- the object to check for equality.- Returns:
- true if the attributes are the same.
- See Also:
Object.equals(java.lang.Object)