Package org.castor.ddlgen.schemaobject
Class ForeignKey
java.lang.Object
org.castor.ddlgen.schemaobject.AbstractSchemaObject
org.castor.ddlgen.schemaobject.ForeignKey
- All Implemented Interfaces:
SchemaObject
- Direct Known Subclasses:
DefaultForeignKey
,MysqlForeignKey
Abstract base class for all foreign keys.
- Since:
- 1.1
- Version:
- $Revision: 5951 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
- Author:
- Le Duc Bao, Ralf Joachim
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Relation type: many-many.static final int
Relation type: one-many.static final int
Relation type: one-one.Fields inherited from class org.castor.ddlgen.schemaobject.AbstractSchemaObject
HASHFACTOR
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal void
Add given field to list of foreign key fields.final void
addReferenceField
(Field field) Add given field to list of fields referenced by the foreign key.final boolean
protected final void
fieldNames
(DDLWriter writer) Concatenate all field names delimited by field delimiter and whitespace.final Field
getField
(int index) Get foreign key field at given index.final int
Get number of foreign key fields.final Field
getReferenceField
(int index) Get field referenced by the foreign key at given index.final int
Get number of fields referenced by the foreign key.final Table
Get table referenced by the foreign key.final int
Get type of relation.final Table
getTable()
Get table that holds foreign key.final int
hashCode()
final void
merge
(ForeignKey fk) Check if given foreign key can be merged with this one.protected final void
referencedFieldNames
(DDLWriter writer) Concatenate all referenced field names delimited by field delimiter and whitespace.final void
setReferenceTable
(Table table) Set table referenced by the foreign key.final void
setRelationType
(int relationType) Set type of relation.final void
Set table that holds foreign key.final void
Build drop script for the schema object.Methods inherited from class org.castor.ddlgen.schemaobject.AbstractSchemaObject
equals, getConfiguration, getName, setConfiguration, setName
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.castor.ddlgen.schemaobject.SchemaObject
toCreateDDL
-
Field Details
-
ONE_ONE
public static final int ONE_ONERelation type: one-one.- See Also:
-
ONE_MANY
public static final int ONE_MANYRelation type: one-many.- See Also:
-
MANY_MANY
public static final int MANY_MANYRelation type: many-many.- See Also:
-
-
Constructor Details
-
ForeignKey
public ForeignKey()
-
-
Method Details
-
setRelationType
public final void setRelationType(int relationType) Set type of relation.- Parameters:
relationType
- Type of relation.
-
getRelationType
public final int getRelationType()Get type of relation.- Returns:
- Type of relation
-
addReferenceField
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.
-
getReferenceFieldCount
public final int getReferenceFieldCount()Get number of fields referenced by the foreign key.- Returns:
- Number of fields referenced by the foreign key.
-
getReferenceField
Get field referenced by the foreign key at given index.- Parameters:
index
- Index of referenced field to return.- Returns:
- Referneced field at given index.
-
setReferenceTable
Set table referenced by the foreign key.- Parameters:
table
- Table referenced by the foreign key.
-
getReferenceTable
Get table referenced by the foreign key.- Returns:
- Table referenced by the foreign key.
-
addField
Add given field to list of foreign key fields.- Parameters:
field
- Field to add to list of foreign key fields.
-
getFieldCount
public final int getFieldCount()Get number of foreign key fields.- Returns:
- Number of foreign key fields.
-
getField
Get foreign key field at given index.- Parameters:
index
- Index of foreign key field to return.- Returns:
- Foreign key field at given index.
-
setTable
Set table that holds foreign key.- Parameters:
table
- Table that holds foreign key.
-
getTable
Get table that holds foreign key.- Returns:
- Table that holds foreign key.
-
fieldNames
Concatenate all field names delimited by field delimiter and whitespace.- Parameters:
writer
- DDLWriter to write schema objects to.
-
referencedFieldNames
Concatenate all referenced field names delimited by field delimiter and whitespace.- Parameters:
writer
- DDLWriter to write schema objects to.
-
toDropDDL
Build drop script for the schema object.- Parameters:
writer
- DDLWriter to write schema objects to.
-
merge
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.
-
equals
-
hashCode
public final int hashCode()
-