Top Description Inners Fields Constructors Methods
java.util.jar

public Class Attributes

extends Object
implements Map<Object, Object>, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, java.util.Map
Imports
java.io.ByteArrayOutputStream, .DataOutputStream, .IOException, java.util.Collection, .HashMap, .LinkedHashMap, .Map, .Objects, .Set, jdk.internal.misc.CDS, jdk.internal.vm.annotation.Stable, sun.nio.cs.UTF_8, sun.util.logging.PlatformLogger

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. There must be a colon and a SPACE after the name; the combined length will not exceed 72 characters. 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.

This map and its views have a predictable iteration order, namely the order that keys were inserted into the map, as with LinkedHashMap.

Author
David Connelly
Since
1.2
External Specification
JAR File Specification
See Also
Manifest

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Attributes.Name

The Attributes.Name class represents an attribute name stored in this Map.

Field Summary

Modifier and TypeField and Description
protected Map<Object, Object>
map

The attribute name-value mappings.

Constructor Summary

AccessConstructor and Description
public
Attributes()

Constructs a new, empty Attributes object with default size.

public
Attributes(int
the initial number of attributes
size
)

Constructs a new, empty Attributes object with the specified initial size.

public
Attributes(Attributes
the specified Attributes
attr
)

Constructs a new Attributes object with the same attribute name-value mappings as in the specified Attributes.

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Implements java.util.Map.clear.

Removes all attributes from this Map.

public Object
clone()

Overrides java.lang.Object.clone.

Returns a copy of the Attributes, implemented as follows:

    public Object clone() { return new Attributes(this); }
public boolean

Returns:

true if this Map contains the specified attribute name
containsKey
(Object
the attribute name
name
)

Implements java.util.Map.containsKey.

Returns true if this Map contains the specified attribute name (key).

public boolean

Returns:

true if this Map maps one or more attribute names to the specified value
containsValue
(Object
the attribute value
value
)

Implements java.util.Map.containsValue.

Returns true if this Map maps one or more attribute names (keys) to the specified value.

public Set<Map.Entry<Object, Object>>
entrySet()

Implements java.util.Map.entrySet.

Returns a Collection view of the attribute name-value mappings contained in this Map.

public boolean

Returns:

true if the specified Object is equal to this Map
equals
(Object
the Object to be compared
o
)

Overrides java.lang.Object.equals.

Implements java.util.Map.equals.

Compares the specified object to the underlying map for equality.

public Object

Returns:

the value of the specified attribute name, or null if not found.
get
(Object
the attribute name
name
)

Implements java.util.Map.get.

Returns the value of the specified attribute name, or null if the attribute name was not found.

public String

Returns:

the String value of the specified attribute name, or null if not found.
getValue
(String
the attribute name as a string
name
)

Returns the value of the specified attribute name, specified as a string, or null if the attribute was not found.

public String

Returns:

the String value of the specified Attribute.Name, or null if not found.
getValue
(Attributes.Name
the Attributes.Name object
name
)

Returns the value of the specified Attributes.Name, or null if the attribute was not found.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements java.util.Map.hashCode.

Returns the hash code value for this Map.

public boolean
isEmpty()

Implements java.util.Map.isEmpty.

Returns true if this Map contains no attributes.

public Set<Object>
keySet()

Implements java.util.Map.keySet.

Returns a Set view of the attribute names (keys) contained in this Map.

public Object

Returns:

the previous value of the attribute, or null if none
put
(Object
the attribute name
name
,
Object
the attribute value
value
)

Implements java.util.Map.put.

Associates the specified value with the specified attribute name (key) in this Map.

public void
putAll(Map<?, ?>
the Attributes to be stored in this map
attr
)

Implements java.util.Map.putAll.

Copies all of the attribute name-value mappings from the specified Attributes to this Map.

public String

Returns:

the previous value of the attribute, or null if none
putValue
(String
the attribute name as a string
name
,
String
the attribute value
value
)

Associates the specified value with the specified attribute name, specified as a String.

pack-priv void
read(Manifest.FastInputStream is, byte[] lbuf)

pack-priv int
read(Manifest.FastInputStream is, byte[] lbuf, String filename, int lineNumber)

public Object

Returns:

the previous value of the attribute, or null if none
remove
(Object
attribute name
name
)

Implements java.util.Map.remove.

Removes the attribute with the specified name (key) from this Map.

public int
size()

Implements java.util.Map.size.

