org.apache.tools.ant.taskdefsClass Manifest.Attribute
- java.lang.Object
- org.apache.tools.ant.taskdefs.Manifest.Attribute
- Enclosing class:
- Manifest
public static class Manifest.Attribute extends java.lang.Object
An attribute for the manifest. Those attributes that are not nested into a section will be added to the "Main" section.
Constructor Summary
Constructors Constructor and Description Attribute()
Construct an empty attributeAttribute(java.lang.String line)
Construct an attribute by parsing a line from the ManifestAttribute(java.lang.String name, java.lang.String value)
Construct a manifest by specifying its name and value
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description void
addContinuation(java.lang.String line)
Add a continuation line from the Manifest file.void
addValue(java.lang.String value)
Add a new value to this attribute - making it multivalued.boolean
equals(java.lang.Object rhs)
java.lang.String
getKey()
Get the attribute's Key - its name in lower case.java.lang.String
getName()
Get the Attribute's namejava.lang.String
getValue()
Get the Attribute's value.java.util.Enumeration<java.lang.String>
getValues()
Get all the attribute's values.int
hashCode()
void
parse(java.lang.String line)
Parse a line into name and value pairsvoid
setName(java.lang.String name)
Set the Attribute's name; requiredvoid
setValue(java.lang.String value)
Set the Attribute's value; requiredvoid
write(java.io.PrintWriter writer)
Write the attribute out to a print writer without flattening multi-values attributes (i.e.void
write(java.io.PrintWriter writer, boolean flatten)
Write the attribute out to a print writer.
Constructor Detail
Attribute
public Attribute()Construct an empty attribute
Attribute
public Attribute(java.lang.String line) throws ManifestExceptionConstruct an attribute by parsing a line from the Manifest
- Parameters:
line
- the line containing the attribute name and value- Throws:
ManifestException
- if the line is not valid
Attribute
public Attribute(java.lang.String name, java.lang.String value)Construct a manifest by specifying its name and value
- Parameters:
name
- the attribute's namevalue
- the Attribute's value
Method Detail
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- a hashcode based on the key and values.
- 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 key and values are the same.
- See Also:
Object.equals(java.lang.Object)
parse
public void parse(java.lang.String line) throws ManifestExceptionParse a line into name and value pairs
- Parameters:
line
- the line to be parsed- Throws:
ManifestException
- if the line does not contain a colon separating the name and value
setName
public void setName(java.lang.String name)Set the Attribute's name; required
- Parameters:
name
- the attribute's name
getName
public java.lang.String getName()Get the Attribute's name
- Returns:
- the attribute's name.
getKey
public java.lang.String getKey()Get the attribute's Key - its name in lower case.
- Returns:
- the attribute's key.
setValue
public void setValue(java.lang.String value)Set the Attribute's value; required
- Parameters:
value
- the attribute's value
getValue
public java.lang.String getValue()Get the Attribute's value.
- Returns:
- the attribute's value.
addValue
public void addValue(java.lang.String value)Add a new value to this attribute - making it multivalued.
- Parameters:
value
- the attribute's additional value
getValues
public java.util.Enumeration<java.lang.String> getValues()Get all the attribute's values.
- Returns:
- an enumeration of the attributes values
addContinuation
public void addContinuation(java.lang.String line)Add a continuation line from the Manifest file. When lines are too long in a manifest, they are continued on the next line by starting with a space. This method adds the continuation data to the attribute value by skipping the first character.
- Parameters:
line
- the continuation line.
write
public void write(java.io.PrintWriter writer) throws java.io.IOExceptionWrite the attribute out to a print writer without flattening multi-values attributes (i.e. Class-Path).
- Parameters:
writer
- the Writer to which the attribute is written- Throws:
java.io.IOException
- if the attribute value cannot be written
write
public void write(java.io.PrintWriter writer, boolean flatten) throws java.io.IOExceptionWrite the attribute out to a print writer.
- Parameters:
writer
- the Writer to which the attribute 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 attribute value cannot be written- Since:
- Ant 1.8.0