Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.util.jar.Attributes
Attributes.Name
class and should confirm to the restrictions
described in that class. Note that the Map interface that Attributes
implements allows you to put names and values into the attribute that don't
follow these restriction (and are not really Atrribute.Names, but if you do
that it might cause undefined behaviour later).
If you use the constants defined in the inner class Name then you can be sure that you always access the right attribute names. This makes manipulating the Attributes more or less type safe.
Most of the methods are wrappers to implement the Map interface. The really
useful and often used methods are getValue(Name)
and
getValue(String)
. If you actually want to set attributes you
may want to use the putValue(String, String)
method
(sorry there is no public type safe putValue(Name, String)
method).
Attributes.Name
Nested Class Summary | |
static class |
|
Field Summary | |
protected Map |
|
Constructor Summary | |
| |
| |
|
Method Summary | |
Set |
|
void |
|
Object |
|
boolean |
|
boolean |
|
boolean | |
Object | |
String | |
String |
|
int |
|
boolean |
|
Set |
|
Object | |
void |
|
String | |
Object | |
int |
|
Collection |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
Field Details
Object>map
protected Map
The map that holds all the attribute name/value pairs. In this
implementation it is actually a Hashtable, but that can be different in
other implementations.
Constructor Details
Attributes
public Attributes(int size)
Creates an empty Attributes map with the given initial size.
- Parameters:
size
- the initial size of the underlying map
Attributes
public Attributes(Attributes attr)
Creates an Attributes map with the initial values taken from another
Attributes map.
- Parameters:
attr
- Attributes map to take the initial values from
Method Details
Object>> entrySet
public SetObject>> entrySet ()
Gives a Set of attribute name and values pairs as MapEntries.
- Returns:
- a set of attribute name value pairs
- See Also:
Map.Entry
, java.util.Map.entrySet()
containsKey
public boolean containsKey(Object attrName)
Checks to see if there is an attribute with the specified name.
XXX - what if the object is a String?
- Specified by:
- containsKey in interface Map<K,V>
- Parameters:
attrName
- the name of the attribute to check
- Returns:
- true if there is an attribute with the specified name, false
otherwise
containsValue
public boolean containsValue(Object attrValue)
Checks to see if there is an attribute name with the specified value.
- Specified by:
- containsValue in interface Map<K,V>
- Parameters:
attrValue
- the value of a attribute to check
- Returns:
- true if there is an attribute name with the specified value,
false otherwise
equals
public boolean equals(Object o)
Checks to see if two Attributes are equal. The supplied object must be
a real instance of Attributes and contain the same attribute name/value
pairs.
- Parameters:
o
- another Attribute object which should be checked for equality
- Returns:
- true if the object is an instance of Attributes and contains the
same name/value pairs, false otherwise
get
public Object get(Object attrName)
Gets the value of a specified attribute name.
XXX - what if the object is a String?
- Parameters:
attrName
- the name of the attribute we want the value of
- Returns:
- the value of the specified attribute name or null when there is
no such attribute name
getValue
public String getValue(String name)
Gets the value of an attribute name given as a String.
- Parameters:
name
- a String describing the Name to look for
- Returns:
- the value gotten from the map of null when not found
getValue
public String getValue(Attributes.Name name)
Gets the value of the given attribute name.
- Parameters:
name
- the Name to look for
- Returns:
- the value gotten from the map of null when not found
keySet
public Set