|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.brains2b.collection.SortedMap
Map implementation that can be sorted defined by a given sort order
Not sorted is the default implementation.
Note:When using SortedMap with a Hashtable the sort order first is set to KEY. All other MAPs are set to NO_SORT regardless of how the Map sorting was implemented.
Nested Class Summary |
Nested classes inherited from class java.util.Map |
java.util.Map.Entry |
Field Summary | |
static int |
KEY
value to set sorting on KEY |
static int |
NO_SORT
value to set NO SORTING |
static int |
VALUE
value to set sorting on VALUE |
Constructor Summary | |
SortedMap()
Constructor for SortedMap. |
|
SortedMap(java.util.Hashtable ht)
Constructor for SortedMap. |
|
SortedMap(int sortOrder)
Constructor for SortedMap. |
|
SortedMap(java.util.Map map)
Constructor for SortedMap. |
|
SortedMap(java.util.Map map,
int sortOrder)
Constructor for SortedMap. |
Method Summary | |
void |
clear()
|
int |
compare(java.lang.Object oLeft,
java.lang.Object oRight)
compare to Objects and returns the natural order |
boolean |
containsKey(java.lang.Object key)
|
boolean |
containsValue(java.lang.Object value)
|
java.util.Set |
entrySet()
|
java.lang.Object |
get(java.lang.Object key)
Overwritten the default get for performance reasons |
int |
getSortOrder()
gets the sort order. |
boolean |
isEmpty()
|
java.util.Set |
keySet()
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
SortedMap does not allow null for keys or values |
void |
putAll(java.util.Map m)
|
java.lang.Object |
remove(java.lang.Object key)
|
void |
setSortOrder(int sortOrder)
sets the sort order for this SortedMap |
int |
size()
|
java.util.Collection |
values()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Map |
equals, hashCode |
Methods inherited from interface java.util.Comparator |
equals |
Field Detail |
public static final int KEY
public static final int VALUE
public static final int NO_SORT
Constructor Detail |
public SortedMap(int sortOrder)
initializes an empty SortedMap with the supplied sort Order
sortOrder
- public SortedMap()
initializes an empty SortedMap with NO_SORT
public SortedMap(java.util.Map map, int sortOrder)
Initializes the SortedMap with a Map and a given sortOrder
map
- sortOrder
- public SortedMap(java.util.Map map)
initializes the SortedMap with a Map and no sort order
map
- java.util.Mappublic SortedMap(java.util.Hashtable ht)
initializes the SortedMap with a Hashtable, sorted on keys
ht
- HashtableMethod Detail |
public int getSortOrder()
public void setSortOrder(int sortOrder)
sortOrder
- int, the new sort order for this SortedMap,
possible values are: KEY,VALUE, NO_SORTpublic int compare(java.lang.Object oLeft, java.lang.Object oRight)
Implementation takes the given sort order into account and will compare the keys or values respectively. It will always return 1 if sort order is set to NO_SORT
compare
in interface java.util.Comparator
Comparator.compare(Object, Object)
public java.util.Set entrySet()
entrySet
in interface java.util.Map
Map.entrySet()
public java.lang.Object get(java.lang.Object key)
We bypass the entrySet() while it will sort the collection first. Something we don't need to get an individual value
get
in interface java.util.Map
AbstractMap.get(java.lang.Object)
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
put
in interface java.util.Map
Map.put(Object, Object)
public void putAll(java.util.Map m)
putAll
in interface java.util.Map
Map.putAll(Map)
public java.lang.Object remove(java.lang.Object key)
remove
in interface java.util.Map
Map.remove(Object)
public void clear()
clear
in interface java.util.Map
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map
public boolean isEmpty()
isEmpty
in interface java.util.Map
public java.util.Set keySet()
keySet
in interface java.util.Map
public int size()
size
in interface java.util.Map
public java.util.Collection values()
values
in interface java.util.Map
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |