This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


java.util.jar
class Attributes

java.lang.Object extended by java.util.jar.Attributes
All Implemented Interfaces:
Cloneable, Map

Most common ways to construct:

JarURLConnection uc = …;

Attributes attr = uc.getMainAttributes();

Based on 19 examples

 

Manifest manifest = …;

Attributes attributes = manifest.getMainAttributes();

Based on 15 examples


public class Attributes
extends Object
implements Map, 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.


Nested Class Summary
static class

           The Attributes.Name class represents an attribute name stored in this Map.
 
Field Summary
protected Map map
          The attribute name-value mappings.
 
Constructor Summary

          Constructs a new, empty Attributes object with default size.

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

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

          Removes all attributes from this Map.
 Object

          Returns a copy of the Attributes, implemented as follows:
 boolean

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

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

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

          Compares the specified Attributes object with this Map for equality.
 Object
get(Object name)

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

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

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

          Returns the hash code value for this Map.
 boolean

          Returns true if this Map contains no attributes.
 Set

          Returns a Set view of the attribute names (keys) contained in this Map.
 Object
put(Object name, Object value)

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

          Copies all of the attribute name-value mappings from the specified Attributes to this Map.
 String
putValue(String name, String value)

          Associates the specified value with the specified attribute name, specified as a String.
 Object
remove(Object name)

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

          Returns the number of attributes in this Map.
 Collection

          Returns a Collection view of the attribute values contained in this Map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

map

protected Map map
The attribute name-value mappings.
Constructor Detail

Attributes

public Attributes()
Constructs a new, empty Attributes object with default size.


Attributes

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

Parameters:
attr - the specified Attributes

Attributes

public Attributes(int size)
Constructs a new, empty Attributes object with the specified initial size.

Parameters:
size - the initial number of attributes
Method Detail

clear

public void clear()
Removes all attributes from this Map.


clone

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.

Overrides:
clone in class Object

containsKey

public boolean containsKey(Object name)
Returns true if this Map contains the specified attribute name (key).

Parameters:
name - the attribute name
Returns:
true if this Map contains the specified attribute name

containsValue

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

Parameters:
value - the attribute value
Returns:
true if this Map maps one or more attribute names to the specified value

entrySet

public Set entrySet()
Returns a Collection view of the attribute name-value mappings contained in this Map.


equals

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.

Overrides:
equals in class Object
Parameters:
o - the Object to be compared
Returns:
true if the specified Object is equal to this Map

get

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

Parameters:
name - the attribute name
Returns:
the value of the specified attribute name, or null if not found.

getValue

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 - the Attributes.Name object
Returns:
the String value of the specified Attribute.Name, or null if not found.

getValue

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 - the attribute name as a string
Returns:
the String value of the specified attribute name, or null if not found.

hashCode

public int hashCode()
Returns the hash code value for this Map.

Overrides:
hashCode in class Object

isEmpty

public boolean isEmpty()
Returns true if this Map contains no attributes.


keySet

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


put

public 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.

Parameters:
name - the attribute name
value - the attribute value
Returns:
the previous value of the attribute, or null if none

putAll

public void putAll(Map attr)
Copies all of the attribute name-value mappings from the specified Attributes to this Map. Duplicate mappings will be replaced.

Parameters:
attr - the Attributes to be stored in this map

putValue

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 - the attribute name as a string
value - the attribute value
Returns:
the previous value of the attribute, or null if none

remove

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

Parameters:
name - attribute name
Returns:
the previous value of the attribute, or null if none

size

public int size()
Returns the number of attributes in this Map.


values

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



This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.