|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | 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 key
public MultiKey(Object key1,
Object key2,
Object key3)
key1 - the first keykey2 - the second keykey3 - the third key
public MultiKey(Object key1,
Object key2,
Object key3,
Object key4)
key1 - the first keykey2 - the second keykey3 - the third keykey4 - the fourth key
public 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 keys
IllegalArgumentException - if the key array is null
protected 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 it
IllegalArgumentException - if the key array is null| Method 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 Objectother - the other object to compare to
public 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 Objectpublic String toString()
toString in class Object
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||