com.raritantechnologies.utils
Class OrderedMap

java.lang.Object
  extended bycom.raritantechnologies.utils.OrderedMap
All Implemented Interfaces:
java.util.Map, java.io.Serializable

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

java.util.Map implementation that preserves the order of objects added to the map.


Developed by Raritan Technologies .

Author:
Ted Sullivan
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Constructor Summary
OrderedMap()
           
OrderedMap(java.util.Map map)
           
 
Method Summary
 void add(java.lang.Object key, java.lang.Object value)
           
 void clear()
           
 OrderedMap combineWith(OrderedMap another, boolean after)
           
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.List entryList()
           
 java.util.Set entrySet()
          Returns a set view of the mappings contained in this map.
 boolean equals(java.lang.Object o)
          Compares the specified object with this map for equality.
 boolean equals(OrderedMap another, java.lang.String excludeFields)
           
 boolean equals(OrderedMap another, java.lang.String excludeFields, boolean ignoreNulls)
           
 java.lang.String formatMap(java.lang.String valueSeparator, java.lang.String fieldSeparator)
          Returns a String containing all of the name=value pairs using the value separator and field separators given.
 java.lang.Object get(java.lang.Object key)
           
 int hashCode()
          Returns the hash code value for this map.
 boolean isEmpty()
           
 java.util.Set keySet()
           
static void main(java.lang.String[] args)
           
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
 void putAll(java.util.Map t)
           
 java.lang.Object remove(java.lang.Object key)
           
 void setMaxSize(int maxSize)
           
 int size()
           
 java.lang.String toString()
           
 java.util.Collection values()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OrderedMap

public OrderedMap()

OrderedMap

public OrderedMap(java.util.Map map)
Method Detail

combineWith

public OrderedMap combineWith(OrderedMap another,
                              boolean after)

setMaxSize

public void setMaxSize(int maxSize)

size

public int size()
Specified by:
size in interface java.util.Map

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface java.util.Map

containsValue

public boolean containsValue(java.lang.Object value)
Specified by:
containsValue in interface java.util.Map

get

public java.lang.Object get(java.lang.Object key)
Specified by:
get in interface java.util.Map

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Specified by:
put in interface java.util.Map

add

public void add(java.lang.Object key,
                java.lang.Object value)

remove

public java.lang.Object remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map

putAll

public void putAll(java.util.Map t)
Specified by:
putAll in interface java.util.Map

clear

public void clear()
Specified by:
clear in interface java.util.Map

keySet

public java.util.Set keySet()
Specified by:
keySet in interface java.util.Map

values

public java.util.Collection values()
Specified by:
values in interface java.util.Map

entrySet

public java.util.Set entrySet()
Returns a set view of the mappings contained in this map. Each element in the returned set is a Map.Entry. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress, the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations. Returns: a set view of the mappings contained in this map.

Specified by:
entrySet in interface java.util.Map

entryList

public java.util.List entryList()

equals

public boolean equals(java.lang.Object o)
Compares the specified object with this map for equality. Returns true if the given object is also a map and the two Maps represent the same mappings. More formally, two maps t1 and t2 represent the same mappings if t1.entrySet().equals(t2.entrySet()). This ensures that the equals method works properly across different implementations of the Map interface. Overrides: equals in class Object Parameters: o - object to be compared for equality with this map. Returns: true if the specified object is equal to this map.

Specified by:
equals in interface java.util.Map

equals

public boolean equals(OrderedMap another,
                      java.lang.String excludeFields)

equals

public boolean equals(OrderedMap another,
                      java.lang.String excludeFields,
                      boolean ignoreNulls)

toString

public java.lang.String toString()

formatMap

public java.lang.String formatMap(java.lang.String valueSeparator,
                                  java.lang.String fieldSeparator)
Returns a String containing all of the name=value pairs using the value separator and field separators given.


hashCode

public int hashCode()
Returns the hash code value for this map. The hash code of a map is defined to be the sum of the hashCodes of each entry in the map's entrySet view. This ensures that t1.equals(t2) implies that t1.hashCode()==t2.hashCode() for any two maps t1 and t2, as required by the general contract of Object.hashCode. Overrides: hashCode in class Object Returns: the hash code value for this map. See Also: Map.Entry.hashCode(), Object.hashCode(), Object.equals(Object), equals(Object)

Specified by:
hashCode in interface java.util.Map

main

public static void main(java.lang.String[] args)