|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
org.globus.common
Class MVHashtable
java.lang.Object | +--org.globus.common.MVHashtable
- All Implemented Interfaces:
- Serializable
- Direct Known Subclasses:
- ConstrainedMVHashtable, MDSResult
- public class MVHashtable
- extends Object
- implements Serializable
- extends Object
MVHashtable is an implementation of a multi-valued hashtable. Each entry of the hashtable is identified by a String key. Besides the key being a String rather than an object, MVHashtable differs from Hashtable in that it maps a single key to multiple values. Each attribute uses a vector for storing multiple values under the same key. Methods are available which help access and manipulate the entries. Where possible, methods are named analogous to similar methods in Hashtable.
- See Also:
- Serialized Form
| Field Summary | |
protected Hashtable |
attribs
holds the attributes of the MVHashtable |
| Constructor Summary | |
MVHashtable()
Default Constructor creates empty MVHashtable. |
|
MVHashtable(int initialSize)
Initial-size Constructor creates empty MVHashtable with specified initial size. |
|
MVHashtable(MVHashtable multivaluedHashtable)
Copy Constructor |
|
| Method Summary | |
void |
add(MVHashtable multivaluedHashtable)
Adds attributes that are stored in a seperate MVHashtable object. |
void |
add(String key,
Object value)
Adds a single value to the specified key. |
void |
add(String key,
Object[] values)
Adds multiple values to the attribute associated with the given key. |
void |
add(String key,
Vector values)
Adds multiple values to the attribute associated with the given key. |
void |
clear()
Deletes all attributes. |
boolean |
contains(String key,
Object value)
Returns true if the given value is stored under a specific attribute. |
boolean |
containsName(String key)
Returns true if the attribute associated with the given key exists. |
Vector |
get(String key)
Returns a vector of values for a specific attribute. |
Object |
getFirstValue(String key)
Returns the first value for a specific attribute. |
Vector |
getKeys()
Returns a vector of the keys. |
Object |
getLastValue(String key)
Returns the last value for a specific attribute. |
Object |
getValueAt(String key,
int index)
Returns a value at the given position index for a specific attribute. |
Enumeration |
keys()
Returns an enumeration of all attribute keys. |
void |
print()
Prints out the contents of the data structure. |
Object |
remove(String key)
Remove an attribute and all values associated with it. |
Object |
remove(String key,
int index)
Removes a value at the specified index within the attribute. |
boolean |
remove(String key,
Object value)
Removes a particular value within an attribute. |
Vector |
set(String key,
Object value)
Sets a new value for the specified attribute. |
int |
size()
Returns the number of attributes. |
int |
size(String key)
Returns the number of entries for an attribute. |
String |
toString()
Converts the internal data structure to a string. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
attribs
protected Hashtable attribs
- holds the attributes of the MVHashtable
| Constructor Detail |
MVHashtable
public MVHashtable()
- Default Constructor creates empty MVHashtable.
MVHashtable
public MVHashtable(int initialSize)
- Initial-size Constructor creates empty MVHashtable with specified
initial size.
- Parameters:
initialSize- the initial capacity of the hashtable.
MVHashtable
public MVHashtable(MVHashtable multivaluedHashtable)
- Copy Constructor
- Parameters:
multivaluedHashtable- the MVHashtable that will start as the base of this new MVHashtable
| Method Detail |
set
public Vector set(String key, Object value)
- Sets a new value for the specified attribute.
- Parameters:
key- the attribute key.value- the entry value.- Returns:
Vectorof previous values associated with the attribute. Null, if the attribute was not associated with any values.
add
public void add(String key, Object value)
- Adds a single value to the specified key.
If there is already an attribute with this key, the
value is appended to the end of values list.
- Parameters:
key- the attribute key.value- the value to add.
add
public void add(String key, Object[] values)
- Adds multiple values to the attribute associated
with the given key. The values are appended
to the end of the values list (if any).
- Parameters:
key- the attribute key.values- the array of values.
add
public void add(String key, Vector values)
- Adds multiple values to the attribute associated
with the given key. The values are appended
to the end of the values list (if any).
- Parameters:
key- the attribute key.value- the Vector of values to add.
add
public void add(MVHashtable multivaluedHashtable)
- Adds attributes that are stored in a seperate MVHashtable object.
- Parameters:
multivaluedHashtable- The to-be-absorbed MVHashtable
remove
public Object remove(String key)
- Remove an attribute and all values associated with it.
- Parameters:
key- the attribute key.- Returns:
- the value to which the key had been mapped in this multivalued hashtable, or null if the key did not have a mapping.
remove
public boolean remove(String key, Object value)
- Removes a particular value within an attribute.
- Parameters:
key- the attribute key.value- the value to delete.- Returns:
- true if the value was removed, false otherwise.
remove
public Object remove(String key, int index)
- Removes a value at the specified index within the
attribute. Note that the indicies of all objects greater
than "index" are decremented by one.
- Parameters:
key- the attribute key.index- the index of the value to delete.- Returns:
- the element that was removed from the list of valus
clear
public void clear()
- Deletes all attributes.
size
public int size()
- Returns the number of attributes.
- Returns:
intthe number of attributes
size
public int size(String key)
- Returns the number of entries for an attribute.
- Parameters:
key- The attribute key.- Returns:
intthe number of entries of the attribute
containsName
public boolean containsName(String key)
- Returns true if the attribute associated with the given key exists.
- Parameters:
key- The attribute key.- Returns:
booleantrue if attribute exists, false if not
contains
public boolean contains(String key, Object value)
- Returns true if the given value is stored under a specific attribute.
- Parameters:
key- the attribute key.value- the entry value.- Returns:
booleantrue if value is stored under specified attribute
keys
public Enumeration keys()
- Returns an enumeration of all attribute keys.
- Returns:
Enumerationof all attribute keys
getKeys
public Vector getKeys()
- Returns a vector of the keys. Keys are strings.
- Returns:
Vectorof keys
get
public Vector get(String key)
- Returns a vector of values for a specific attribute.
- Parameters:
key- the attribute key.- Returns:
Vectorof values for the specified attribute
getFirstValue
public Object getFirstValue(String key)
- Returns the first value for a specific attribute.
- Parameters:
key- the attribute key.- Returns:
Objectthe first value for the specified attribute
getLastValue
public Object getLastValue(String key)
- Returns the last value for a specific attribute.
- Parameters:
key- the attribute key.- Returns:
Objectthe last value for the specified attribute
getValueAt
public Object getValueAt(String key, int index)
- Returns a value at the given position index for a specific
attribute.
- Parameters:
key- the attribute key.index- the index of the value to return for the attribute.- Returns:
Objectthe value at the specified index position of the specified attribute. Null if not found.
public void print()
- Prints out the contents of the data structure. This method is
used for debugging purposes.
toString
public String toString()
- Converts the internal data structure to a string.
- Returns:
Stringa string representation of this structure.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||