Package java.util.jar
Class Attributes
java.lang.Object
java.util.jar.Attributes
public class Attributes extends Object implements Cloneable, Map<Object,Object>
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.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAttributes.NameThe name part of the name/value pairs constituting an attribute as defined by the specification of the JAR manifest. -
Field Summary
-
Constructor Summary
Constructors Constructor Description Attributes()Constructs anAttributesinstance.Attributes(int size)Constructs anAttributesinstance with initial capacity of sizesize.Attributes(Attributes attrib)Constructs anAttributesinstance obtaining keys and values from the parameterattrib. -
Method Summary
Modifier and Type Method Description voidclear()Removes all key/value pairs from thisAttributes.Objectclone()Creates and returns a copy of thisObject.booleancontainsKey(Object key)Determines whether thisAttributescontains the specified key.booleancontainsValue(Object value)Determines whether thisAttributescontains the specified value.Set<Map.Entry<Object,Object>>entrySet()Returns a set containing map entries for each of the key/value pair contained in thisAttributes.booleanequals(Object obj)Determines if thisAttributesand the parameterAttributesare equal.Objectget(Object key)Returns the value associated with the parameter key.StringgetValue(String name)Returns the string associated with the parameter name.StringgetValue(Attributes.Name name)Returns the value associated with the parameterAttributes.Namekey.inthashCode()Returns the hash code of thisAttributes.booleanisEmpty()Determines whether thisAttributescontains any keys.Set<Object>keySet()Returns aSetcontaining all the keys found in thisAttributes.Objectput(Object key, Object value)Stores key/value pairs in thisAttributes.voidputAll(Map<?,?> attrib)Stores all the key/value pairs in the argument in thisAttributes.StringputValue(String name, String value)Stores the valuevalueassociated with the keynamein thisAttributes.Objectremove(Object key)Deletes the key/value pair with keykeyfrom thisAttributes.intsize()Returns the number of key/value pairs associated with thisAttributes.Collection<Object>values()Returns a collection of all the values present in thisAttributes.
-
Field Details
-
map
TheAttributesas name/value pairs. Maps the attribute names (asAttributes.Name) of a JAR file manifest to arbitrary values. The attribute names thus are obtained from theManifestfor convenience.
-
-
Constructor Details
-
Attributes
public Attributes()Constructs anAttributesinstance. -
Attributes
Constructs anAttributesinstance obtaining keys and values from the parameterattrib.- Parameters:
attrib- The attributes to obtain entries from.
-
Attributes
public Attributes(int size)Constructs anAttributesinstance with initial capacity of sizesize.- Parameters:
size- Initial size of thisAttributesinstance.
-
-
Method Details
-
clear
public void clear()Removes all key/value pairs from thisAttributes.- Specified by:
clearin interfaceMap<Object,Object>- See Also:
Map.isEmpty(),Map.size()
-
containsKey
Determines whether thisAttributescontains the specified key.- Specified by:
containsKeyin interfaceMap<Object,Object>- Parameters:
key- The key to search for.- Returns:
trueif the key is found,falseotherwise.
-
containsValue
Determines whether thisAttributescontains the specified value.- Specified by:
containsValuein interfaceMap<Object,Object>- Parameters:
value- the value to search for.- Returns:
trueif the value is found,falseotherwise.
-
entrySet
Returns a set containing map entries for each of the key/value pair contained in thisAttributes. -
get
Returns the value associated with the parameter key. -
isEmpty
public boolean isEmpty()Determines whether thisAttributescontains any keys.- Specified by:
isEmptyin interfaceMap<Object,Object>- Returns:
trueif one or more keys exist,falseotherwise.- See Also:
Map.size()
-
keySet
Returns aSetcontaining all the keys found in thisAttributes. -
put
Stores key/value pairs in thisAttributes.- Specified by:
putin interfaceMap<Object,Object>- Parameters:
key- the key to associate with value.value- the value to store in thisAttributes.- Returns:
- the value being stored.
- Throws:
ClassCastException- when key is not anAttributes.Nameor value is not aString.
-
putAll
Stores all the key/value pairs in the argument in thisAttributes. -
remove
Deletes the key/value pair with keykeyfrom thisAttributes. -
size
public int size()Returns the number of key/value pairs associated with thisAttributes. -
values
Returns a collection of all the values present in thisAttributes. -
clone
Description copied from class:ObjectCreates and returns a copy of thisObject. 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 callsuper.clone()to create the new instance and then create deep copies of the nested, mutable objects. -
hashCode
public int hashCode()Returns the hash code of thisAttributes. -
equals
Determines if thisAttributesand the parameterAttributesare equal. TwoAttributesinstances are equal if they contain the same keys and values. -
getValue
Returns the value associated with the parameterAttributes.Namekey.- Parameters:
name- the key to obtain the value for.- Returns:
- the
Stringassociated with name, ornullif name is not a valid key.
-
getValue
Returns the string associated with the parameter name.- Parameters:
name- the key to obtain the value for.- Returns:
- the string associated with name, or
nullif name is not a valid key.
-
putValue
Stores the valuevalueassociated with the keynamein thisAttributes.- Returns:
- the value being stored.
-