Returns the number of attributes in this Map.

public Collection<Object>
values()

Implements java.util.Map.values.

Returns a Collection view of the attribute values contained in this Map.

pack-priv void
pack-priv void
Inherited from java.lang.Object:
finalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

mapback to summary
protected Map<Object, Object> map

The attribute name-value mappings.

Constructor Detail

Attributesback to summary
public Attributes()

Constructs a new, empty Attributes object with default size.

Attributesback to summary
public Attributes(int size)

Constructs a new, empty Attributes object with the specified initial size.

Parameters
size:int

the initial number of attributes

Attributesback to summary
public Attributes(Attributes attr)

Constructs a new Attributes object with the same attribute name-value mappings as in the specified Attributes.

Parameters
attr:Attributes

the specified Attributes

Method Detail

clearback to summary
public void clear()

Implements java.util.Map.clear.

Removes all attributes from this Map.

cloneback to summary
public Object clone()

Overrides java.lang.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.
Returns:Object

Doc from java.lang.Object.clone.

a clone of this instance.

containsKeyback to summary
public boolean containsKey(Object name)

Implements java.util.Map.containsKey.

Returns true if this Map contains the specified attribute name (key).

Parameters
name:Object

the attribute name

Returns:boolean

true if this Map contains the specified attribute name

containsValueback to summary
public boolean containsValue(Object value)

Implements java.util.Map.containsValue.

Returns true if this Map maps one or more attribute names (keys) to the specified value.

Parameters
value:Object

the attribute value

Returns:boolean

true if this Map maps one or more attribute names to the specified value

entrySetback to summary
public Set<Map.Entry<Object, Object>> entrySet()

Implements java.util.Map.entrySet.

Returns a Collection view of the attribute name-value mappings contained in this Map.

Returns:Set<Map.Entry<Object, Object>>

Doc from java.util.Map.entrySet.

a set view of the mappings contained in this map

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Implements java.util.Map.equals.

Compares the specified object to the underlying map for equality. Returns true if the given object is also a Map and the two maps represent the same mappings.

Parameters
o:Object

the Object to be compared

Returns:boolean

true if the specified Object is equal to this Map

getback to summary
public Object get(Object name)

Implements java.util.Map.get.

Returns the value of the specified attribute name, or null if the attribute name was not found.

Parameters
name:Object

the attribute name

Returns:Object

the value of the specified attribute name, or null if not found.

getValueback to summary
public 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));
Parameters
name:String

the attribute name as a string

Returns:String

the String value of the specified attribute name, or null if not found.

Exceptions
IllegalArgumentException:
if the attribute name is invalid
getValueback to summary
public 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);
Parameters
name:Attributes.Name

the Attributes.Name object

Returns:String

the String value of the specified Attribute.Name, or null if not found.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements java.util.Map.hashCode.

Returns the hash code value for this Map.

Returns:int

Doc from java.util.Map.hashCode.

the hash code value for this map

isEmptyback to summary
public boolean isEmpty()

Implements java.util.Map.isEmpty.

Returns true if this Map contains no attributes.

Returns:boolean

Doc from java.util.Map.isEmpty.

true if this map contains no key-value mappings

keySetback to summary
public Set<Object> keySet()

Implements java.util.Map.keySet.

Returns a Set view of the attribute names (keys) contained in this Map.

Returns:Set<Object>

Doc from java.util.Map.keySet.

a set view of the keys contained in this map

putback to summary
public Object put(Object name, Object value)

Implements java.util.Map.put.

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.

Parameters
name:Object

the attribute name

value:Object

the attribute value

Returns:Object

the previous value of the attribute, or null if none

Exceptions
ClassCastException:
if the name is not a Attributes.Name or the value is not a String
putAllback to summary
public void putAll(Map<?, ?> attr)

Implements java.util.Map.putAll.

Copies all of the attribute name-value mappings from the specified Attributes to this Map. Duplicate mappings will be replaced.

Parameters
attr:Map<?, ?>

the Attributes to be stored in this map

Exceptions
ClassCastException:
if attr is not an Attributes
putValueback to summary
public 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);
Parameters
name:String

the attribute name as a string

value:String

the attribute value

Returns:String

the previous value of the attribute, or null if none

Exceptions
IllegalArgumentException:
if the attribute name is invalid
readback to summary
pack-priv void read(Manifest.FastInputStream is, byte[] lbuf) throws IOException
readback to summary
pack-priv int read(Manifest.FastInputStream is, byte[] lbuf, String filename, int lineNumber) throws IOException
removeback to summary
public Object remove(Object name)

