|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.collections.keyvalue.MultiKey
A MultiKey
allows multiple map keys to be merged together.
The purpose of this class is to avoid the need to write code to handle maps of maps. An example might be the need to lookup a filename by key and locale. The typical solution might be nested maps. This class can be used instead by creating an instance passing in the key and locale.
Constructor Summary | |
|
MultiKey(Object[] keys)
Constructor taking an array of keys. |
protected |
MultiKey(Object[] keys,
boolean makeCopy)
Constructor taking an array of keys. |
|
MultiKey(Object key1,
Object key2)
Constructor taking two keys. |
|
MultiKey(Object key1,
Object key2,
Object key3)
Constructor taking three keys. |
|
MultiKey(Object key1,
Object key2,
Object key3,
Object key4)
Constructor taking four keys. |
|
MultiKey(Object key1,
Object key2,
Object key3,
Object key4,
Object key5)
Constructor taking five keys. |
Method Summary | |
boolean |
equals(Object other)
Compares this object to another. |
Object[] |
getKeys()
Gets a copy of the individual keys. |
int |
hashCode()
Gets the combined hash code that is computed from all the keys. |
String |
toString()
Gets a debugging string version of the key. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public MultiKey(Object key1, Object key2)
key1
- the first keykey2
- the second keypublic MultiKey(Object key1, Object key2, Object key3)
key1
- the first keykey2
- the second keykey3
- the third keypublic MultiKey(Object key1, Object key2, Object key3, Object key4)
key1
- the first keykey2
- the second keykey3
- the third keykey4
- the fourth keypublic MultiKey(Object key1, Object key2, Object key3, Object key4, Object key5)
key1
- the first keykey2
- the second keykey3
- the third keykey4
- the fourth keykey5
- the fifth keypublic MultiKey(Object[] keys)
keys
- the array of keysIllegalArgumentException
- if the key array is nullprotected MultiKey(Object[] keys, boolean makeCopy)
If the array is not copied, then it must not be modified.
keys
- the array of keysmakeCopy
- true to copy the array, false to assign itIllegalArgumentException
- if the key array is nullMethod Detail |
public Object[] getKeys()
public boolean equals(Object other)
To be equal, the other object must be a MultiKey
with the
same number of keys which are also equal.
equals
in class Object
other
- the other object to compare topublic int hashCode()
This value is computed once and then cached, so elements should not
change their hash codes once created (note that this is the same
constraint that would be used if the individual keys elements were
themselves Map
keys.
hashCode
in class Object
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |