com.sun.data.provider
Class RowKey

java.lang.Object
  extended bycom.sun.data.provider.RowKey
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable
Direct Known Subclasses:
IndexRowKey, ObjectArrayRowKey, ObjectRowKey

public class RowKey
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable

RowKey is a representation of an identifier for a specific data row that may be retrieved from a TableDataProvider. Specialized implementations might also provide extra capabilities for navigation between rows, or other value added services.

A RowKey (and rowId) is expected to remain valid for as long as possible - meaning when a RowKey is fetched from a TableDataProvider, it is considered an address of a particular row in that TableDataProvider. If rows have been added or removed from the TableDataProvider, a previously fetched RowKey should still represent the row it did when it was first retrieved. A common strategy for TableDataProvider implementations is to store intrinsicly "primary key-like" data from the underlying data source inside of a specialized RowKey implementation. Another strategy is to store a random hash index in the RowKeys, and maintain a map inside the TableDataProvider implementation to resolve the RowKeys back to the underlying data rows. This insolates consumers of the TableDataProvider implementation from row index changes (due to inserts, deletes, etc) in the underlying data source.

At any point a user might call TableDataProvider.getRowKey(String) in order to fetch a valid RowKey for a particular rowId, so the TableDataProvider must be capable of resolving a rowId back to a unique RowKey.

RowKey implements Comparable so that batched deletes and inserts can be done in reverse order to help ensure consistency of row order. This is only for blind operations implemented where there is no knowledge of a specific RowKey or TableDataProvider implementations. A RowKey implementation might not support intrinsic ordering of any type.

Author:
Joe Nuxoll
See Also:
Serialized Form

Field Summary
static RowKey[] EMPTY_ARRAY
          A convenient static empty array to use for no-op method returns
 
Constructor Summary
RowKey()
          Constructs an uninitialized RowKey.
RowKey(java.lang.String rowId)
          Constructs a new RowKey with the specified cannonical ID.
 
Method Summary
 int compareTo(java.lang.Object o)
          Standard implementation of compareTo(Object).
 boolean equals(java.lang.Object o)
          Standard equals implementation.
 java.lang.String getRowId()
           
 void setRowId(java.lang.String rowId)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_ARRAY

public static final RowKey[] EMPTY_ARRAY
A convenient static empty array to use for no-op method returns

Constructor Detail

RowKey

public RowKey()
Constructs an uninitialized RowKey.


RowKey

public RowKey(java.lang.String rowId)
Constructs a new RowKey with the specified cannonical ID.

Parameters:
rowId - The desired cannonical ID String
Method Detail

setRowId

public void setRowId(java.lang.String rowId)
Parameters:
rowId - the canonical internal identifier of this RowKey

getRowId

public java.lang.String getRowId()
Returns:
the canonical internal identifier of this RowKey

equals

public boolean equals(java.lang.Object o)
Standard equals implementation. This method compares the RowKey id values for equality.

Parameters:
o - the Object to check equality
Returns:
true if equal, false if not
See Also:
Object.equals(Object)

compareTo

public int compareTo(java.lang.Object o)

Standard implementation of compareTo(Object). This checks for equality first (using equals(Object)), then compares the rowId strings. This should be overridden by RowKey implementations that have a notion of order. This allows for deletions and insertions to be done in reverse order to help ensure the longevity of valid RowKeys.

Specified by:
compareTo in interface java.lang.Comparable

toString

public java.lang.String toString()