public
class
Attributes
extends Object
implements
Map<Object, Object>,
Cloneable
java.lang.Object | |
↳ | java.util.jar.Attributes |
The Attributes class maps Manifest attribute names to associated string values. Valid attribute names are case-insensitive, are restricted to the ASCII characters in the set [0-9a-zA-Z_-], and cannot exceed 70 characters in length. Attribute values can contain any characters and will be UTF8-encoded when written to the output stream. See the JAR File Specification for more information about valid attribute names and values.
See also:
Nested classes | |
---|---|
class |
Attributes.Name
The Attributes.Name class represents an attribute name stored in this Map. |
Fields | |
---|---|
protected
Map<Object, Object> |
map
The attribute name-value mappings. |
Public constructors | |
---|---|
Attributes()
Constructs a new, empty Attributes object with default size. |
|
Attributes(int size)
Constructs a new, empty Attributes object with the specified initial size. |
|
Attributes(Attributes attr)
Constructs a new Attributes object with the same attribute name-value mappings as in the specified Attributes. |
Public methods | |
---|---|
void
|
clear()
Removes all attributes from this Map. |
Object
|
clone()
Returns a copy of the Attributes, implemented as follows: public Object clone() { return new Attributes(this); }Since the attribute names and values are themselves immutable, the Attributes returned can be safely modified without affecting the original. |
boolean
|
containsKey(Object name)
Returns true if this Map contains the specified attribute name (key). |
boolean
|
containsValue(Object value)
Returns true if this Map maps one or more attribute names (keys) to the specified value. |
Set<Entry<Object, Object>>
|
entrySet()
Returns a Collection view of the attribute name-value mappings contained in this Map. |
boolean
|
equals(Object o)
Compares the specified Attributes object with this Map for equality. |
Object
|
get(Object name)
Returns the value of the specified attribute name, or null if the attribute name was not found. |
String
|
getValue(String name)
Returns the value of the specified attribute name, specified as a string, or null if the attribute was not found. |
String
|
getValue(Attributes.Name name)
Returns the value of the specified Attributes.Name, or null if the attribute was not found. |
int
|
hashCode()
Returns the hash code value for this Map. |
boolean
|
isEmpty()
Returns true if this Map contains no attributes. |
Set<Object>
|
keySet()
Returns a Set view of the attribute names (keys) contained in this Map. |
Object
|
put(Object name, Object value)
Associates the specified value with the specified attribute name (key) in this Map. |
void
|
putAll(Map<?, ?> attr)
Copies all of the attribute name-value mappings from the specified Attributes to this Map. |
String
|
putValue(String name, String value)
Associates the specified value with the specified attribute name, specified as a String. |
Object
|
remove(Object name)
Removes the attribute with the specified name (key) from this Map. |
int
|
size()
Returns the number of attributes in this Map. |
Collection<Object>
|
values()
Returns a Collection view of the attribute values contained in this Map. |
Inherited methods | |
---|---|
From
class
java.lang.Object
| |
From
interface
java.util.Map
|
Attributes ()
Constructs a new, empty Attributes object with default size.
Attributes (int size)
Constructs a new, empty Attributes object with the specified initial size.
Parameters | |
---|---|
size |
int :
the initial number of attributes
|
Attributes (Attributes attr)
Constructs a new Attributes object with the same attribute name-value mappings as in the specified Attributes.
Parameters | |
---|---|
attr |
Attributes :
the specified Attributes
|
Object clone ()
Returns a copy of the Attributes, implemented as follows:
public Object clone() { return new Attributes(this); }Since the attribute names and values are themselves immutable, the Attributes returned can be safely modified without affecting the original.
Returns | |
---|---|
Object |
a clone of this instance. |
boolean containsKey (Object name)
Returns true if this Map contains the specified attribute name (key).
Parameters | |
---|---|
name |
Object :
the attribute name |
Returns | |
---|---|
boolean |
true if this Map contains the specified attribute name |
boolean containsValue (Object value)
Returns true if this Map maps one or more attribute names (keys) to the specified value.
Parameters | |
---|---|
value |
Object :
the attribute value |
Returns | |
---|---|
boolean |
true if this Map maps one or more attribute names to the specified value |
Set<Entry<Object, Object>> entrySet ()
Returns a Collection view of the attribute name-value mappings contained in this Map.
Returns | |
---|---|
Set<Entry<Object, Object>> |
a set view of the mappings contained in this map |
boolean equals (Object o)
Compares the specified Attributes object with this Map for equality. Returns true if the given object is also an instance of Attributes and the two Attributes objects represent the same mappings.
Parameters | |
---|---|
o |
Object :
the Object to be compared |
Returns | |
---|---|
boolean |
true if the specified Object is equal to this Map |
Object get (Object name)
Returns the value of the specified attribute name, or null if the attribute name was not found.
Parameters | |
---|---|
name |
Object :
the attribute name |
Returns | |
---|---|
Object |
the value of the specified attribute name, or null if not found. |
String getValue (String name)
Returns the value of the specified attribute name, specified as a string, or null if the attribute was not found. The attribute name is case-insensitive.
This method is defined as:
return (String)get(new Attributes.Name((String)name));
Parameters | |
---|---|
name |
String :
the attribute name as a string |
Returns | |
---|---|
String |
the String value of the specified attribute name, or null if not found. |
Throws | |
---|---|
IllegalArgumentException |
if the attribute name is invalid |
String getValue (Attributes.Name name)
Returns the value of the specified Attributes.Name, or null if the attribute was not found.
This method is defined as:
return (String)get(name);
Parameters | |
---|---|
name |
Attributes.Name :
the Attributes.Name object |
Returns | |
---|---|
String |
the String value of the specified Attribute.Name, or null if not found. |
int hashCode ()
Returns the hash code value for this Map.
Returns | |
---|---|
int |
a hash code value for this object. |
boolean isEmpty ()
Returns true if this Map contains no attributes.
Returns | |
---|---|
boolean |
true if this map contains no key-value mappings
|
Set<Object> keySet ()
Returns a Set view of the attribute names (keys) contained in this Map.
Returns | |
---|---|
Set<Object> |
a set view of the keys contained in this map |
Object put (Object name, Object value)
Associates the specified value with the specified attribute name (key) in this Map. If the Map previously contained a mapping for the attribute name, the old value is replaced.
Parameters | |
---|---|
name |
Object :
the attribute name |
value |
Object :
the attribute value |
Returns | |
---|---|
Object |
the previous value of the attribute, or null if none |
Throws | |
---|---|
ClassCastException |
if the name is not a Attributes.Name or the value is not a String |
void putAll (Map<?, ?> attr)
Copies all of the attribute name-value mappings from the specified Attributes to this Map. Duplicate mappings will be replaced.
Parameters | |
---|---|
attr |
Map :
the Attributes to be stored in this map |
Throws | |
---|---|
ClassCastException |
if attr is not an Attributes |
String putValue (String name, String value)
Associates the specified value with the specified attribute name, specified as a String. The attributes name is case-insensitive. If the Map previously contained a mapping for the attribute name, the old value is replaced.
This method is defined as:
return (String)put(new Attributes.Name(name), value);
Parameters | |
---|---|
name |
String :
the attribute name as a string |
value |
String :
the attribute value |
Returns | |
---|---|
String |
the previous value of the attribute, or null if none |
Throws | |
---|---|
IllegalArgumentException |
if the attribute name is invalid |
Object remove (Object name)
Removes the attribute with the specified name (key) from this Map. Returns the previous attribute value, or null if none.
Parameters | |
---|---|
name |
Object :
attribute name |
Returns | |
---|---|
Object |
the previous value of the attribute, or null if none |
int size ()
Returns the number of attributes in this Map.
Returns | |
---|---|
int |
the number of key-value mappings in this map |
Collection<Object> values ()
Returns a Collection view of the attribute values contained in this Map.
Returns | |
---|---|
Collection<Object> |
a collection view of the values contained in this map |