org.datanucleus.store.rdbms.key
Class CandidateKey

java.lang.Object
  extended by org.datanucleus.store.rdbms.key.CandidateKey
Direct Known Subclasses:
PrimaryKey

public class CandidateKey
extends java.lang.Object

Representation of a Candidate key. This represents a UNIQUE key on a column or columns.


Field Summary
protected  java.util.List<org.datanucleus.store.mapped.DatastoreField> columns
          Columns that the key relates to.
protected  java.lang.String name
          Name of the key.
protected  org.datanucleus.store.mapped.DatastoreContainerObject table
          Table that the key applies to.
 
Constructor Summary
CandidateKey(org.datanucleus.store.mapped.DatastoreContainerObject table)
          Constructor.
 
Method Summary
 void addDatastoreField(org.datanucleus.store.mapped.DatastoreField col)
          Class to add a column to the key
protected  void assertSameDatastoreObject(org.datanucleus.store.mapped.DatastoreField col)
          Utility to assert if the column is for a different table.
 boolean equals(java.lang.Object obj)
          Equality operator.
 java.lang.String getColumnList()
          Accessor for the column list
static java.lang.String getColumnList(java.util.Collection cols)
          Method to return the list of columns which the key applies to.
 java.util.List getColumns()
          Accessor for the columns that the key relates to.
 org.datanucleus.store.mapped.DatastoreContainerObject getDatastoreContainerObject()
          Accessor for the table
 java.lang.String getName()
          Accessor for the key name.
 int hashCode()
          Hashcode operator.
 void setDatastoreField(int seq, org.datanucleus.store.mapped.DatastoreField col)
          Mutator for the column spec, to add/change a column.
protected static void setMinSize(java.util.List list, int size)
           
 void setName(java.lang.String name)
          Mutator for the key name.
 int size()
          Accessor for the size.
 boolean startsWith(org.datanucleus.store.rdbms.key.Key key)
          Check if this starts with the same columns specified in key.
 java.lang.String toString()
          Stringify method.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
Name of the key.


table

protected org.datanucleus.store.mapped.DatastoreContainerObject table
Table that the key applies to.


columns

protected java.util.List<org.datanucleus.store.mapped.DatastoreField> columns
Columns that the key relates to.

Constructor Detail

CandidateKey

public CandidateKey(org.datanucleus.store.mapped.DatastoreContainerObject table)
Constructor.

Parameters:
table - Table to apply this key to
Method Detail

setDatastoreField

public void setDatastoreField(int seq,
                              org.datanucleus.store.mapped.DatastoreField col)
Mutator for the column spec, to add/change a column.

Parameters:
seq - Sequence number of the column
col - The column

size

public int size()
Accessor for the size.

Returns:
The size.

equals

public boolean equals(java.lang.Object obj)
Equality operator.

Parameters:
obj - The object to compare against
Returns:
Whether the objects are equal

toString

public java.lang.String toString()
Stringify method.

Overrides:
toString in class java.lang.Object
Returns:
String version of this object.

getName

public java.lang.String getName()
Accessor for the key name.

Returns:
Key name

getDatastoreContainerObject

public org.datanucleus.store.mapped.DatastoreContainerObject getDatastoreContainerObject()
Accessor for the table

Returns:
table

getColumns

public java.util.List getColumns()
Accessor for the columns that the key relates to.

Returns:
the List of columns.

getColumnList

public java.lang.String getColumnList()
Accessor for the column list

Returns:
The column list

addDatastoreField

public void addDatastoreField(org.datanucleus.store.mapped.DatastoreField col)
Class to add a column to the key

Parameters:
col - The column to add

startsWith

public boolean startsWith(org.datanucleus.store.rdbms.key.Key key)
Check if this starts with the same columns specified in key.

Parameters:
key - the Key (may be multiple number of columns)
Returns:
true if this columns starts with columns specified in key

setName

public void setName(java.lang.String name)
Mutator for the key name.

Parameters:
name - The key name

assertSameDatastoreObject

protected void assertSameDatastoreObject(org.datanucleus.store.mapped.DatastoreField col)
Utility to assert if the column is for a different table.

Parameters:
col - The column to compare with

hashCode

public int hashCode()
Hashcode operator.

Overrides:
hashCode in class java.lang.Object
Returns:
The hashcode

setMinSize

protected static void setMinSize(java.util.List list,
                                 int size)

getColumnList

public static java.lang.String getColumnList(java.util.Collection cols)
Method to return the list of columns which the key applies to.

Parameters:
cols - The columns.
Returns:
The column list.


Copyright © 2009. All Rights Reserved.