Implements java.util.Map.remove.

Removes the attribute with the specified name (key) from this Map. Returns the previous attribute value, or null if none.

Parameters
name:Object

attribute name

Returns:Object

the previous value of the attribute, or null if none

sizeback to summary
public int size()

Implements java.util.Map.size.

Returns the number of attributes in this Map.

Returns:int

Doc from java.util.Map.size.

the number of key-value mappings in this map

valuesback to summary
public Collection<Object> values()

Implements java.util.Map.values.

Returns a Collection view of the attribute values contained in this Map.

Returns:Collection<Object>

Doc from java.util.Map.values.

a collection view of the values contained in this map

writeback to summary
pack-priv void write(DataOutputStream out) throws IOException
writeMainback to summary
pack-priv void writeMain(DataOutputStream out) throws IOException
java.util.jar back to summary

public Class Attributes.Name

extends Object
Class Inheritance

The Attributes.Name class represents an attribute name stored in this Map. 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.
External Specification
JAR File Specification

Field Summary

Modifier and TypeField and Description
public static final Attributes.Name
CLASS_PATH

Name object for Class-Path manifest attribute.

public static final Attributes.Name
CONTENT_TYPE

Name object for Content-Type manifest attribute.

public static final Attributes.Name
EXTENSION_INSTALLATION

Deprecated Extension mechanism is no longer supported.
Name object for Extension-Installation manifest attribute.
public static final Attributes.Name
EXTENSION_LIST

Name object for Extension-List manifest attribute used for the extension mechanism that is no longer supported.

public static final Attributes.Name
EXTENSION_NAME

Name object for Extension-Name manifest attribute used for the extension mechanism that is no longer supported.

private final int
public static final Attributes.Name
IMPLEMENTATION_TITLE

Name object for Implementation-Title manifest attribute used for package versioning.

public static final Attributes.Name
IMPLEMENTATION_URL

Deprecated Extension mechanism is no longer supported.
Name object for Implementation-URL manifest attribute.
public static final Attributes.Name
IMPLEMENTATION_VENDOR

Name object for Implementation-Vendor manifest attribute used for package versioning.

public static final Attributes.Name
IMPLEMENTATION_VENDOR_ID

Deprecated Extension mechanism is no longer supported.
Name object for Implementation-Vendor-Id manifest attribute.
public static final Attributes.Name
IMPLEMENTATION_VERSION

Name object for Implementation-Version manifest attribute used for package versioning.

private static Map<String, Attributes.Name>
KNOWN_NAMES

Avoid allocation for common Names

public static final Attributes.Name
MAIN_CLASS

Name object for Main-Class manifest attribute used for launching applications packaged in JAR files.

public static final Attributes.Name
MANIFEST_VERSION

Name object for Manifest-Version manifest attribute.

public static final Attributes.Name
MULTI_RELEASE

Name object for Multi-Release manifest attribute that indicates this is a multi-release JAR file.

private final String
public static final Attributes.Name
SEALED

Name object for Sealed manifest attribute used for sealing.

public static final Attributes.Name
SIGNATURE_VERSION

Name object for Signature-Version manifest attribute used when signing JAR files.

public static final Attributes.Name
SPECIFICATION_TITLE

Name object for Specification-Title manifest attribute used for package versioning.

public static final Attributes.Name
SPECIFICATION_VENDOR

Name object for Specification-Vendor manifest attribute used for package versioning.

public static final Attributes.Name
SPECIFICATION_VERSION

Name object for Specification-Version manifest attribute used for package versioning.

Constructor Summary

AccessConstructor and Description
public
Name(String
the attribute string name
name
)

Constructs a new attribute name using the given string name.

Method Summary

Modifier and TypeMethod and Description
private static void
public boolean

Returns:

true if this attribute name is equal to the specified attribute object
equals
(Object
the object to compare
o
)

Overrides java.lang.Object.equals.

Compares this attribute name to another for equality.

private final int
hash(String name)

public int
hashCode()

Overrides java.lang.Object.hashCode.

Computes the hash value for this attribute name.

pack-priv static final Attributes.Name
of(String name)

public String
toString()

Overrides java.lang.Object.toString.

Returns the attribute name as a String.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

CLASS_PATHback to summary
public static final Attributes.Name CLASS_PATH

