JIDE 3.5.15

com.jidesoft.pivot
Class CompoundKey

java.lang.Object
  extended by com.jidesoft.pivot.CompoundKey
All Implemented Interfaces:
Serializable, Comparable<CompoundKey>

public class CompoundKey
extends Object
implements Comparable<CompoundKey>, Serializable

CompoundKey is a class that takes several objects and make them into one value so that it can be used as the key for a Map.

See Also:
Serialized Form

Constructor Summary
protected CompoundKey(Object[] keys)
          Creates a CompoundKey.
 
Method Summary
static void clearCache()
           
 int compareTo(CompoundKey o)
          Compare two CompoundKeys.
 int compareTo(CompoundKey thatKey, IPivotDataModel pivotDataModel, PivotField[] fields, int[] orders)
          Compare two CompoundKeys with the specified sort orders for each key.
 boolean equals(Object o)
          Indicates whether this key contains the same key values as another CompoundKey.
 CompoundKey getCompoundKeyPrefix()
          Gets the immediate prefix.
 CompoundKey getCompoundKeyPrefix(int prefixLength)
          Gets the prefix of the specified length.
 CompoundKey[] getCompoundKeyPrefixes()
          Gets several CompoundKeys that are partial of this CompoundKey.
 int getKeyCount()
          Gets the number of keys.
 Object[] getKeys()
          Gets the keys used in this CompoundKey.
 Object getLastKey()
          Gets the last key from this compound key.
 int hashCode()
          Gets the hash code for this compound key.
 int hashCode(int i)
           
static CompoundKey newInstance(Object[] keys)
          Reuse the same instance of compound key.
 boolean startsWith(CompoundKey key)
          Checks if the first number of keys in this CompoundKey are the same as the keys in the specified key.
 String toString()
           
 Values toValues()
           
 Values toValues(int count, int summaryType)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CompoundKey

protected CompoundKey(Object[] keys)
Creates a CompoundKey.

Parameters:
keys - An array of keys.
Method Detail

newInstance

public static CompoundKey newInstance(Object[] keys)
Reuse the same instance of compound key.

Parameters:
keys - the keys
Returns:
the same instance of compound key that was created before.

hashCode

public int hashCode()
Gets the hash code for this compound key.

Overrides:
hashCode in class Object

compareTo

public int compareTo(CompoundKey o)
Compare two CompoundKeys.

Specified by:
compareTo in interface Comparable<CompoundKey>
Parameters:
o - The Object to check for equality.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

compareTo

public int compareTo(CompoundKey thatKey,
                     IPivotDataModel pivotDataModel,
                     PivotField[] fields,
                     int[] orders)
Compare two CompoundKeys with the specified sort orders for each key.

Parameters:
thatKey - the key to be compared
pivotDataModel - the pivot data model
fields - the pivot fields
orders - the order of each field
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

equals

public boolean equals(Object o)
Indicates whether this key contains the same key values as another CompoundKey.

Overrides:
equals in class Object
Parameters:
o - The other object to compare to this
Returns:
true if, and only if, the other object o is a CompoundKey and o contains exactly the same number of key values as this key, and the key values in o are equal to, and in the same order as, the key values in this key.

getKeys

public Object[] getKeys()
Gets the keys used in this CompoundKey.

Returns:
the keys used in this CompoundKey.

toString

public String toString()
Overrides:
toString in class Object

getKeyCount

public int getKeyCount()
Gets the number of keys.

Returns:
the number of keys.

startsWith

public boolean startsWith(CompoundKey key)
Checks if the first number of keys in this CompoundKey are the same as the keys in the specified key.

Parameters:
key - key to compare with
Returns:
true if the first number of keys in this CompoundKey are the same as the keys in the specified key.

hashCode

public int hashCode(int i)

getCompoundKeyPrefixes

public CompoundKey[] getCompoundKeyPrefixes()
Gets several CompoundKeys that are partial of this CompoundKey. For example, if a CompoundKey has {a,b,c}, this method will return {a}, {a,b}, and the CompoundKey itself {a,b,c}, as an array. All CompoundKeys in the return array will make startsWith(CompoundKey) true.

Returns:
the prefixes of the CompoundKey.

getLastKey

public Object getLastKey()
Gets the last key from this compound key.

Returns:
the last key from this compound key.

getCompoundKeyPrefix

public CompoundKey getCompoundKeyPrefix()
Gets the immediate prefix. For example, if the CompoundKey has three keys, the immediate prefix will have the first two keys. If there are no keys, it will return an empty CompoundKey.

Returns:
the immediate prefix.
See Also:
getCompoundKeyPrefixes()

getCompoundKeyPrefix

public CompoundKey getCompoundKeyPrefix(int prefixLength)
Gets the prefix of the specified length. The length should be between 0 and the CompoundKey length.

Parameters:
prefixLength - the prefix length.
Returns:
the prefix having the specified length.
See Also:
getCompoundKeyPrefixes()

clearCache

public static void clearCache()

toValues

public Values toValues()

toValues

public Values toValues(int count,
                       int summaryType)

JIDE 3.5.15