org.apache.openjpa.jdbc.schema
Class LocalConstraint

java.lang.Object
  extended by org.apache.openjpa.jdbc.schema.Constraint
      extended by org.apache.openjpa.jdbc.schema.LocalConstraint
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Index, PrimaryKey, Unique

public abstract class LocalConstraint
extends Constraint

Constraint over local table columns, as opposed to a foreign key which spans tables. Column APIs can represent a full constraint or a partial constraint, aligning with DatabaseMetaData.

Author:
Abe White
See Also:
Serialized Form

Constructor Summary
LocalConstraint()
          Default constructor.
LocalConstraint(String name, Table table)
          Constructor.
 
Method Summary
 void addColumn(Column col)
          Add a column to the constraint.
 boolean columnsMatch(Column[] ocols)
          Return true if the given columns match the columns of this constraint.
 boolean containsColumn(Column col)
          Return true if the pk includes the given column.
 void deref()
           
 void derefColumns()
          Deref all columns in this constraint.
protected  boolean equalsLocalConstraint(LocalConstraint lc)
          Return true if the columns of this constraint matches that of the given one.
 Column[] getColumns()
          Return all the columns the constraint spans.
 int getRefCount()
           
 void ref()
           
 void refColumns()
          Ref all columns in this constraint.
 boolean removeColumn(Column col)
          Remove a column from the constraint.
 void setColumns(Column[] cols)
          Set the columns the constraint spans.
 
Methods inherited from class org.apache.openjpa.jdbc.schema.Constraint
getColumnName, getFullName, getName, getSchemaName, getTable, getTableName, isDeferred, isLogical, setColumnName, setDeferred, setName, setSchemaName, setTableName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocalConstraint

public LocalConstraint()
Default constructor.


LocalConstraint

public LocalConstraint(String name,
                       Table table)
Constructor.

Parameters:
name - the name of the constraint, if any
table - the table of the constraint
Method Detail

getColumns

public Column[] getColumns()
Return all the columns the constraint spans.


setColumns

public void setColumns(Column[] cols)
Set the columns the constraint spans.


addColumn

public void addColumn(Column col)
Add a column to the constraint.


removeColumn

public boolean removeColumn(Column col)
Remove a column from the constraint.

Returns:
true if the column was removed, false if not part of the primary key

containsColumn

public boolean containsColumn(Column col)
Return true if the pk includes the given column.


refColumns

public void refColumns()
Ref all columns in this constraint.


derefColumns

public void derefColumns()
Deref all columns in this constraint.


columnsMatch

public boolean columnsMatch(Column[] ocols)
Return true if the given columns match the columns of this constraint.


equalsLocalConstraint

protected boolean equalsLocalConstraint(LocalConstraint lc)
Return true if the columns of this constraint matches that of the given one. The constraints are not compared on name.


getRefCount

public int getRefCount()

ref

public void ref()

deref

public void deref()


Copyright © 2006-2010 Apache Software Foundation. All Rights Reserved.