Skip to content

Most visited

Recently visited

navigation
Added in API level 1

Attributes

public class Attributes
extends Object implements Cloneable, Map<ObjectObject>

java.lang.Object
   ↳ java.util.jar.Attributes


The Attributes class is used to store values for manifest entries. Attribute keys are generally instances of Attributes.Name. Values associated with attribute keys are of type String.

Summary

Nested classes

class Attributes.Name

The name part of the name/value pairs constituting an attribute as defined by the specification of the JAR manifest. 

Fields

protected Map<ObjectObject> map

The Attributes as name/value pairs.

Public constructors

Attributes()

Constructs an Attributes instance.

Attributes(Attributes attrib)

Constructs an Attributes instance obtaining keys and values from the parameter attrib.

Attributes(int size)

Constructs an Attributes instance with initial capacity of size size.

Public methods

void clear()

Removes all key/value pairs from this Attributes.

Object clone()

Creates and returns a copy of this Object.

boolean containsKey(Object key)

Determines whether this Attributes contains the specified key.

boolean containsValue(Object value)

Determines whether this Attributes contains the specified value.

Set<Entry<ObjectObject>> entrySet()

Returns a set containing map entries for each of the key/value pair contained in this Attributes.

boolean equals(Object obj)

Determines if this Attributes and the parameter Attributes are equal.

Object get(Object key)

Returns the value associated with the parameter key.

String getValue(String name)

Returns the string associated with the parameter name.

String getValue(Attributes.Name name)

Returns the value associated with the parameter Attributes.Name key.

int hashCode()

Returns the hash code of this Attributes.

boolean isEmpty()

Determines whether this Attributes contains any keys.

Set<Object> keySet()

Returns a Set containing all the keys found in this Attributes.

Object put(Object key, Object value)

Stores key/value pairs in this Attributes.

void putAll(Map<?, ?> attrib)

Stores all the key/value pairs in the argument in this Attributes.

String putValue(String name, String value)

Stores the value value associated with the key name in this Attributes.

Object remove(Object key)

Deletes the key/value pair with key key from this Attributes.

int size()

Returns the number of key/value pairs associated with this Attributes.

Collection<Object> values()

Returns a collection of all the values present in this Attributes.

Inherited methods

From class java.lang.Object
From interface java.util.Map

Fields

map

Added in API level 1
Map<ObjectObject> map

The Attributes as name/value pairs. Maps the attribute names (as Attributes.Name) of a JAR file manifest to arbitrary values. The attribute names thus are obtained from the Manifest for convenience.

Public constructors

Attributes

Added in API level 1
Attributes ()

Constructs an Attributes instance.

Attributes

Added in API level 1
Attributes (Attributes attrib)

Constructs an Attributes instance obtaining keys and values from the parameter attrib.

Parameters
attrib Attributes: The attributes to obtain entries from.

Attributes

Added in API level 1
Attributes (int size)

Constructs an Attributes instance with initial capacity of size size.

Parameters
size int: Initial size of this Attributes instance.

Public methods

clear

Added in API level 1
void clear ()

Removes all key/value pairs from this Attributes.

clone

Added in API level 1
Object clone ()

Creates and returns a copy of this Object. The default implementation returns a so-called "shallow" copy: It creates a new instance of the same class and then copies the field values (including object references) from this instance to the new instance. A "deep" copy, in contrast, would also recursively clone nested objects. A subclass that needs to implement this kind of cloning should call super.clone() to create the new instance and then create deep copies of the nested, mutable objects.

Returns
Object a copy of this object.

containsKey

Added in API level 1
boolean containsKey (Object key)

Determines whether this Attributes contains the specified key.

Parameters
key Object: The key to search for.
Returns
boolean true if the key is found, false otherwise.

containsValue

Added in API level 1
boolean containsValue (Object value)

Determines whether this Attributes contains the specified value.

Parameters
value Object: the value to search for.
Returns
boolean true if the value is found, false otherwise.

entrySet

Added in API level 1
Set<Entry<ObjectObject>> entrySet ()

Returns a set containing map entries for each of the key/value pair contained in this Attributes.

Returns
Set<Entry<ObjectObject>> a set of Map.Entry's

equals

Added in API level 1
boolean equals (Object obj)

Determines if this Attributes and the parameter Attributes are equal. Two Attributes instances are equal if they contain the same keys and values.

Parameters
obj Object: the object with which this Attributes is compared.
Returns
boolean true if the Attributes are equal, false otherwise.

get

Added in API level 1
Object get (Object key)

Returns the value associated with the parameter key.

Parameters
key Object: the key to search for.
Returns
Object Object associated with key, or null if key does not exist.

getValue

Added in API level 1
String getValue (String name)

Returns the string associated with the parameter name.

Parameters
name String: the key to obtain the value for.
Returns
String the string associated with name, or null if name is not a valid key.

getValue

Added in API level 1
String getValue (Attributes.Name name)

Returns the value associated with the parameter Attributes.Name key.

Parameters
name Attributes.Name: the key to obtain the value for.
Returns
String the String associated with name, or null if name is not a valid key.

hashCode

Added in API level 1
int hashCode ()

Returns the hash code of this Attributes.

Returns
int the hash code of this object.

isEmpty

Added in API level 1
boolean isEmpty ()

Determines whether this Attributes contains any keys.

Returns
boolean true if one or more keys exist, false otherwise.

keySet

Added in API level 1
Set<Object> keySet ()

Returns a Set containing all the keys found in this Attributes.

Returns
Set<Object> a Set of all keys.

put

Added in API level 1
Object put (Object key, 
                Object value)

Stores key/value pairs in this Attributes.

Parameters
key Object: the key to associate with value.
value Object: the value to store in this Attributes.
Returns
Object the value being stored.
Throws
ClassCastException when key is not an Attributes.Name or value is not a String.

putAll

Added in API level 1
void putAll (Map<?, ?> attrib)

Stores all the key/value pairs in the argument in this Attributes.

Parameters
attrib Map: the associations to store (must be of type Attributes).

putValue

Added in API level 1
String putValue (String name, 
                String value)

Stores the value value associated with the key name in this Attributes.

Parameters
name String
value String
Returns
String the value being stored.

remove

Added in API level 1
Object remove (Object key)

Deletes the key/value pair with key key from this Attributes.

Parameters
key Object: the key to remove.
Returns
Object the values associated with the removed key, null if not present.

size

Added in API level 1
int size ()

Returns the number of key/value pairs associated with this Attributes.

Returns
int the size of this Attributes.

values

Added in API level 1
Collection<Object> values ()

Returns a collection of all the values present in this Attributes.

Returns
Collection<Object> a collection of all values present.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.