|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.dhmp.util.BasicHierarchicalMap
Reference implementation of HierarchicalMap. Internally, it uses a LinkedHashMultiMap data structure, which is similar to java.util.LinkedHashMap but also accepts multiple occurrence of the same key. This class keeps an internal hash table with default initial size (16) and initial threshold (80%). When the quantity of entries in the hash table achieves the threshold (size * threshold) then rehash process occurs doubling the size of hash table.
This implementation is not thread safe.
Nested Class Summary | |
class |
BasicHierarchicalMap.BasicHierarchicalMapCollection
|
Nested classes inherited from class org.dhmp.util.HierarchicalMap |
HierarchicalMap.EntrySet |
Field Summary | |
static int |
ACCESS_ORDER
The last element accessed using get or put method will be placed as the last element returned during iteration. |
LinkedHashMultiMap |
children
|
static int |
INSERTION_ORDER
Iteration will return the elements in first-in first-out order (FIFO). |
static int |
maximumDepth
Maximum iteration that can occur during toString()
method call. |
static int |
REVERSE_ACCESS_ORDER
The last element accessed using get or put method will be placed as the first element returned during iteration. |
Fields inherited from interface org.dhmp.util.HierarchicalMap |
DEFAULT_PATH_SEPARATOR |
Constructor Summary | |
BasicHierarchicalMap()
Default constructor. |
|
BasicHierarchicalMap(int intialSize)
Constructs an empty BasicHierarchicalMap with specified initial size and default threshold (80%). |
|
BasicHierarchicalMap(int intialSize,
float loadFactor)
Constructs an empty BasicHierarchicalMap with specified initial size and loadFactor. |
|
BasicHierarchicalMap(int intialSize,
float loadFactor,
int accessFormat)
Construct an empty BasicHierarchicalMap with a specific initial size, load factor, and ordering mode. |
Method Summary | |
HierarchicalMap |
add(java.lang.Object key)
Associates a new HierarchicalMap with the specified key in this map. |
HierarchicalMap |
add(java.lang.Object[] key)
Associates a new HierarchicalMap with the specified key in this map. |
java.lang.Object |
add(java.lang.Object[] key,
java.lang.Object value)
Associates the specified value with the specified key in this map. |
java.lang.Object |
add(java.lang.Object key,
java.lang.Object value)
Associates the specified value with the specified key in this map. |
HierarchicalMap |
addAll(HierarchicalMap hmap)
Adds all the entries contained in the specified hierarchicalmap into this map. |
java.lang.Object |
addAll(java.lang.Object[] key,
java.util.Collection values)
Associates all the values contained in the specified collection with the specified key in this map. |
java.util.Collection |
addAll(java.lang.Object[] key,
HierarchicalMap hmap)
Associates all the values contained in the specified hierarchicalmap with the specified key in this map. |
java.lang.Object |
addAll(java.lang.Object key,
java.util.Collection values)
Associates all the values contained in the specified collection with the specified key in this map. |
java.util.Collection |
addAll(java.lang.Object key,
HierarchicalMap hmap)
Adds all the entries with specified key contained in the specified hierarchicalmap into this map under key. |
java.lang.Object |
clone()
Returns a cloned HierarchicalMap. |
java.util.Set |
entrySet()
Returns a set view of the mappings contained in this map. |
boolean |
equals(java.lang.Object o)
|
java.lang.Object |
get()
Returns the value of oldest mapping added to this map. |
java.lang.Object |
get(java.lang.Object key)
Returns the value in this map associated to the specified key. |
java.lang.Object |
get(java.lang.Object[] key)
Returns the value in this map associated to the specified key. |
java.util.Collection |
getAll(java.lang.Object key)
Returns a collection view of all the values to which this map maps the specified key. |
java.util.Collection |
getAll(java.lang.Object[] key)
Returns collection containing all the value in this map associated to the specified key. |
java.lang.String |
getPathSeparator()
Returns the current characters considered as path separators. |
java.util.Set |
keySet()
Returns a set view of the keys contained in this map. |
HierarchicalMap |
newInstance()
Creates a new instance of empty HierarchicalMap. |
java.lang.Object |
put(java.lang.Object[] key,
java.lang.Object value)
Associates the specified value with the specified key in this map. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Associates the specified value with the specified key in this map. |
java.lang.Object |
remove(java.lang.Object key)
Removes the mapping for this key from this map if it is present. |
java.lang.Object |
remove(java.lang.Object[] key)
Removes the mapping for this key from this map if it is present. |
java.util.Collection |
removeAll(java.lang.Object key)
Removes the mapping for this key from this map if it is present. |
java.util.Collection |
removeAll(java.lang.Object[] key)
Removes the mapping for this key from this map if it is present. |
java.lang.String |
setPathSeparator(java.lang.String pathSeparator)
Defines the characters to be considered as path separator inside key. |
void |
share(HierarchicalMap map)
Share the same content of HierarchicalMap passed as parameter. |
int |
size()
Returns the number of key-value mappings in this map. |
java.lang.String |
toString()
This is same as toXMLString(maximumDepth) . |
java.lang.StringBuffer |
toXMLString(int depth)
Converts the content of this map into XML like String. |
java.util.Collection |
values()
Returns a collection view of the values contained in this map. |
Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int INSERTION_ORDER
public static final int ACCESS_ORDER
public static final int REVERSE_ACCESS_ORDER
public static int maximumDepth
toString()
method call. It prevents infinite loop while converting the content
into String when HierarchicalMap contains a recursive reference.
This is set to 10 by default. Use toXMLString(int depth)
instead to override the default depth.
public LinkedHashMultiMap children
Constructor Detail |
public BasicHierarchicalMap()
public BasicHierarchicalMap(int intialSize)
intialSize
- initial sizepublic BasicHierarchicalMap(int intialSize, float loadFactor)
intialSize
- initial size. Default is 11loadFactor
- the load factor (> 0, not NaN) that triggers rehashing. Default is 0.75public BasicHierarchicalMap(int intialSize, float loadFactor, int accessFormat)
intialSize
- initial size. Default is 11loadFactor
- the load factor (> 0, not NaN) that triggers rehashing. Default is 0.75accessFormat
- ACCESS_ORDER, INSERTION_ORDER or REVERSE_ACCESS_ORDER
java.lang.IllegalArgumentException
- if (initialCapacity < 0) ||
! (loadFactor > 0.0)Method Detail |
public java.lang.Object get(java.lang.Object key)
HierarchicalMap
get("Order/Address/Province")
:
Order Address State = "California" Country = "USA" Address Province = "Hiroshima" Country = "Japan"The result is the same as: get("Order").get("Address").get("Province")
get
in interface HierarchicalMap
key
- key whose associated value is to be returned.
public java.lang.Object get(java.lang.Object[] key)
HierarchicalMap2
get
in interface HierarchicalMap2
key
- key array whose associated value is to be returned.
HierarchicalMap.get(Object key)
public java.lang.Object get()
HierarchicalMap
get
in interface HierarchicalMap
public java.util.Collection getAll(java.lang.Object key)
HierarchicalMap
getAll
in interface HierarchicalMap
key
- key which associated value is to be returned.
public java.util.Collection getAll(java.lang.Object[] key)
HierarchicalMap2
getAll
in interface HierarchicalMap2
key
- key array whose associated value is to be returned.
HierarchicalMap.getAll(Object key)
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
HierarchicalMap
put
in interface HierarchicalMap
key
- key which the specified value is to be associated.value
- value to be associated with the specified key.
public java.lang.Object put(java.lang.Object[] key, java.lang.Object value)
HierarchicalMap2
put
in interface HierarchicalMap2
key
- key array which the specified value is to be associated.value
- value to be associated with the specified key.
HierarchicalMap.put(Object key, Object value)
public java.lang.Object add(java.lang.Object key, java.lang.Object value)
HierarchicalMap
add
in interface HierarchicalMap
key
- key which the specified value is to be associated.value
- value to be associated with the specified key.
public java.lang.Object add(java.lang.Object[] key, java.lang.Object value)
HierarchicalMap2
add
in interface HierarchicalMap2
key
- key array which the specified value is to be associated.value
- value to be associated with the specified key.
HierarchicalMap.add(Object key, Object value)
public HierarchicalMap add(java.lang.Object key)
HierarchicalMap
add
in interface HierarchicalMap
key
- key which a new HierarchicalMap is to be associated.
public HierarchicalMap add(java.lang.Object[] key)
HierarchicalMap2
add
in interface HierarchicalMap2
key
- key array which a new HierarchicalMap is to be associated.
HierarchicalMap.add(Object key)
public java.lang.Object addAll(java.lang.Object key, java.util.Collection values)
HierarchicalMap
addAll
in interface HierarchicalMap
key
- key which the specified values is to be associated.values
- a collection containing the values to be associated with the specified key.
public java.lang.Object addAll(java.lang.Object[] key, java.util.Collection values)
HierarchicalMap2
addAll
in interface HierarchicalMap2
key
- key array which the specified values is to be associated.values
- a collection containing the values to be associated with the specified key.
HierarchicalMap.addAll(Object key, Collection values)
public HierarchicalMap addAll(HierarchicalMap hmap)
HierarchicalMap
addAll
in interface HierarchicalMap
hmap
- a hierarchicalmap containing the entries to be added.
public java.util.Collection addAll(java.lang.Object key, HierarchicalMap hmap)
HierarchicalMap
addAll
in interface HierarchicalMap
key
- specifying the source and target.hmap
- a hierarchicalmap containing the entries to be added.
public java.util.Collection addAll(java.lang.Object[] key, HierarchicalMap hmap)
HierarchicalMap2
addAll
in interface HierarchicalMap2
key
- key array which the specified values is to be associated.hmap
- a HierarchicalMap containing the values to be associated with the specified key.
HierarchicalMap.addAll(Object key, HierarchicalMap hmap)
public java.lang.Object remove(java.lang.Object key)
HierarchicalMap
remove
in interface HierarchicalMap
key
- key which mapping is to be removed from the map.
public java.lang.Object remove(java.lang.Object[] key)
HierarchicalMap2
remove
in interface HierarchicalMap2
key
- key array which mapping is to be removed from the map.
HierarchicalMap.remove(Object key)
public java.util.Collection removeAll(java.lang.Object key)
HierarchicalMap
removeAll
in interface HierarchicalMap
key
- key which mapping is to be removed from the map.
public java.util.Collection removeAll(java.lang.Object[] key)
HierarchicalMap2
removeAll
in interface HierarchicalMap2
key
- key array which mapping is to be removed from the map.
HierarchicalMap.removeAll(Object key)
public java.util.Collection values()
HierarchicalMap
values
in interface HierarchicalMap
public java.util.Set keySet()
HierarchicalMap
keySet
in interface HierarchicalMap
public java.util.Set entrySet()
HierarchicalMap
entrySet
in interface HierarchicalMap
public int size()
HierarchicalMap
size
in interface HierarchicalMap
public java.lang.StringBuffer toXMLString(int depth)
<key>
and </key>
. This method does not check for the
occurrence of recursive reference. An error message
"<Error>Too many recursion. String truncated...</Error>"
will be placed when maximum depth is reached during the String
conversion.
depth
- maximum number of iteration allowed during String
convention.
public java.lang.String toString()
toXMLString(maximumDepth)
.
public java.lang.Object clone()
HierarchicalMap
clone
in interface HierarchicalMap
public boolean equals(java.lang.Object o)
public void share(HierarchicalMap map) throws java.lang.IllegalArgumentException
map
- the map in which the content will be shared.
java.lang.IllegalArgumentException
- is thrown when passed Map is not a instance of BasicHierarchicalMap.public HierarchicalMap newInstance()
HierarchicalMap
newInstance
in interface HierarchicalMap
public java.lang.String getPathSeparator()
HierarchicalMap
getPathSeparator
in interface HierarchicalMap
public java.lang.String setPathSeparator(java.lang.String pathSeparator)
HierarchicalMap
setPathSeparator
in interface HierarchicalMap
pathSeparator
- new path separators.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |