com.digi.config.util
Class ArrayMap

java.lang.Object
  extended bycom.digi.config.util.ArrayMap
All Implemented Interfaces:
java.util.Map, java.io.Serializable

public class ArrayMap
extends java.lang.Object
implements java.util.Map, java.io.Serializable

This class provides a map collection with a concept of insert order. That is, when iterating over the collection, they will be returned in the order they were inserted into the collection. Users are still free to operate on the collection as a map however.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Constructor Summary
ArrayMap()
          Construct an empty ArrayMap
ArrayMap(ArrayMap map)
          Construct an ArrayMap and populate it with items from the specified map.
ArrayMap(java.util.Map map)
          Construct an ArrayMap and populate it with items from the specified map.
 
Method Summary
 void clear()
          Removes all items from the ArrayMap
 boolean containsKey(java.lang.Object key)
          Indicates if the specified key is found in the ArrayMap
 boolean containsValue(java.lang.Object value)
          Indicates if the specified value is found in the ArrayMap
 ArrayMap copy()
          Creates a new ArrayMap containing the same elements and order as this ArrayMap.
 java.util.Set entrySet()
          Returns the set of Map.Entrys for the ArrayMap Note: do not add or remove elements from the returned set as it will corrupt the contents of the ArrayMap.
 boolean equals(java.lang.Object o)
          Compares the ArrayMap against the specified object
 java.lang.Object get(java.lang.Object key)
          Looks for an object in the ArrayMap that was stored under the specified key.
 int hashCode()
          Produces a hashcode for the ArrayMap
 boolean isEmpty()
          Indicates if the ArrayMap is empty or not
 java.util.Set keySet()
          Returns the set of keys for the ArrayMap Note: do not add or remove elements from the returned set as it will corrupt the contents of the ArrayMap
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Inserts an element into the collection under a specified lookup key.
 void putAll(java.util.Map t)
          Inserts all items found in a specified map into the ArrayMap.
 java.lang.Object putAt(java.lang.Object key, int position, java.lang.Object value)
          Inserts an element into the collection under a specified lookup key and in the specified position.
 java.lang.Object remove(java.lang.Object key)
          Removes the element from the collection found under the specified lookup key.
 int size()
          Returns the number of elements in the ArrayMap
 java.util.Collection values()
          Returns the ordered collection of values found in the ArrayMap.
 java.util.List valuesList()
          Returns the ordered List of values found in the ArrayMap.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayMap

public ArrayMap()
Construct an empty ArrayMap


ArrayMap

public ArrayMap(java.util.Map map)
Construct an ArrayMap and populate it with items from the specified map. Order of elements will be iteration order of the map.

Parameters:
map - a map of the elements to be added to the ArrayMap

ArrayMap

public ArrayMap(ArrayMap map)
Construct an ArrayMap and populate it with items from the specified map. Order of elements will be iteration order of the map.

Parameters:
map - a map of the elements to be added to the ArrayMap
Method Detail

size

public int size()
Returns the number of elements in the ArrayMap

Specified by:
size in interface java.util.Map

isEmpty

public boolean isEmpty()
Indicates if the ArrayMap is empty or not

Specified by:
isEmpty in interface java.util.Map

containsKey

public boolean containsKey(java.lang.Object key)
Indicates if the specified key is found in the ArrayMap

Specified by:
containsKey in interface java.util.Map
Parameters:
key - the key to check for in the ArrayMap

containsValue

public boolean containsValue(java.lang.Object value)
Indicates if the specified value is found in the ArrayMap

Specified by:
containsValue in interface java.util.Map
Parameters:
value - the value to check for in the ArrayMap

get

public java.lang.Object get(java.lang.Object key)
Looks for an object in the ArrayMap that was stored under the specified key.

Specified by:
get in interface java.util.Map
Parameters:
key - the value to check for in the ArrayMap
Returns:
the object stored under the specified key. null if no object was found.

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Inserts an element into the collection under a specified lookup key. Note: when replacing a previous item in the collection under the same lookup key, this method performs a linear scan to place the new item in the same position as the old item was at.

Specified by:
put in interface java.util.Map
Parameters:
key - the lookup key for the item being inserted
value - the item being stored in the collection

putAt

public java.lang.Object putAt(java.lang.Object key,
                              int position,
                              java.lang.Object value)
Inserts an element into the collection under a specified lookup key and in the specified position. The insert is non-destructive and will simply move existing elements at that position back one position.

Parameters:
key - the lookup key for the item being inserted
position - the position in the ArrayMap to insert the item at
value - the item being stored in the collection

remove

public java.lang.Object remove(java.lang.Object key)
Removes the element from the collection found under the specified lookup key.

Note: this method performs a linear scan to locate item in ordered element portion of the ArrayMap

Specified by:
remove in interface java.util.Map
Parameters:
key - the lookup key for the item being removed
Returns:
value the item being removed from the collection. null if the item was not found

putAll

public void putAll(java.util.Map t)
Inserts all items found in a specified map into the ArrayMap. The items will be inserted in the order they are returned from the map iterator.

Specified by:
putAll in interface java.util.Map
Parameters:
t - the map whose items are to be added to the ArrayMap

clear

public void clear()
Removes all items from the ArrayMap

Specified by:
clear in interface java.util.Map

keySet

public java.util.Set keySet()
Returns the set of keys for the ArrayMap

Note: do not add or remove elements from the returned set as it will corrupt the contents of the ArrayMap

Specified by:
keySet in interface java.util.Map

values

public java.util.Collection values()
Returns the ordered collection of values found in the ArrayMap. The returned order will be the order in which the items were put into the ArrayMap. Note that if different items were put under the same key the new item replaces the old item and assumes its position in the ordered collection.

Note, this collection is not backed by the map. Adding or removing items from the returned collection will not affect the contents of the ArrayMap.

Specified by:
values in interface java.util.Map

entrySet

public java.util.Set entrySet()
Returns the set of Map.Entrys for the ArrayMap

Note: do not add or remove elements from the returned set as it will corrupt the contents of the ArrayMap.

Specified by:
entrySet in interface java.util.Map

equals

public boolean equals(java.lang.Object o)
Compares the ArrayMap against the specified object

Specified by:
equals in interface java.util.Map

hashCode

public int hashCode()
Produces a hashcode for the ArrayMap

Specified by:
hashCode in interface java.util.Map

valuesList

public java.util.List valuesList()
Returns the ordered List of values found in the ArrayMap. The returned order will be the order in which the items were put into the ArrayMap. Note that if different items were put under the same key the new item replaces the old item and assumes its position in the ordered collection.

Note, this collection is not backed by the map. Adding or removing items from the returned collection will not affect the contents of the ArrayMap.


copy

public ArrayMap copy()
Creates a new ArrayMap containing the same elements and order as this ArrayMap.



Copyright © 2001-2002 Digi International. All Rights Reserved.