org.apache.tapestry.util
Class MultiKey

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

public class MultiKey
extends java.lang.Object
implements java.io.Externalizable

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

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(java.lang.Object[] keys, boolean makeCopy)
          Builds a MultiKey from an array of keys.
 
Method Summary
 boolean equals(java.lang.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(java.io.ObjectInput in)
          Reads the state previously written by writeExternal(ObjectOutput).
 java.lang.String toString()
          Identifies all the keys stored by this MultiKey.
 void writeExternal(java.io.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(java.lang.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:
java.lang.IllegalArgumentException - if keys is null, of if the first element of keys is null.
Method Detail

equals

public boolean equals(java.lang.Object other)
Returns true if:

Overrides:
equals in class java.lang.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 java.lang.Object

toString

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

Overrides:
toString in class java.lang.Object

writeExternal

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

Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

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

Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException