org.cip4.jdflib.util
Class VectorMap<key,vectorObject>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<key,java.util.Vector<vectorObject>>
          extended by org.cip4.jdflib.util.VectorMap<key,vectorObject>
Type Parameters:
key - the type used for the key
vectorObject - the type used for individual elements of each vector in the map
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<key,java.util.Vector<vectorObject>>
Direct Known Subclasses:
JDFAmountPool.AmountMap

public class VectorMap<key,vectorObject>
extends java.util.HashMap<key,java.util.Vector<vectorObject>>

HashMap of multiple elements utility class

Author:
Rainer Prosi
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Field Summary
private static long serialVersionUID
           
 
Constructor Summary
VectorMap()
          null constructor
 
Method Summary
 void appendUnique(key key, java.util.Vector<vectorObject> vVal)
          append a map, ensuring uniqueness
 void appendUnique(VectorMap<key,vectorObject> map)
          append a VectorMap, ensuring uniqueness
 java.util.Vector<vectorObject> getAllValues()
          get all values as one big vector, multiple entries are retained (see ContainerUtil.unify())
 int getIndex(key key, vectorObject singleObject)
          get the index of singleObject in the vector of key
 vectorObject getOne(java.lang.Object key, int i)
          get the value for key
 void putOne(key key, vectorObject val)
          put the value for key, ensuring uniqueness
 void removeOne(key key, vectorObject val)
          remove the value for key,also remove key if the vector is empty
 void setOne(key key, vectorObject newObj, vectorObject oldObj)
          replace the value for key, add if oldObj==null or is not there
 int size(key key)
          get the size of the vector for key
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

VectorMap

public VectorMap()
null constructor

Method Detail

getOne

public vectorObject getOne(java.lang.Object key,
                           int i)
get the value for key

Parameters:
key - the search key
i - the index in the vecor matching key; if <0 count from the back of the vector
Returns:
the matching vectorObject; null if the key does not exist or i is out of range

getIndex

public int getIndex(key key,
                    vectorObject singleObject)
get the index of singleObject in the vector of key

Parameters:
key - the key of the vector
singleObject - the object to search
Returns:
-2: no such key; -1: no value in key; else the index in the vexctor of key

size

public int size(key key)
get the size of the vector for key

Parameters:
key - the key of the vector
Returns:
the size of the vector for key, 0 if no key exists

putOne

public void putOne(key key,
                   vectorObject val)
put the value for key, ensuring uniqueness

Parameters:
key - the key of the vector
val - the vector element

appendUnique

public void appendUnique(key key,
                         java.util.Vector<vectorObject> vVal)
append a map, ensuring uniqueness

Parameters:
key - the key of the vector
vVal - the vector of elements

appendUnique

public void appendUnique(VectorMap<key,vectorObject> map)
append a VectorMap, ensuring uniqueness

Parameters:
map - the map to add

getAllValues

public java.util.Vector<vectorObject> getAllValues()
get all values as one big vector, multiple entries are retained (see ContainerUtil.unify())

Returns:
a vector of all values

removeOne

public void removeOne(key key,
                      vectorObject val)
remove the value for key,also remove key if the vector is empty

Parameters:
key - the key of the vector
val - the vector element

setOne

public void setOne(key key,
                   vectorObject newObj,
                   vectorObject oldObj)
replace the value for key, add if oldObj==null or is not there

Parameters:
key - the key of the vector
newObj - the new object to set
oldObj - the old object to replace