org.apache.torque.engine.database.model
Class ForeignKey

java.lang.Object
  extended by org.apache.torque.engine.database.model.ForeignKey

public class ForeignKey
extends Object

A class for information about foreign keys of a table.

Version:
$Id: ForeignKey.java,v 1.1 2007-10-21 07:57:27 abyrne Exp $
Author:
Fedor, Daniel Rall,
Constructor Summary
ForeignKey()
           
 
Method Summary
 void addOption(String key, String value)
          Add an XML Specified option key/value pair to this element's option set.
 void addReference(Attributes attrib)
          Adds a new reference entry to the foreign key
 void addReference(String local, String foreign)
          Adds a new reference entry to the foreign key
 String getForeignColumnNames()
          Returns a comma delimited string of foreign column names
 List getForeignColumns()
          Returns the list of foreign column names.
 Hashtable getForeignLocalMapping()
          Utility method to get foreign column names to local column names mapping for this foreign key.
 String getForeignTableName()
          Get the foreignTableName of the FK
 String getLocalColumnNames()
          Returns a comma delimited string of local column names
 List getLocalColumns()
          Returns the list of local column names.
 Hashtable getLocalForeignMapping()
          Utility method to get local column names to foreign column names mapping for this foreign key.
 String getName()
          Returns the name attribute.
 String getOnDelete()
          Returns the onDelete attribute
 String getOnUpdate()
          Returns the onUpdate attribute
 String getOption(String key)
          Get the value that was associated with this key in an XML option element.
 Map getOptions()
          Gets the full ordered hashtable array of items specified by XML option statements under this element.
 Table getTable()
          Get the parent Table of the foreign key
 String getTableName()
          Returns the name of the table the foreign key is in
 boolean hasOnDelete()
          Returns whether or not the onDelete attribute is set
 boolean hasOnUpdate()
          Returns whether or not the onUpdate attribute is set
 void loadFromXML(Attributes attrib)
          Imports foreign key from an XML specification
 void setForeignTableName(String tableName)
          Set the foreignTableName of the FK
 void setName(String name)
          Sets the name attribute.
 void setOnDelete(String value)
          Sets the onDelete attribute
 void setOnUpdate(String value)
          Sets the onUpdate attribute
 void setTable(Table parent)
          Set the parent Table of the foreign key
 String toString()
          String representation of the foreign key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ForeignKey

public ForeignKey()
Method Detail

loadFromXML

public void loadFromXML(Attributes attrib)
Imports foreign key from an XML specification

Parameters:
attrib - the xml attributes

hasOnUpdate

public boolean hasOnUpdate()
Returns whether or not the onUpdate attribute is set

Returns:
true if the onUpdate attribute is set

hasOnDelete

public boolean hasOnDelete()
Returns whether or not the onDelete attribute is set

Returns:
true if the onDelete attribute is set

getOnUpdate

public String getOnUpdate()
Returns the onUpdate attribute

Returns:
the onUpdate attribute

getOnDelete

public String getOnDelete()
Returns the onDelete attribute

Returns:
the onDelete attribute

setOnDelete

public void setOnDelete(String value)
Sets the onDelete attribute

Parameters:
value - the onDelete attribute

setOnUpdate

public void setOnUpdate(String value)
Sets the onUpdate attribute

Parameters:
value - the onUpdate attribute

getName

public String getName()
Returns the name attribute.

Returns:
the name

setName

public void setName(String name)
Sets the name attribute.

Parameters:
name - the name

getForeignTableName

public String getForeignTableName()
Get the foreignTableName of the FK

Returns:
the name of the foreign table

setForeignTableName

public void setForeignTableName(String tableName)
Set the foreignTableName of the FK

Parameters:
tableName - the name of the foreign table

setTable

public void setTable(Table parent)
Set the parent Table of the foreign key

Parameters:
parent - the table

getTable

public Table getTable()
Get the parent Table of the foreign key

Returns:
the parent table

getTableName

public String getTableName()
Returns the name of the table the foreign key is in

Returns:
the name of the table

addReference

public void addReference(Attributes attrib)
Adds a new reference entry to the foreign key

Parameters:
attrib - the xml attributes

addReference

public void addReference(String local,
                         String foreign)
Adds a new reference entry to the foreign key

Parameters:
local - name of the local column
foreign - name of the foreign column

getLocalColumnNames

public String getLocalColumnNames()
Returns a comma delimited string of local column names

Returns:
the local column names

getForeignColumnNames

public String getForeignColumnNames()
Returns a comma delimited string of foreign column names

Returns:
the foreign column names

getLocalColumns

public List getLocalColumns()
Returns the list of local column names. You should not edit this List.

Returns:
the local columns

getLocalForeignMapping

public Hashtable getLocalForeignMapping()
Utility method to get local column names to foreign column names mapping for this foreign key.

Returns:
table mapping foreign names to local names

getForeignColumns

public List getForeignColumns()
Returns the list of foreign column names. You should not edit this List.

Returns:
the foreign columns

getForeignLocalMapping

public Hashtable getForeignLocalMapping()
Utility method to get foreign column names to local column names mapping for this foreign key.

Returns:
table mapping local names to foreign names

toString

public String toString()
String representation of the foreign key. This is an xml representation.

Overrides:
toString in class Object
Returns:
string representation in xml

addOption

public void addOption(String key,
                      String value)
Add an XML Specified option key/value pair to this element's option set.

Parameters:
key - the key of the option.
value - the value of the option.

getOption

public String getOption(String key)
Get the value that was associated with this key in an XML option element.

Parameters:
key - the key of the option.
Returns:
The value for the key or a null.

getOptions

public Map getOptions()
Gets the full ordered hashtable array of items specified by XML option statements under this element.

Note, this is not thread save but since it's only used for generation which is single threaded, there should be minimum danger using this in Velocity.

Returns:
An Map of all options. Will not be null but may be empty.


Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.