public class Attributes extends Object implements Map<Object,Object>, Cloneable
The Attributes class maps Manifest attribute names to associated string values. Valid attribute names are case-insensitive, are restricted to the ASCII characters in the set [0-9a-zA-Z_-], and cannot exceed 70 characters in length. Attribute values can contain any characters and will be UTF8-encoded when written to the output stream. See the JAR File Specification for more information about valid attribute names and values.
Manifest
Modifier and Type | Class and Description |
---|---|
static class |
Attributes.Name The Attributes.Name class represents an attribute name stored in this Map. |
Map.Entry<K,V>
protected Map<Object,Object> map
The attribute name-value mappings.
public Attributes()
Constructs a new, empty Attributes object with default size.
public Attributes(int size)
Constructs a new, empty Attributes object with the specified initial size.
size
- the initial number of attributespublic Attributes(Attributes attr)
Constructs a new Attributes object with the same attribute name-value mappings as in the specified Attributes.
attr
- the specified Attributespublic Object get(Object name)
Returns the value of the specified attribute name, or null if the attribute name was not found.
get
in interface Map<Object,Object>
name
- the attribute namepublic String getValue(String name)
Returns the value of the specified attribute name, specified as a string, or null if the attribute was not found. The attribute name is case-insensitive.
This method is defined as:
return (String)get(new Attributes.Name((String)name));
name
- the attribute name as a stringIllegalArgumentException
- if the attribute name is invalidpublic String getValue(Attributes.Name name)
Returns the value of the specified Attributes.Name, or null if the attribute was not found.
This method is defined as:
return (String)get(name);
name
- the Attributes.Name objectpublic Object put(Object name, Object value)
Associates the specified value with the specified attribute name (key) in this Map. If the Map previously contained a mapping for the attribute name, the old value is replaced.
put
in interface Map<Object,Object>
name
- the attribute namevalue
- the attribute valueClassCastException
- if the name is not a Attributes.Name or the value is not a Stringpublic String putValue(String name, String value)
Associates the specified value with the specified attribute name, specified as a String. The attributes name is case-insensitive. If the Map previously contained a mapping for the attribute name, the old value is replaced.
This method is defined as:
return (String)put(new Attributes.Name(name), value);
name
- the attribute name as a stringvalue
- the attribute valueIllegalArgumentException
- if the attribute name is invalidpublic Object remove(Object name)
Removes the attribute with the specified name (key) from this Map. Returns the previous attribute value, or null if none.
remove
in interface Map<Object,Object>
name
- attribute namepublic boolean containsValue(Object value)
Returns true if this Map maps one or more attribute names (keys) to the specified value.
containsValue
in interface Map<Object,Object>
value
- the attribute valuepublic boolean containsKey(Object name)
Returns true if this Map contains the specified attribute name (key).
containsKey
in interface Map<Object,Object>
name
- the attribute namepublic void putAll(Map<?,?> attr)
Copies all of the attribute name-value mappings from the specified Attributes to this Map. Duplicate mappings will be replaced.
putAll
in interface Map<Object,Object>
attr
- the Attributes to be stored in this mapClassCastException
- if attr is not an Attributespublic void clear()
Removes all attributes from this Map.
public int size()
Returns the number of attributes in this Map.
size
in interface Map<Object,Object>
public boolean isEmpty()
Returns true if this Map contains no attributes.
isEmpty
in interface Map<Object,Object>
true
if this map contains no key-value mappingspublic Set<Object> keySet()
Returns a Set view of the attribute names (keys) contained in this Map.
keySet
in interface Map<Object,Object>
public Collection<Object> values()
Returns a Collection view of the attribute values contained in this Map.
values
in interface Map<Object,Object>
public Set<Map.Entry<Object,Object>> entrySet()
Returns a Collection view of the attribute name-value mappings contained in this Map.
entrySet
in interface Map<Object,Object>
public boolean equals(Object o)
Compares the specified Attributes object with this Map for equality. Returns true if the given object is also an instance of Attributes and the two Attributes objects represent the same mappings.
equals
in interface Map<Object,Object>
equals
in class Object
o
- the Object to be comparedObject.hashCode()
, HashMap
public int hashCode()
Returns the hash code value for this Map.
hashCode
in interface Map<Object,Object>
hashCode
in class Object
Object.equals(java.lang.Object)
, System.identityHashCode(java.lang.Object)
public Object clone()
Returns a copy of the Attributes, implemented as follows:
public Object clone() { return new Attributes(this); }Since the attribute names and values are themselves immutable, the Attributes returned can be safely modified without affecting the original.
© 1993–2017, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.