|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.jar.Attributes
public class Attributes
Represents attribute name/value pairs from a Manifest as a Map.
The names of an attribute are represented by the
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 |
Attributes.Name
Represents a name of a Manifest Attribute. |
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry<K,V> |
Field Summary | |
---|---|
protected Map<Object,Object> |
map
The map that holds all the attribute name/value pairs. |
Constructor Summary | |
---|---|
Attributes()
Creates an empty Attributes map. |
|
Attributes(Attributes attr)
Creates an Attributes map with the initial values taken from another Attributes map. |
|
Attributes(int size)
Creates an empty Attributes map with the given initial size. |
Method Summary | |
---|---|
void |
clear()
Removes all attributes. |
Object |
clone()
Return a clone of this attribute map. |
boolean |
containsKey(Object attrName)
Checks to see if there is an attribute with the specified name. |
boolean |
containsValue(Object attrValue)
Checks to see if there is an attribute name with the specified value. |
Set<Map.Entry<Object,Object>> |
entrySet()
Gives a Set of attribute name and values pairs as MapEntries. |
boolean |
equals(Object o)
Checks to see if two Attributes are equal. |
Object |
get(Object attrName)
Gets the value of a specified attribute name. |
String |
getValue(Attributes.Name name)
Gets the value of the given attribute name. |
String |
getValue(String name)
Gets the value of an attribute name given as a String. |
int |
hashCode()
Returns the hashcode of the attribute name/value map. |
boolean |
isEmpty()
Returns true if there are no attributes set, false otherwise. |
Set<Object> |
keySet()
Gives a Set of all the values of defined attribute names. |
Object |
put(Object name,
Object value)
Adds or replaces a attribute name/value pair. |
void |
putAll(Map<?,?> attr)
Adds or replaces all attribute name/value pairs from another Attributes object to this one. |
String |
putValue(String name,
String value)
Stores an attribute name (represented by a String) and value in this Attributes map. |
Object |
remove(Object name)
Remove a attribute name/value pair. |
int |
size()
Returns the number of defined attribute name/value pairs. |
Collection<Object> |
values()
Returns all the values of the defined attribute name/value pairs as a Collection. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Map<Object,Object> map
Constructor Detail |
---|
public Attributes()
public Attributes(int size)
size
- the initial size of the underlying mappublic Attributes(Attributes attr)
attr
- Attributes map to take the initial values fromMethod Detail |
---|
public String getValue(String name)
name
- a String describing the Name to look for
public String getValue(Attributes.Name name)
name
- the Name to look for
public String putValue(String name, String value)
name
- a (case insensitive) String representation of the attribite
name to add/replacevalue
- the (new) value of the attribute namepublic Object clone()
clone
in class Object
Cloneable
public void clear()
clear
in interface Map<Object,Object>
public boolean containsKey(Object attrName)
containsKey
in interface Map<Object,Object>
attrName
- the name of the attribute to check
public boolean containsValue(Object attrValue)
containsValue
in interface Map<Object,Object>
attrValue
- the value of a attribute to check
public Set<Map.Entry<Object,Object>> entrySet()
entrySet
in interface Map<Object,Object>
Map.Entry
,
Map.entrySet()
public boolean equals(Object o)
equals
in interface Map<Object,Object>
equals
in class Object
o
- another Attribute object which should be checked for equality
Object.hashCode()
public Object get(Object attrName)
get
in interface Map<Object,Object>
attrName
- the name of the attribute we want the value of
Map.containsKey(Object)
public int hashCode()
hashCode
in interface Map<Object,Object>
hashCode
in class Object
Object.equals(Object)
,
System.identityHashCode(Object)
public boolean isEmpty()
isEmpty
in interface Map<Object,Object>
public Set<Object> keySet()
keySet
in interface Map<Object,Object>
public Object put(Object name, Object value)
put
in interface Map<Object,Object>
name
- the name of the attributevalue
- the (new) value of the attribute
Map.containsKey(Object)
public void putAll(Map<?,?> attr)
putAll
in interface Map<Object,Object>
attr
- the Attributes object to merge with this one
ClassCastException
- if the supplied map is not an instance of
AttributesMap.put(Object, Object)
public Object remove(Object name)
remove
in interface Map<Object,Object>
name
- the name of the attribute name/value pair to remove
public int size()
size
in interface Map<Object,Object>
public Collection<Object> values()
values
in interface Map<Object,Object>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |