|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
org.globus.common
Class MVHashtable
java.lang.Object | +--org.globus.common.MVHashtable
- All Implemented Interfaces:
- java.io.Serializable
- Direct Known Subclasses:
- ConstrainedMVHashtable, MDSResult
- public class MVHashtable
- extends java.lang.Object
- implements java.io.Serializable
- extends java.lang.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 java.util.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(java.lang.String key,
java.lang.Object value)
Adds a single value to the specified key. |
void |
add(java.lang.String key,
java.lang.Object[] values)
Adds multiple values to the attribute associated with the given key. |
void |
add(java.lang.String key,
java.util.Vector values)
Adds multiple values to the attribute associated with the given key. |
void |
clear()
Deletes all attributes. |
boolean |
contains(java.lang.String key,
java.lang.Object value)
Returns true if the given value is stored under a specific attribute. |
boolean |
containsName(java.lang.String key)
Returns true if the attribute associated with the given key exists. |
java.util.Vector |
get(java.lang.String key)
Returns a vector of values for a specific attribute. |
java.lang.Object |
getFirstValue(java.lang.String key)
Returns the first value for a specific attribute. |
java.util.Vector |
getKeys()
Returns a vector of the keys. |
java.lang.Object |
getLastValue(java.lang.String key)
Returns the last value for a specific attribute. |
java.lang.Object |
getValueAt(java.lang.String key,
int index)
Returns a value at the given position index for a specific attribute. |
java.util.Enumeration |
keys()
Returns an enumeration of all attribute keys. |
void |
print()
Prints out the contents of the data structure. |
java.lang.Object |
remove(java.lang.String key)
Remove an attribute and all values associated with it. |
java.lang.Object |
remove(java.lang.String key,
int index)
Removes a value at the specified index within the attribute. |
boolean |
remove(java.lang.String key,
java.lang.Object value)
Removes a particular value within an attribute. |
java.util.Vector |
set(java.lang.String key,
java.lang.Object value)
Sets a new value for the specified attribute. |
int |
size()
Returns the number of attributes. |
int |
size(java.lang.String key)
Returns the number of entries for an attribute. |
java.lang.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 java.util.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 java.util.Vector set(java.lang.String key,
java.lang.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(java.lang.String key,
java.lang.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(java.lang.String key,
java.lang.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(java.lang.String key,
java.util.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.
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 java.lang.Object remove(java.lang.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(java.lang.String key,
java.lang.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 java.lang.Object remove(java.lang.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(java.lang.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(java.lang.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(java.lang.String key,
java.lang.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 java.util.Enumeration keys()
- Returns an enumeration of all attribute keys.
- Returns:
Enumerationof all attribute keys
getKeys
public java.util.Vector getKeys()
- Returns a vector of the keys. Keys are strings.
- Returns:
Vectorof keys
get
public java.util.Vector get(java.lang.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 java.lang.Object getFirstValue(java.lang.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 java.lang.Object getLastValue(java.lang.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 java.lang.Object getValueAt(java.lang.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 java.lang.String toString()
- Converts the internal data structure to a string.
- Overrides:
toStringin classjava.lang.Object
- Returns:
Stringa string representation of this structure.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||