org.datanucleus.store.rdbms.key
Class PrimaryKey

java.lang.Object
  extended by org.datanucleus.store.rdbms.key.CandidateKey
      extended by org.datanucleus.store.rdbms.key.PrimaryKey

public class PrimaryKey
extends CandidateKey

Representation of the primary key of a table.


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
PrimaryKey(org.datanucleus.store.mapped.DatastoreContainerObject table)
          Creates a primary key.
 
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.
protected static void setMinSize(java.util.List list, int size)
           
 void setName(java.lang.String name)
          Mutator for the key name.
 boolean startsWith(org.datanucleus.store.rdbms.key.Key key)
          Check if this starts with the same columns specified in key.
 java.lang.String toString()
          Stringifier method.
 
Methods inherited from class org.datanucleus.store.rdbms.key.CandidateKey
setDatastoreField, size
 
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

PrimaryKey

public PrimaryKey(org.datanucleus.store.mapped.DatastoreContainerObject table)
Creates a primary key. A default name of the primary key is created by the constructor. This name can be overwritten.

Parameters:
table - Table that this is the PK for
Method Detail

equals

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

Overrides:
equals in class CandidateKey
Parameters:
obj - The object to compare against
Returns:
Whether they are equal

toString

public java.lang.String toString()
Stringifier method. Generates a form of the PK ready to be used in a DDL statement. e.g PRIMARY KEY (col1,col2)

Overrides:
toString in class CandidateKey
Returns:
The string form of this object. Ready to be used in a DDL statement.

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.