org.apache.tapestry.util
Class MultiKey

java.lang.Object
  extended by org.apache.tapestry.util.MultiKey
All Implemented Interfaces:
Externalizable, Serializable

public class MultiKey
extends Object
implements Externalizable

A complex key that may be used as an alternative to nested Maps.

Version:
$Id: MultiKey.java 243791 2004-02-19 17:38:13Z hlship $
Author:
Howard Lewis Ship
See Also:
Serialized Form

Constructor Summary
MultiKey()
          Public no-arguments constructor needed to be compatible with Externalizable; this leaves the new MultiKey in a non-usable state and shouldn't be used by user code.
MultiKey(Object[] keys, boolean makeCopy)
          Builds a MultiKey from an array of keys.
 
Method Summary
 boolean equals(Object other)
          Returns true if: The other object is a MultiKey They have the same number of key elements Every element is an exact match or is equal
 int hashCode()
          Returns the hash code of the receiver, which is computed from all the non-null key elements.
 void readExternal(ObjectInput in)
          Reads the state previously written by writeExternal(ObjectOutput).
 String toString()
          Identifies all the keys stored by this MultiKey.
 void writeExternal(ObjectOutput out)
          Writes a count of the keys, then writes each individual key.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MultiKey

public MultiKey()
Public no-arguments constructor needed to be compatible with Externalizable; this leaves the new MultiKey in a non-usable state and shouldn't be used by user code.


MultiKey

public MultiKey(Object[] keys,
                boolean makeCopy)
Builds a MultiKey from an array of keys. If the array is not copied, then it must not be modified.

Parameters:
keys - The components of the key.
makeCopy - If true, a copy of the keys is created. If false, the keys are simple retained by the MultiKey.
Throws:
IllegalArgumentException - if keys is null, of if the first element of keys is null.
Method Detail

equals

public boolean equals(Object other)
Returns true if:

Overrides:
equals in class Object

hashCode

public int hashCode()
Returns the hash code of the receiver, which is computed from all the non-null key elements. 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 key elements were themselves Map keys.

Overrides:
hashCode in class Object

toString

public String toString()
Identifies all the keys stored by this MultiKey.

Overrides:
toString in class Object

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Writes a count of the keys, then writes each individual key.

Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Reads the state previously written by writeExternal(ObjectOutput).

Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException