public class Attributes extends Object implements Map<Object,Object>, Cloneable
This map and its views have a predictable iteration order, namely the order that keys were inserted into the map, as with LinkedHashMap
.
Modifier and Type | Class | Description |
---|---|---|
static class |
Attributes.Name |
The Attributes.Name class represents an attribute name stored in this Map. |
Modifier and Type | Field | Description |
---|---|---|
protected Map |
map |
The attribute name-value mappings. |
Constructor | Description |
---|---|
Attributes() |
Constructs a new, empty Attributes object with default size. |
Attributes |
Constructs a new, empty Attributes object with the specified initial size. |
Attributes |
Constructs a new Attributes object with the same attribute name-value mappings as in the specified Attributes. |
Modifier and Type | Method | Description |
---|---|---|
void |
clear() |
Removes all attributes from this Map. |
Object |
clone() |
Returns a copy of the Attributes, implemented as follows: |
boolean |
containsKey |
Returns true if this Map contains the specified attribute name (key). |
boolean |
containsValue |
Returns true if this Map maps one or more attribute names (keys) to the specified value. |
Set |
entrySet() |
Returns a Collection view of the attribute name-value mappings contained in this Map. |
boolean |
equals |
Compares the specified object to the underlying map for equality. |
Object |
get |
Returns the value of the specified attribute name, or null if the attribute name was not found. |
String |
getValue |
Returns the value of the specified attribute name, specified as a string, or null if the attribute was not found. |
String |
getValue |
Returns the value of the specified Attributes.Name, or null if the attribute was not found. |
int |
hashCode() |
Returns the hash code value for this Map. |
boolean |
isEmpty() |
Returns true if this Map contains no attributes. |
Set |
keySet() |
Returns a Set view of the attribute names (keys) contained in this Map. |
Object |
put |
Associates the specified value with the specified attribute name (key) in this Map. |
void |
putAll |
Copies all of the attribute name-value mappings from the specified Attributes to this Map. |
String |
putValue |
Associates the specified value with the specified attribute name, specified as a String. |
Object |
remove |
Removes the attribute with the specified name (key) from this Map. |
int |
size() |
Returns the number of attributes in this Map. |
Collection |
values() |
Returns a Collection view of the attribute values contained in this Map. |
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
protected Map<Object,Object> map
public Attributes()
public Attributes(int size)
size
- the initial number of attributespublic Attributes(Attributes attr)
attr
- the specified Attributespublic Object get(Object name)
public String getValue(String name)
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)
This method is defined as:
return (String)get(name);
name
- the Attributes.Name objectpublic Object put(Object name, Object value)
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)
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)
public boolean containsValue(Object value)
containsValue
in interface Map<Object,Object>
value
- the attribute valuepublic boolean containsKey(Object name)
containsKey
in interface Map<Object,Object>
name
- the attribute namepublic void putAll(Map<?,?> attr)
putAll
in interface Map<Object,Object>
attr
- the Attributes to be stored in this mapClassCastException
- if attr is not an Attributespublic void clear()
public int size()
public boolean isEmpty()
public Set<Object> keySet()
public Collection<Object> values()
public Set<Map.Entry<Object,Object>> entrySet()
public boolean equals(Object o)
public int hashCode()
public Object clone()
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, 2023, 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.
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/jar/Attributes.html