org.apache.turbine.om
Class ComboKey

java.lang.Object
  |
  +--org.apache.turbine.om.ObjectKey
        |
        +--org.apache.turbine.om.ComboKey
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable

public class ComboKey
extends ObjectKey

This class can be used as an ObjectKey to uniquely identify an object within an application where the id consists of multiple entities such a String[] representing a multi-column primary key.

See Also:
Serialized Form

Field Summary
private static java.lang.String errMsg
          Sets the internal representation using a String array.
(package private)  SimpleKey[] key
           
(package private)  java.lang.StringBuffer sbuf
           
static char SEPARATOR
          The single character used to separate key values in a string.
static java.lang.String SEPARATOR_STRING
          The single character used to separate key values in a string.
(package private)  java.util.ArrayList tmpKeys
           
 
Constructor Summary
ComboKey()
          Creates an ComboKey whose internal representation will be set later, through a set method
ComboKey(SimpleKey[] keys)
          Creates a ComboKey whose internal representation is an array of SimpleKeys.
ComboKey(java.lang.String keys)
          Sets the internal representation to a String array.
ComboKey(java.lang.String[] keys)
          Creates a compound ComboKey whose internal representation is a String array.
 
Method Summary
 void appendTo(java.lang.StringBuffer sb)
          Appends a String representation of the key to a buffer.
 boolean equals(java.lang.Object keyObj)
          This method will return true if the conditions for a looseEquals are met and in addition no parts of the keys are null.
 java.lang.Object getValue()
          Get the underlying object.
 int hashCode()
          if the underlying key array is not null and the first element is not null this method returns the hashcode of the first element in the key.
 boolean looseEquals(java.lang.Object keyObj)
          keyObj is equal to this ComboKey if keyObj is a ComboKey, String, ObjectKey[], or String[] that contains the same information this key contains.
 void setValue(ComboKey keys)
           
 void setValue(SimpleKey[] keys)
          Sets the internal representation using an array of SimpleKeys.
 void setValue(java.lang.String keys)
          Sets the internal representation using a String of the form produced by the toString method.
 void setValue(java.lang.String[] keys)
           
 java.lang.String toString()
          A String that may consist of one section or multiple sections separated by a colon.
 
Methods inherited from class org.apache.turbine.om.ObjectKey
compareTo
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

SEPARATOR

public static final char SEPARATOR
The single character used to separate key values in a string.

SEPARATOR_STRING

public static final java.lang.String SEPARATOR_STRING
The single character used to separate key values in a string.

tmpKeys

java.util.ArrayList tmpKeys

sbuf

java.lang.StringBuffer sbuf

key

SimpleKey[] key

errMsg

private static java.lang.String errMsg
Sets the internal representation using a String array.
Constructor Detail

ComboKey

public ComboKey()
Creates an ComboKey whose internal representation will be set later, through a set method

ComboKey

public ComboKey(SimpleKey[] keys)
Creates a ComboKey whose internal representation is an array of SimpleKeys.

ComboKey

public ComboKey(java.lang.String[] keys)
         throws TurbineException
Creates a compound ComboKey whose internal representation is a String array.

ComboKey

public ComboKey(java.lang.String keys)
         throws TurbineException
Sets the internal representation to a String array.
Method Detail

setValue

public void setValue(SimpleKey[] keys)
Sets the internal representation using an array of SimpleKeys.

setValue

public void setValue(java.lang.String[] keys)
              throws TurbineException

setValue

public void setValue(java.lang.String keys)
              throws TurbineException
Sets the internal representation using a String of the form produced by the toString method.
Overrides:
setValue in class ObjectKey
Following copied from class: org.apache.turbine.om.ObjectKey
Parameters:
s - a String value
Throws:
TurbineException - if an error occurs

setValue

public void setValue(ComboKey keys)

getValue

public java.lang.Object getValue()
Get the underlying object.
Overrides:
getValue in class ObjectKey

equals

public boolean equals(java.lang.Object keyObj)
This method will return true if the conditions for a looseEquals are met and in addition no parts of the keys are null.
Overrides:
equals in class java.lang.Object

looseEquals

public boolean looseEquals(java.lang.Object keyObj)
keyObj is equal to this ComboKey if keyObj is a ComboKey, String, ObjectKey[], or String[] that contains the same information this key contains. For example A String[] might be equal to this key, if this key was instantiated with a String[] and the arrays contain equal Strings. Another example, would be if keyObj is an ComboKey that was instantiated with a ObjectKey[] and this ComboKey was instantiated with a String[], but the ObjectKeys in the ObjectKey[] were instantiated with Strings that equal the Strings in this KeyObject's String[] This method is not as strict as the equals method which does not allow any null keys parts, while the internal key may not be null portions may be, and the two object will be considered equal if their null portions match.

appendTo

public void appendTo(java.lang.StringBuffer sb)
Description copied from class: ObjectKey
Appends a String representation of the key to a buffer.
Overrides:
appendTo in class ObjectKey
Following copied from class: org.apache.turbine.om.ObjectKey
Parameters:
sb - a StringBuffer

hashCode

public int hashCode()
if the underlying key array is not null and the first element is not null this method returns the hashcode of the first element in the key. Otherwise calls ObjectKey.hashCode()
Overrides:
hashCode in class ObjectKey
Returns:
an int value

toString

public java.lang.String toString()
A String that may consist of one section or multiple sections separated by a colon.
Overrides:
toString in class java.lang.Object


Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.