java.util.jar
Class Attributes
- Cloneable, Map
Represents attribute name/value pairs from a Manifest as a Map.
The names of an attribute are represented by the
Attributes.Name
class and should confirm to the restrictions
described in that class. Note that the Map interface that Attributes
implements allows you to put names and values into the attribute that don't
follow these restriction (and are not really Atrribute.Names, but if you do
that it might cause undefined behaviour later).
If you use the constants defined in the inner class Name then you can be
sure that you always access the right attribute names. This makes
manipulating the Attributes more or less type safe.
Most of the methods are wrappers to implement the Map interface. The really
useful and often used methods are
getValue(Name)
and
getValue(String)
. If you actually want to set attributes you
may want to use the
putValue(String, String)
method
(sorry there is no public type safe
putValue(Name, String)
method).
protected Map | map - The map that holds all the attribute name/value pairs.
|
Attributes() - Creates an empty Attributes map.
|
Attributes(int size) - Creates an empty Attributes map with the given initial size.
|
Attributes(Attributes attr) - Creates an Attributes map with the initial values taken from another
Attributes map.
|
void | clear() - Removes all attributes.
|
Object | clone() - Return a clone of this attribute map.
|
boolean | containsKey(Object attrName) - Checks to see if there is an attribute with the specified name.
|
boolean | containsValue(Object attrValue) - Checks to see if there is an attribute name with the specified value.
|
Set | entrySet() - Gives a Set of attribute name and values pairs as MapEntries.
|
boolean | equals(Object o) - Checks to see if two Attributes are equal.
|
Object | get(Object attrName) - Gets the value of a specified attribute name.
|
String | getValue(String name) - Gets the value of an attribute name given as a String.
|
String | getValue(Attributes.Name name) - Gets the value of the given attribute name.
|
int | hashCode() - Returns the hashcode of the attribute name/value map.
|
boolean | isEmpty() - Returns true if there are no attributes set, false otherwise.
|
Set | keySet() - Gives a Set of all the values of defined attribute names.
|
Object | put(Object name, Object value) - Adds or replaces a attribute name/value pair.
|
void | putAll(Map attr) - Adds or replaces all attribute name/value pairs from another
Attributes object to this one.
|
String | putValue(String name, String value) - Stores an attribute name (represented by a String) and value in this
Attributes map.
|
Object | remove(Object name) - Remove a attribute name/value pair.
|
int | size() - Returns the number of defined attribute name/value pairs.
|
Collection | values() - Returns all the values of the defined attribute name/value pairs as a
Collection.
|
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait |
map
protected Map map
The map that holds all the attribute name/value pairs. In this
implementation it is actually a Hashtable, but that can be different in
other implementations.
Attributes
public Attributes()
Creates an empty Attributes map.
Attributes
public Attributes(int size)
Creates an empty Attributes map with the given initial size.
size
- the initial size of the underlying map
Attributes
public Attributes(Attributes attr)
Creates an Attributes map with the initial values taken from another
Attributes map.
attr
- Attributes map to take the initial values from
clear
public void clear()
Removes all attributes.
- clear in interface Map
containsKey
public boolean containsKey(Object attrName)
Checks to see if there is an attribute with the specified name.
XXX - what if the object is a String?
- containsKey in interface Map
attrName
- the name of the attribute to check
- true if there is an attribute with the specified name, false
otherwise
containsValue
public boolean containsValue(Object attrValue)
Checks to see if there is an attribute name with the specified value.
- containsValue in interface Map
attrValue
- the value of a attribute to check
- true if there is an attribute name with the specified value,
false otherwise
entrySet
public Set entrySet()
Gives a Set of attribute name and values pairs as MapEntries.
- entrySet in interface Map
- a set of attribute name value pairs
equals
public boolean equals(Object o)
Checks to see if two Attributes are equal. The supplied object must be
a real instance of Attributes and contain the same attribute name/value
pairs.
- equals in interface Map
- equals in interface Object
o
- another Attribute object which should be checked for equality
- true if the object is an instance of Attributes and contains the
same name/value pairs, false otherwise
get
public Object get(Object attrName)
Gets the value of a specified attribute name.
XXX - what if the object is a String?
- get in interface Map
attrName
- the name of the attribute we want the value of
- the value of the specified attribute name or null when there is
no such attribute name
getValue
public String getValue(String name)
Gets the value of an attribute name given as a String.
name
- a String describing the Name to look for
- the value gotten from the map of null when not found
getValue
public String getValue(Attributes.Name name)
Gets the value of the given attribute name.
name
- the Name to look for
- the value gotten from the map of null when not found
isEmpty
public boolean isEmpty()
Returns true if there are no attributes set, false otherwise.
- isEmpty in interface Map
keySet
public Set keySet()
Gives a Set of all the values of defined attribute names.
- keySet in interface Map
put
public Object put(Object name,
Object value)
Adds or replaces a attribute name/value pair.
XXX - What if the name is a string? What if the name is neither a Name
nor a String? What if the value is not a string?
- put in interface Map
name
- the name of the attributevalue
- the (new) value of the attribute
- the old value of the attribute or null when there was no old
attribute with this name
putAll
public void putAll(Map attr)
Adds or replaces all attribute name/value pairs from another
Attributes object to this one. The supplied Map must be an instance of
Attributes.
- putAll in interface Map
attr
- the Attributes object to merge with this one
putValue
public String putValue(String name,
String value)
Stores an attribute name (represented by a String) and value in this
Attributes map.
When the (case insensitive string) name already exists the value is
replaced and the old value is returned.
name
- a (case insensitive) String representation of the attribite
name to add/replacevalue
- the (new) value of the attribute name
remove
public Object remove(Object name)
Remove a attribute name/value pair.
XXX - What if the name is a String?
- remove in interface Map
name
- the name of the attribute name/value pair to remove
- the old value of the attribute or null if the attribute didn't
exist
size
public int size()
Returns the number of defined attribute name/value pairs.
- size in interface Map
values
public Collection values()
Returns all the values of the defined attribute name/value pairs as a
Collection.
- values in interface Map
Attributes.java -- Represents attribute name/value pairs from a Manifest
Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.