Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

javatools.db
Class DbDynamicConstraint  view DbDynamicConstraint download DbDynamicConstraint.java

java.lang.Object
  extended byjavatools.db.DbConstraint
      extended byjavatools.db.DbDynamicConstraint

public class DbDynamicConstraint
extends DbConstraint

It is a class representing a "dynamic" constraint, i.e. a constraint that changes references dynamically.

Version:
0.2.0

Field Summary
private  boolean automaticBuild
           
private  java.util.LinkedList deleteOperations
           
private  java.util.LinkedList fatherTables
           
private  java.util.LinkedList fatherTablesColumns
           
private  java.util.LinkedList refColumns
           
private  java.util.LinkedList sonIndexes
           
private  java.util.LinkedList sonTables
           
private  java.util.LinkedList updateOperations
           
 
Fields inherited from class javatools.db.DbConstraint
automaticChecking, canDoUpdate, CASCADE, cloned, constraintEmulation, constraints, currentOperation, defaultValues, DELETE_OPERATION, deleteCascadeChildren, DO_NOTHING, fatherColsChildren, fatherRecords, fromList, INSERT_OPERATION, intoList, refColsChildren, refs, searchSets, selector, SET_DEFAULT, SET_NULL, sonsWhere, table, UPDATE_CASCADE, UPDATE_OPERATION, updateCascadeChildren, updateFromLists, updateIntoLists, where
 
Constructor Summary
DbDynamicConstraint(DbAbstractTable tbl)
          Creates new DbDynamicConstraint
 
Method Summary
 void addFatherTable(DbAbstractTable fatherTable, DbColumn[] fatherColumns, DbColumn[] pRefColumns, int updateOperation, int deleteOperation)
          Adds a new father table.
 void addSonTable(DbAbstractTable sonTable, int fatherIndex)
          Adds a son table.
 void build()
          Builds all static lists.
private  void buildArrays()
           
 void check(int operation)
          Performs checking in the table, after setting all dynamic and "static" data.
protected  void checkFathers()
          Checks the fathers.
protected  void checkThis(int operation)
          Performs base checking.
private  void createReferences()
           
 java.lang.Object[] getDefaultValues(int index)
          Returns the default values of referenced father table whose index is specified.
 int getDeleteOperation(int index)
          Returns the delete operation that should be done for the father table whose index is specified.
 DbColumn[] getFatherColumns(int index)
          The referenced columns of father table whose index is specified.
 DbAbstractTable getFatherTable(int index)
          Returns a father table whose index is specified.
 int getFatherTablesCount()
          Returns the number of referenced father tables.
 DbColumn[] getRefColumns(int index)
          Returns the referencing columns of THIS table to the father table whose index is specified.
 int getSonFatherIndex(int index)
          Returns the index that a son table uses to reference this table.
 DbAbstractTable getSonTable(int index)
          Returns a son table whose index is specified.
 int getSonTablesCount()
          Returns the number of son tables.
 int getUpdateOperation(int index)
          Returns the update operation that should be done for the father table whose index is specified.
 void setAutomaticBuild(boolean value)
          Tells this object to build (or not) automatically all lists at all times.
 int update(int operation)
          Performs actual update in the table and, eventually, cascades.
 
Methods inherited from class javatools.db.DbConstraint
checkChildren, clear, clone, getAutomaticChecking, getConstraintEmulation, getTable, initLists, initStaticLists, setAutomaticChecking, setConstraintEmulation, setSelector, setValueLists, setWhere, updateThis
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fatherTables

private java.util.LinkedList fatherTables

sonTables

private java.util.LinkedList sonTables

updateOperations

private java.util.LinkedList updateOperations

deleteOperations

private java.util.LinkedList deleteOperations

fatherTablesColumns

private java.util.LinkedList fatherTablesColumns

refColumns

private java.util.LinkedList refColumns

sonIndexes

private java.util.LinkedList sonIndexes

automaticBuild

private boolean automaticBuild
Constructor Detail

DbDynamicConstraint

public DbDynamicConstraint(DbAbstractTable tbl)
Creates new DbDynamicConstraint

Method Detail

check

public void check(int operation)
           throws DbException
Performs checking in the table, after setting all dynamic and "static" data.

Specified by:
check in class DbConstraint

update

public int update(int operation)
           throws DbException
Performs actual update in the table and, eventually, cascades. If automatic checking is set, it also checks before updating.

Specified by:
update in class DbConstraint

addFatherTable

public void addFatherTable(DbAbstractTable fatherTable,
                           DbColumn[] fatherColumns,
                           DbColumn[] pRefColumns,
                           int updateOperation,
                           int deleteOperation)
Adds a new father table.


addSonTable

public void addSonTable(DbAbstractTable sonTable,
                        int fatherIndex)
Adds a son table.


getFatherTablesCount

public int getFatherTablesCount()
Returns the number of referenced father tables.

Overrides:
getFatherTablesCount in class DbConstraint

getSonTablesCount

public int getSonTablesCount()
Returns the number of son tables.

Overrides:
getSonTablesCount in class DbConstraint

getFatherTable

public DbAbstractTable getFatherTable(int index)
                               throws DbException
Returns a father table whose index is specified.

Overrides:
getFatherTable in class DbConstraint

getSonTable

public DbAbstractTable getSonTable(int index)
                            throws DbException
Returns a son table whose index is specified.

Overrides:
getSonTable in class DbConstraint

getSonFatherIndex

public int getSonFatherIndex(int index)
                      throws DbException
Returns the index that a son table uses to reference this table.

Overrides:
getSonFatherIndex in class DbConstraint

getUpdateOperation

public int getUpdateOperation(int index)
                       throws DbException
Returns the update operation that should be done for the father table whose index is specified.

Overrides:
getUpdateOperation in class DbConstraint

getDeleteOperation

public int getDeleteOperation(int index)
                       throws DbException
Returns the delete operation that should be done for the father table whose index is specified.

Overrides:
getDeleteOperation in class DbConstraint

getFatherColumns

public DbColumn[] getFatherColumns(int index)
                            throws DbException
The referenced columns of father table whose index is specified.

Overrides:
getFatherColumns in class DbConstraint

getRefColumns

public DbColumn[] getRefColumns(int index)
                         throws DbException
Returns the referencing columns of THIS table to the father table whose index is specified.

Overrides:
getRefColumns in class DbConstraint

setAutomaticBuild

public void setAutomaticBuild(boolean value)
Tells this object to build (or not) automatically all lists at all times.


build

public void build()
           throws DbException
Builds all static lists.

Overrides:
build in class DbConstraint

checkThis

protected void checkThis(int operation)
                  throws DbException
Performs base checking.

Overrides:
checkThis in class DbConstraint

checkFathers

protected void checkFathers()
                     throws DbException
Checks the fathers.

Overrides:
checkFathers in class DbConstraint

createReferences

private void createReferences()

getDefaultValues

public java.lang.Object[] getDefaultValues(int index)
                                    throws DbException
Returns the default values of referenced father table whose index is specified.

Overrides:
getDefaultValues in class DbConstraint

buildArrays

private void buildArrays()