org.castor.ddlgen.schemaobject

Class ForeignKey

Implemented Interfaces:
SchemaObject
Known Direct Subclasses:
DefaultForeignKey, MysqlForeignKey

public abstract class ForeignKey
extends AbstractSchemaObject

Abstract base class for all foreign keys.
Version:
$Revision: 5951 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
Authors:
Le Duc Bao
Ralf Joachim
Since:
1.1

Field Summary

static int
MANY_MANY
Relation type: many-many.
static int
ONE_MANY
Relation type: one-many.
static int
ONE_ONE
Relation type: one-one.

Fields inherited from class org.castor.ddlgen.schemaobject.AbstractSchemaObject

HASHFACTOR

Method Summary

void
addField(Field field)
Add given field to list of foreign key fields.
void
addReferenceField(Field field)
Add given field to list of fields referenced by the foreign key.
boolean
equals(Object other)
protected void
fieldNames(DDLWriter writer)
Concatenate all field names delimited by field delimiter and whitespace.
Field
getField(int index)
Get foreign key field at given index.
int
getFieldCount()
Get number of foreign key fields.
Field
getReferenceField(int index)
Get field referenced by the foreign key at given index.
int
getReferenceFieldCount()
Get number of fields referenced by the foreign key.
Table
getReferenceTable()
Get table referenced by the foreign key.
int
getRelationType()
Get type of relation.
Table
getTable()
Get table that holds foreign key.
int
hashCode()
void
merge(ForeignKey fk)
Check if given foreign key can be merged with this one.
protected void
referencedFieldNames(DDLWriter writer)
Concatenate all referenced field names delimited by field delimiter and whitespace.
void
setReferenceTable(Table table)
Set table referenced by the foreign key.
void
setRelationType(int relationType)
Set type of relation.
void
setTable(Table table)
Set table that holds foreign key.
void
toDropDDL(DDLWriter writer)

Methods inherited from class org.castor.ddlgen.schemaobject.AbstractSchemaObject

equals, getConfiguration, getName, setConfiguration, setName

Field Details

MANY_MANY

public static final int MANY_MANY
Relation type: many-many.
Field Value:
2

ONE_MANY

public static final int ONE_MANY
Relation type: one-many.
Field Value:
1

ONE_ONE

public static final int ONE_ONE
Relation type: one-one.
Field Value:
0

Method Details

addField

public final void addField(Field field)
Add given field to list of foreign key fields.
Parameters:
field - Field to add to list of foreign key fields.

addReferenceField

public final void addReferenceField(Field field)
Add given field to list of fields referenced by the foreign key.
Parameters:
field - Field to add to list of fields referenced by the foreign key.

equals

public final boolean equals(Object other)

fieldNames

protected final void fieldNames(DDLWriter writer)
Concatenate all field names delimited by field delimiter and whitespace.
Parameters:
writer - DDLWriter to write schema objects to.

getField

public final Field getField(int index)
Get foreign key field at given index.
Parameters:
index - Index of foreign key field to return.
Returns:
Foreign key field at given index.

getFieldCount

public final int getFieldCount()
Get number of foreign key fields.
Returns:
Number of foreign key fields.

getReferenceField

public final Field getReferenceField(int index)
Get field referenced by the foreign key at given index.
Parameters:
index - Index of referenced field to return.
Returns:
Referneced field at given index.

getReferenceFieldCount

public final int getReferenceFieldCount()
Get number of fields referenced by the foreign key.
Returns:
Number of fields referenced by the foreign key.

getReferenceTable

public final Table getReferenceTable()
Get table referenced by the foreign key.
Returns:
Table referenced by the foreign key.

getRelationType

public final int getRelationType()
Get type of relation.
Returns:
Type of relation

getTable

public final Table getTable()
Get table that holds foreign key.
Returns:
Table that holds foreign key.

hashCode

public final int hashCode()

merge

public final void merge(ForeignKey fk)
            throws GeneratorException
Check if given foreign key can be merged with this one.
Parameters:
fk - Foreign key to check if it is able to be merged.
Throws:
GeneratorException - If foreign keys cannot be merged.

referencedFieldNames

protected final void referencedFieldNames(DDLWriter writer)
Concatenate all referenced field names delimited by field delimiter and whitespace.
Parameters:
writer - DDLWriter to write schema objects to.

setReferenceTable

public final void setReferenceTable(Table table)
Set table referenced by the foreign key.
Parameters:
table - Table referenced by the foreign key.

setRelationType

public final void setRelationType(int relationType)
Set type of relation.
Parameters:
relationType - Type of relation.

setTable

public final void setTable(Table table)
Set table that holds foreign key.
Parameters:
table - Table that holds foreign key.

toDropDDL

public final void toDropDDL(DDLWriter writer)
Specified by:
toDropDDL in interface SchemaObject

Intalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com