Name object for Class-Path manifest attribute.

See Also
JAR file specification
CONTENT_TYPEback to summary
public static final Attributes.Name CONTENT_TYPE

Name object for Content-Type manifest attribute.

EXTENSION_INSTALLATIONback to summary
public static final Attributes.Name EXTENSION_INSTALLATION

Deprecated

Extension mechanism is no longer supported.

Name object for Extension-Installation manifest attribute.

Annotations
@Deprecated
EXTENSION_LISTback to summary
public static final Attributes.Name EXTENSION_LIST

Name object for Extension-List manifest attribute used for the extension mechanism that is no longer supported.

EXTENSION_NAMEback to summary
public static final Attributes.Name EXTENSION_NAME

Name object for Extension-Name manifest attribute used for the extension mechanism that is no longer supported.

hashCodeback to summary
private final int hashCode
IMPLEMENTATION_TITLEback to summary
public static final Attributes.Name IMPLEMENTATION_TITLE

Name object for Implementation-Title manifest attribute used for package versioning.

IMPLEMENTATION_URLback to summary
public static final Attributes.Name IMPLEMENTATION_URL

Deprecated

Extension mechanism is no longer supported.

Name object for Implementation-URL manifest attribute.

Annotations
@Deprecated
IMPLEMENTATION_VENDORback to summary
public static final Attributes.Name IMPLEMENTATION_VENDOR

Name object for Implementation-Vendor manifest attribute used for package versioning.

IMPLEMENTATION_VENDOR_IDback to summary
public static final Attributes.Name IMPLEMENTATION_VENDOR_ID

Deprecated

Extension mechanism is no longer supported.

Name object for Implementation-Vendor-Id manifest attribute.

Annotations
@Deprecated
IMPLEMENTATION_VERSIONback to summary
public static final Attributes.Name IMPLEMENTATION_VERSION

Name object for Implementation-Version manifest attribute used for package versioning.

KNOWN_NAMESback to summary
private static Map<String, Attributes.Name> KNOWN_NAMES

Avoid allocation for common Names

Annotations
@Stable
MAIN_CLASSback to summary
public static final Attributes.Name MAIN_CLASS

Name object for Main-Class manifest attribute used for launching applications packaged in JAR files. The Main-Class attribute is used in conjunction with the -jar command-line option of the java application launcher.

MANIFEST_VERSIONback to summary
public static final Attributes.Name MANIFEST_VERSION

Name object for Manifest-Version manifest attribute. This attribute indicates the version number of the manifest standard to which a JAR file's manifest conforms.

See Also
Manifest and Signature Specification
MULTI_RELEASEback to summary
public static final Attributes.Name MULTI_RELEASE

Name object for Multi-Release manifest attribute that indicates this is a multi-release JAR file.

Since
9
nameback to summary
private final String name
SEALEDback to summary
public static final Attributes.Name SEALED

Name object for Sealed manifest attribute used for sealing.

See Also
Package Sealing
SIGNATURE_VERSIONback to summary
public static final Attributes.Name SIGNATURE_VERSION

Name object for Signature-Version manifest attribute used when signing JAR files.

See Also
Manifest and Signature Specification
SPECIFICATION_TITLEback to summary
public static final Attributes.Name SPECIFICATION_TITLE

Name object for Specification-Title manifest attribute used for package versioning.

SPECIFICATION_VENDORback to summary
public static final Attributes.Name SPECIFICATION_VENDOR

Name object for Specification-Vendor manifest attribute used for package versioning.

SPECIFICATION_VERSIONback to summary
public static final Attributes.Name SPECIFICATION_VERSION

Name object for Specification-Version manifest attribute used for package versioning.

Constructor Detail

Nameback to summary
public Name(String name)

Constructs a new attribute name using the given string name.

Parameters
name:String

the attribute string name

Exceptions
IllegalArgumentException:
if the attribute name was invalid
NullPointerException:
if the attribute name was null

Method Detail

addNameback to summary
private static void addName(Map<String, Attributes.Name> names, Attributes.Name name)
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Compares this attribute name to another for equality.

Parameters
o:Object

the object to compare

Returns:boolean

true if this attribute name is equal to the specified attribute object

hashback to summary
private final int hash(String name)
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Computes the hash value for this attribute name.

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object

ofback to summary
pack-priv static final Attributes.Name of(String name)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns the attribute name as a String.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object