|
||||||||||
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<K>
public class MultiKey<K>
A MultiKey
allows multiple map keys to be merged together.
// populate map with data mapping key+locale to localizedText Map map = new HashMap(); MultiKey multiKey = new MultiKey(key, locale); map.put(multiKey, localizedText); // later retireve the localized text MultiKey multiKey = new MultiKey(key, locale); String localizedText = (String) map.get(multiKey);
Constructor Summary | |
---|---|
MultiKey(K... keys)
Constructor taking two keys. |
|
MultiKey(K[] keys,
boolean makeClone)
Constructor taking an array of keys, optionally choosing whether to clone. |
Method Summary | |
---|---|
boolean |
equals(Object other)
Compares this object to another. |
K |
getKey(int index)
Gets the key at the specified index. |
K[] |
getKeys()
Gets a clone of the array of keys. |
int |
hashCode()
Gets the combined hash code that is computed from all the keys. |
int |
size()
Gets the size of the list of 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(K... keys)
keys
- the keyspublic MultiKey(K[] keys, boolean makeClone)
new MultiKey(new Object[] {...}, false);The keys should be immutable If they are not then they must not be changed after adding to the MultiKey.
keys
- the array of keys, not nullmakeClone
- true to clone the array, false to assign it
IllegalArgumentException
- if the key array is nullMethod Detail |
---|
public K[] getKeys()
public K getKey(int index)
index
- the index to retrieve
IndexOutOfBoundsException
- if the index is invalidpublic int size()
public boolean equals(Object other)
MultiKey
with the
same number of keys which are also equal.
equals
in class Object
other
- the other object to compare to
public int hashCode()
Map
keys.
hashCode
in class Object
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |