| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.cosylab.util.NameValueList
public class NameValueList
A simple name-value list. Names are strings and values any Java objects
 (where primitives are packed in their respective encapsulation objects).
 Names and values are stored in arrays. The initial dimension of the array
 can be specified or a default can be used ( DEFAULT_CAPACITY =
 10 elements). If more elements are added, the arrays grow in
 DEFAULT_CAPACITY increments. The addition is therefore a fast
 operation,  if the arrays are not resized. The removal, on the other hand,
 resizes the arrays each  time and is a much slower operation. Lookup of
 value by name uses linear search and  string comparison. This object does
 not allow duplicate name entries. If a duplicate  name is provided, the old
 value will be overwritten and returned as a return  value from
 add method.
 
 
This object is thread safe.
The primary purpose of this object is to store small (10 or less) name-value pairs. In this case, the algorithms (including the linear search) are quite effective. An example would be the use for passing the argument values to the method calls.
This class does preserve the order during insertion and deletion operations.
 This class implements the collection Map interface.
 
| Nested Class Summary | 
|---|
| Nested classes/interfaces inherited from interface java.util.Map | 
|---|
| java.util.Map.Entry<K,V> | 
| Constructor Summary | |
|---|---|
| NameValueList()Creates a new instance of this object with the DEFAULT_CAPACITYequal to 10. | |
| NameValueList(int initialCapacity)Creates a new instance of this object with the initial capacity specified by the user. | |
| Method Summary | |
|---|---|
|  void | clear()Sets all elements to null, resets the current pointer to the initial position thereby effectively removing all elements from this map. | 
|  boolean | containsKey(java.lang.Object name)Returns trueif this object contains the name-value mapping
 with the speficiedname. | 
|  boolean | containsValue(java.lang.Object value)Returns trueif this map contains a given value. | 
|  java.util.Set | entrySet()Returns the set of entries, as described in java.util.Map.Entry. | 
|  java.lang.Object | get(java.lang.Object name)Returns an object stored under name. | 
|  java.lang.String[] | getNames()Returns an array of names stored in this data structure. | 
|  boolean | isEmpty()Returns trueiff this map does not contain any name-value
 pairs. | 
|  java.util.Set | keySet()Returns a set of all names. | 
|  java.lang.Object | put(java.lang.Object name,
    java.lang.Object value)Adds a new name-value pair. | 
|  void | putAll(java.util.Map t)Puts all nave-value pairs from provided Map to this Map. | 
|  java.lang.Object | remove(java.lang.Object name)Removes a value stored under nameand returns it. | 
|  int | size()Returns the actual number of entries stored in this data structure. | 
|  java.lang.String | toString()Lists all objects in this list by calling their toString()methods. | 
|  java.util.Collection | values()Returns a collection of all values. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Methods inherited from interface java.util.Map | 
|---|
| equals, hashCode | 
| Constructor Detail | 
|---|
public NameValueList()
DEFAULT_CAPACITY equal to 10.
public NameValueList(int initialCapacity)
initialCapacity - the size of the names and values array at
        construction| Method Detail | 
|---|
public int size()
size in interface java.util.Map
public java.lang.Object put(java.lang.Object name,
                            java.lang.Object value)
put in interface java.util.Mapname - the name to store the value undervalue - a new value for the name
java.lang.ClassCastException - if parameter name is not of type
         Stringpublic java.lang.Object remove(java.lang.Object name)
name and returns it. This
 method resizes the arrays by decreasing them by 1.
remove in interface java.util.Mapname - the name of the value to remove
null if the value with
         the given name did not exist in the structure
java.lang.ClassCastException - if parameter name is not of type
         Stringpublic java.lang.Object get(java.lang.Object name)
name.
get in interface java.util.Mapname - the name to lookup
name or null if
         such  object does not exist
java.lang.ClassCastException - if parameter name is not of type
         Stringpublic java.lang.String[] getNames()
null.
public void clear()
clear in interface java.util.MapMap.clear()public boolean containsKey(java.lang.Object name)
true if this object contains the name-value mapping
 with the speficied name.
containsKey in interface java.util.Mapname - the name to lookup
true iff the mapping with the given name
         exists
java.lang.NullPointerException - if parameter name is nullMap.containsKey(Object)public boolean containsValue(java.lang.Object value)
true if this map contains a given value. This is
 determined as in java.util.Map specifications.
containsValue in interface java.util.Mapvalue - test if this map contains the value
true iff the test succeedsMap.containsValue(Object)public java.util.Set entrySet()
java.util.Map.Entry.
entrySet in interface java.util.MapMap.entrySet()public boolean isEmpty()
true iff this map does not contain any name-value
 pairs.
isEmpty in interface java.util.Maptrue iff emptyMap.isEmpty()public java.util.Set keySet()
keySet in interface java.util.MapMap.keySet()public void putAll(java.util.Map t)
putAll in interface java.util.Mapt - a map argument with which to perform the union operationMap.putAll(Map)public java.util.Collection values()
values in interface java.util.MapMap.values()public java.lang.String toString()
toString()
 methods.
toString in class java.lang.Object| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||