com.nec.tdd.tools.dbMapper
Class ORMapEntry

java.lang.Object
  |
  +--com.nec.tdd.tools.dbMapper.ORMapEntry

public class ORMapEntry
extends java.lang.Object

A ORMappingInfo entry (Class name - ORMapEntry pair).

This class holds mapping between a Java class and the relational table that will be used to store object instances of the class. An instance of this class is created per class tag specified in OR mapping (xml) file.

An ORMapEntry can also be constructed dynamically and added to an ORMappingInfo object.


Constructor Summary
ORMapEntry()
          Constructs an ORMapEntry with all paramters set to default.
 
Method Summary
 ORFieldInfo[] getAllFields()
          Method to get all fields for this mapping.
 java.lang.String getClassName()
          Returns the class name associated with this map entry.
 DAOInterface getDAO()
           
 ORFieldInfo getField(java.lang.String fieldName)
          Method to get an ORFieldInfo from this mapping for given field name.
 ORFieldInfo[] getKeyFields()
          Method to get all key fields (fields with isKey attribute set to true) for this mapping.
 java.lang.String getPKClassName()
          Get the primary key class name, if any, associated with this mapping.
 java.lang.String getTableName()
          Get the database table that will be used to store object instances of the mapping class name.
 boolean isUserDefinedPK()
          Returns true if primary key class is specified (pk_class tag) in mapping (explicit primary key).
 void setClassName(java.lang.String name)
          Set the class name associated with this map entry.
 void setDAO(DAOInterface dao)
           
 void setFields(ORFieldInfo[] newFields)
          Method to set or replace all fields for this mapping.
 void setPKClassName(java.lang.String pkClassName)
          Set a primary class for this mapping.
 void setTableName(java.lang.String name)
          Set the database table name that will be used to store object instances of the mapping class name.
 java.lang.String toString()
          Returns string representation of this mapping entry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ORMapEntry

public ORMapEntry()
Constructs an ORMapEntry with all paramters set to default.
Method Detail

getClassName

public java.lang.String getClassName()
Returns the class name associated with this map entry.

setClassName

public void setClassName(java.lang.String name)
Set the class name associated with this map entry.

getTableName

public java.lang.String getTableName()
Get the database table that will be used to store object instances of the mapping class name.

setTableName

public void setTableName(java.lang.String name)
Set the database table name that will be used to store object instances of the mapping class name.

getPKClassName

public java.lang.String getPKClassName()
                                throws java.lang.Exception
Get the primary key class name, if any, associated with this mapping. Rules to determine the primary class:
Throws:
java.lang.Exception - if primary key can not be determined from the mapping.

isUserDefinedPK

public boolean isUserDefinedPK()
Returns true if primary key class is specified (pk_class tag) in mapping (explicit primary key). False otherwise.

setPKClassName

public void setPKClassName(java.lang.String pkClassName)
Set a primary class for this mapping. This method overwrites old (explicit or implicit) primary key.
Parameters:
pkClassName - a primary class for this mapping.

getAllFields

public ORFieldInfo[] getAllFields()
Method to get all fields for this mapping.
Returns:
Array of all fields for this mapping.
See Also:
getKeyFields()

getKeyFields

public ORFieldInfo[] getKeyFields()
Method to get all key fields (fields with isKey attribute set to true) for this mapping.

Notes :
Keys fields are only of basic type.

Returns:
Array of all key fields for this mapping. Order in which fields are inserted to mapping is preserved.
See Also:
getAllFields()

getField

public ORFieldInfo getField(java.lang.String fieldName)
Method to get an ORFieldInfo from this mapping for given field name.
Parameters:
fieldName - A field name whose associated ORFieldInfo is to be returned.
Returns:
the ORFieldInfo entry to associate with given fieldName. Returns null if field name not found in mapping.

setFields

public void setFields(ORFieldInfo[] newFields)
Method to set or replace all fields for this mapping. This method updates other attributes (i.e. primary key class, key fields etc) dependent on these fields.
Parameters:
newFields - New fields for this mapping.

getDAO

public DAOInterface getDAO()

setDAO

public void setDAO(DAOInterface dao)

toString

public java.lang.String toString()
Returns string representation of this mapping entry.
Overrides:
toString in class java.lang.Object