Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.util.jar

Class Attributes

java.lang.Object
|
+--java.util.jar.Attributes

All Implemented Interfaces:

Cloneable, Map


public class Attributes

extends Object

implements Cloneable, Map

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).

Author:See Also:

Field Summary

java.util.Mapmap

The map that holds all the attribute name/value pairs.

Constructor Summary

Attributes()

Creates an empty Attributes map.
Attributes(int size)

Creates an empty Attributes map with the given initial size.
Attributes(java.util.jar.Attributes attr)

Creates an Attributes map with the initial values taken from another Attributes map.

Method Summary

voidclear()

Removes all attributes.
java.lang.Objectclone()

Return a clone of this attribute map.
booleancontainsKey(java.lang.Object attrName)

Checks to see if there is an attribute with the specified name.
booleancontainsValue(java.lang.Object attrValue)

Checks to see if there is an attribute name with the specified value.
java.util.SetentrySet()

Gives a Set of attribute name and values pairs as MapEntries.
booleanequals(java.lang.Object o)

Checks to see if two Attributes are equal.
java.lang.Objectget(java.lang.Object attrName)

Gets the value of a specified attribute name.
java.lang.StringgetValue(java.lang.String name)

Gets the value of an attribute name given as a String.
java.lang.StringgetValue(java.util.jar.Attributes.Name name)

Gets the value of the given attribute name.
inthashCode()

Returns the hashcode of the attribute name/value map.
booleanisEmpty()

Returns true if there are no attributes set, false otherwise.
java.util.SetkeySet()

Gives a Set of all the values of defined attribute names.
java.lang.Objectput(java.lang.Object name, java.lang.Object value)

Adds or replaces a attribute name/value pair.
voidputAll(java.util.Map attr)

Adds or replaces all attribute name/value pairs from another Attributes object to this one.
java.lang.StringputValue(java.lang.String name, java.lang.String value)

Stores an attribute name (represented by a String) and value in this Attributes map.
java.lang.Objectremove(java.lang.Object name)

Remove a attribute name/value pair.
intsize()

Returns the number of defined attribute name/value pairs.
java.util.Collectionvalues()

Returns all the values of the defined attribute name/value pairs as a Collection.

Field Details

map

protected Map 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()

Creates an empty Attributes map.


Attributes

public Attributes(int size)

Creates an empty Attributes map with the given initial size.

Parameters:


Attributes

public Attributes(java.util.jar.Attributes attr)

Creates an Attributes map with the initial values taken from another Attributes map.

Parameters:


Method Details

clear

public void clear()

Removes all attributes.


clone

public Object clone()

Return a clone of this attribute map.


containsKey

public boolean containsKey(java.lang.Object attrName)

Checks to see if there is an attribute with the specified name. XXX - what if the object is a String?

Parameters:

Returns:


containsValue

public boolean containsValue(java.lang.Object attrValue)

Checks to see if there is an attribute name with the specified value.

Parameters:

Returns:


entrySet

public Set entrySet()

Gives a Set of attribute name and values pairs as MapEntries.

Returns:

See Also:


equals

public boolean equals(java.lang.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:

Returns:


get

public Object get(java.lang.Object attrName)

Gets the value of a specified attribute name. XXX - what if the object is a String?

Parameters:

Returns:


getValue

public String getValue(java.lang.String name)

Gets the value of an attribute name given as a String.

Parameters:

Returns:


getValue

public String getValue(java.util.jar.Attributes.Name name)

Gets the value of the given attribute name.

Parameters:

Returns:


hashCode

public int hashCode()

Returns the hashcode of the attribute name/value map.


isEmpty

public boolean isEmpty()

Returns true if there are no attributes set, false otherwise.


keySet

public Set keySet()

Gives a Set of all the values of defined attribute names.


put

public Object put(java.lang.Object name, java.lang.Object value)

Adds or replaces a attribute name/value pair. XXX - What if the name is a string? What if the name is neither a Name nor a String? What if the value is not a string?

Parameters:

Returns:


putAll

public void putAll(java.util.Map attr)

Adds or replaces all attribute name/value pairs from another Attributes object to this one. The supplied Map must be an instance of Attributes.

Parameters:

Throws:


putValue

public String putValue(java.lang.String name, java.lang.String value)

Stores an attribute name (represented by a String) and value in this Attributes map. When the (case insensitive string) name already exists the value is replaced and the old value is returned.

Parameters:


remove

public Object remove(java.lang.Object name)

Remove a attribute name/value pair. XXX - What if the name is a String?

Parameters:

Returns:


size

public int size()

Returns the number of defined attribute name/value pairs.


values

public Collection values()

Returns all the values of the defined attribute name/value pairs as a Collection.