Class ComboKey

java.lang.Object
org.apache.torque.om.ObjectKey<SimpleKey<?>[]>
org.apache.torque.om.ComboKey
All Implemented Interfaces:
Serializable, Comparable<Object>

public class ComboKey extends ObjectKey<SimpleKey<?>[]>
This class can be used as an ObjectKey to uniquely identify an object within an application where the key consists of multiple entities (such a String[] representing a multi-column primary key).
Version:
$Id: ComboKey.java 1917245 2024-04-21 14:06:23Z tv $
Author:
John McNally, Daniel Rall, J. Russell Smyth
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final char
    The single character used to separate key values in a string.
    static final String
    The single character used to separate key values in a string.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Initializes the internal key value to null.
    Creates an ComboKey and set its internal representation
    Creates a ComboKey that is equivalent to key.
    ComboKey(SimpleKey<?>[] key)
    Creates an ComboKey and set its internal representation
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Appends a String representation of the key to a buffer.
    boolean
    equals(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.
    int
    Returns the JDBC type of the key as defined in java.sql.Types.
    int
    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
    keyObj is equal to this ComboKey if keyObj is a ComboKey, String, ObjectKey[], or String[] that contains the same information this key contains.
    void
    Sets the internal representation using a String of the form produced by the toString method.
    A String that may consist of one section or multiple sections separated by a colon.

    Methods inherited from class org.apache.torque.om.ObjectKey

    compareTo, getValue, setValue, setValue

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • SEPARATOR

      public static final char SEPARATOR
      The single character used to separate key values in a string.
      See Also:
    • SEPARATOR_STRING

      public static final String SEPARATOR_STRING
      The single character used to separate key values in a string.
      See Also:
  • Constructor Details

    • ComboKey

      public ComboKey()
      Initializes the internal key value to null.
    • ComboKey

      public ComboKey(String key)
      Creates an ComboKey and set its internal representation
      Parameters:
      key - the key value as String
    • ComboKey

      public ComboKey(SimpleKey<?>[] key)
      Creates an ComboKey and set its internal representation
      Parameters:
      key - the key value
    • ComboKey

      public ComboKey(ComboKey key)
      Creates a ComboKey that is equivalent to key.
      Parameters:
      key - the key value
  • Method Details

    • setValue

      public void setValue(String keys)
      Sets the internal representation using a String of the form produced by the toString method.
      Parameters:
      keys - the key values
    • getJdbcType

      public int getJdbcType()
      Returns the JDBC type of the key as defined in java.sql.Types.
      Specified by:
      getJdbcType in class ObjectKey<SimpleKey<?>[]>
      Returns:
      Types.ARRAY.
    • equals

      public boolean equals(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 ObjectKey<SimpleKey<?>[]>
      Parameters:
      keyObj - the comparison value
      Returns:
      whether the two objects are equal
    • looseEquals

      public boolean looseEquals(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.
      Parameters:
      keyObj - the comparison value
      Returns:
      whether the two objects are equal
    • appendTo

      public void appendTo(StringBuilder sb)
      Description copied from class: ObjectKey
      Appends a String representation of the key to a buffer.
      Overrides:
      appendTo in class ObjectKey<SimpleKey<?>[]>
      Parameters:
      sb - the StringBuilder to append
      See Also:
    • 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<SimpleKey<?>[]>
      Returns:
      an int value
    • toString

      public String toString()
      A String that may consist of one section or multiple sections separated by a colon.

      Each Key is represented by [type N|S|D][value][:].

      Example:

      the ComboKey(StringKey("key1"), NumberKey(2)) is represented as Skey1:N2:

      Overrides:
      toString in class ObjectKey<SimpleKey<?>[]>
      Returns:
      a String representation