FileDocCategorySizeDatePackage
Attributes.javaAPI DocAndroid 1.5 API16708Wed May 06 22:41:02 BST 2009java.util.jar

Attributes

public class Attributes extends Object implements Cloneable, Map
The {@code Attributes} class is used to store values for manifest entries. Attribute keys are generally instances of {@code Attributes.Name}. Values associated with attribute keys are of type {@code String}.
since
Android 1.0

Fields Summary
protected Map
map
The {@code Attributes} as name/value pairs. Maps the attribute names (as {@link Attributes.Name}) of a JAR file manifest to arbitrary values. The attribute names thus are obtained from the {@link Manifest} for convenience.
Constructors Summary
public Attributes()
Constructs an {@code Attributes} instance.

since
Android 1.0

        map = new HashMap<Object, Object>();
    
public Attributes(Attributes attrib)
Constructs an {@code Attributes} instance obtaining keys and values from the parameter {@code attrib}.

param
attrib The attributes to obtain entries from.
since
Android 1.0

        map = (Map<Object, Object>)((HashMap) attrib.map).clone();
    
public Attributes(int size)
Constructs an {@code Attributes} instance with initial capacity of size {@code size}.

param
size Initial size of this {@code Attributes} instance.
since
Android 1.0

        map = new HashMap<Object, Object>(size);
    
Methods Summary
public voidclear()
Removes all key/value pairs from this {@code Attributes}.

since
Android 1.0

        map.clear();
    
public java.lang.Objectclone()

        Attributes clone;
        try {
            clone = (Attributes) super.clone();
        } catch (CloneNotSupportedException e) {
            return null;
        }
        clone.map = (Map<Object, Object>) ((HashMap) map).clone();
        return clone;
    
public booleancontainsKey(java.lang.Object key)
Determines whether this {@code Attributes} contains the specified key.

param
key The key to search for.
return
{@code true} if the key is found, {@code false} otherwise.
since
Android 1.0

        return map.containsKey(key);
    
public booleancontainsValue(java.lang.Object value)
Determines whether this {@code Attributes} contains the specified value.

param
value the value to search for.
return
{@code true} if the value is found, {@code false} otherwise.
since
Android 1.0

        return map.containsValue(value);
    
public java.util.SetentrySet()
Returns a set containing map entries for each of the key/value pair contained in this {@code Attributes}.

return
a set of Map.Entry's
since
Android 1.0

        return map.entrySet();
    
public booleanequals(java.lang.Object obj)
Determines if this {@code Attributes} and the parameter {@code Attributes} are equal. Two {@code Attributes} instances are equal if they contain the same keys and values.

param
obj the object with which this {@code Attributes} is compared.
return
{@code true} if the {@code Attributes} are equal, {@code false} otherwise.
since
Android 1.0

        if (this == obj) {
            return true;
        }
        if (obj instanceof Attributes) {
            return map.equals(((Attributes) obj).map);
        }
        return false;
    
public java.lang.Objectget(java.lang.Object key)
Returns the value associated with the parameter key.

param
key the key to search for.
return
Object associated with key, or {@code null} if key does not exist.
since
Android 1.0

        return map.get(key);
    
public java.lang.StringgetValue(java.util.jar.Attributes$Name name)
Returns the value associated with the parameter {@code Attributes.Name} key.

param
name the key to obtain the value for.
return
the {@code String} associated with name, or {@code null} if name is not a valid key.
since
Android 1.0

        return (String) map.get(name);
    
public java.lang.StringgetValue(java.lang.String name)
Returns the string associated with the parameter name.

param
name the key to obtain the value for.
return
the string associated with name, or {@code null} if name is not a valid key.
since
Android 1.0

        return (String) map.get(new Attributes.Name(name));
    
public inthashCode()
Returns the hash code of this {@code Attributes}.

return
the hash code of this object.
since
Android 1.0

        return map.hashCode();
    
public booleanisEmpty()
Determines whether this {@code Attributes} contains any keys.

return
{@code true} if one or more keys exist, {@code false} otherwise.
since
Android 1.0

        return map.isEmpty();
    
public java.util.SetkeySet()
Returns a {@code Set} containing all the keys found in this {@code Attributes}.

return
a {@code Set} of all keys.
since
Android 1.0

        return map.keySet();
    
public java.lang.Objectput(java.lang.Object key, java.lang.Object value)
Stores key/value pairs in this {@code Attributes}.

param
key the key to associate with value.
param
value the value to store in this {@code Attributes}.
return
the value being stored.
exception
ClassCastException when key is not an {@code Attributes.Name} or value is not a {@code String}.
since
Android 1.0

        return map.put((Name)key, (String)value);
    
public voidputAll(java.util.Map attrib)
Stores all the key/value pairs in the argument in this {@code Attributes} .

param
attrib the associations to store (must be of type {@code Attributes} ).
since
Android 1.0

        if (attrib == null || !(attrib instanceof Attributes)) {
            throw new ClassCastException();
        }
        this.map.putAll(attrib);
    
public java.lang.StringputValue(java.lang.String name, java.lang.String val)
Stores the value {@code val} associated with the key {@code name} in this {@code Attributes}.

param
name the key to store.
param
val the value to store in this {@code Attributes}.
return
the value being stored.
since
Android 1.0

        return (String) map.put(new Attributes.Name(name), val);
    
public java.lang.Objectremove(java.lang.Object key)
Deletes the key/value pair with key {@code key} from this {@code Attributes}.

param
key the key to remove.
return
the values associated with the removed key, {@code null} if not present.
since
Android 1.0

        return map.remove(key);
    
public intsize()
Returns the number of key/value pairs associated with this {@code Attributes}.

return
the size of this {@code Attributes}.
since
Android 1.0

        return map.size();
    
public java.util.Collectionvalues()
Returns a collection of all the values present in this {@code Attributes} .

return
a collection of all values present.
since
Android 1.0

        return map.values();