org.jaffa.persistence.engines.jdbcengine.configservice
Class ClassMetaData

java.lang.Object
  extended byorg.jaffa.persistence.engines.jdbcengine.configservice.ClassMetaData

public class ClassMetaData
extends Object

This class holds all the meta deta pertaining to a particular persistent object


Constructor Summary
ClassMetaData()
          Constructs a new ClassMetaData object with an empty class name.
ClassMetaData(String classname)
          Constructs a new ClassMetaData object with the specified class name.
 
Method Summary
 void addAttribute(String attName, String type)
          Add an attribute to this meta data object.
 void addKeyField(String attName, String type, boolean autogen)
          Add a primary key field attribute to this meta data object.
 void addMember(String attName, String memberName)
          Add a member for an attribute to this meta object.
 void addSqlName(String attName, String sqlName)
          Add a new sql name for an attribute to this meta object.
 void addSqlType(String attName, String type)
          Add sql type data for a particular attribute in this meta data object.
 AccessibleObject getAccessor(String attributeName)
          Returns the accessor Field/Method for the specified attribute.
 Map getAccessors()
          Return a Map of the accessor Field/Method objects for the defined class where key is the name of the attribute and value is the accessor Field/Method object.
 Map getAllKeyFieldNames()
          Returns a Map where key is the name of a primary key attribute for the class and value is its corresponding Java type.
 Map getAttributes()
          Returns a Map of the non-primary-key attributes of the class where key is the name of the attribtue and value is its Java type.
 String getClassName()
          Returns the fully-qualified class name of the class that this meta object represents.
 AccessibleObject getMutator(String attributeName)
          Returns the mutator Field/Method for the specified attribute.
 Map getMutators()
          Return a Map of the mutator Field/Method objects for the defined class where key is the name of the attribute and value is the mutator Field/Method object.
 Map getNonAutoKeyFieldNames()
          Returns a Map where key is the name of a primary key attribute for the class and value is its corresponding Java type.
 String getSqlName(String attributeName)
          Returns the name of the sql column in which the specified attribute is stored, as defined in the mapping file.
 String getSqlType(String attributeName)
          Returns the database sql type for the specified attribute, as defined in the mapping file.
 String getTable()
          Return the database table name that the object represented by this meta object is to be stored in.
 String getType(String attName)
          Returns the Java type of the specified attribute.
 URL getXmlFileUrl()
          Returns the URL object that was parsed to obtain the meta data for this object.
 void setClassName(String classname)
          Set the classname property of this meta data object.
 void setTable(String table)
          Set the table property of this meta data object
 void setXmlFileUrl(URL xmlFileUrl)
          Set the xmlFileUrl property of this meta data object.
 void validate()
          Uses the Introspection service to ensure that the correct accessors and mutators exist for each attribtue specified in the mapping file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassMetaData

public ClassMetaData()
Constructs a new ClassMetaData object with an empty class name.


ClassMetaData

public ClassMetaData(String classname)
Constructs a new ClassMetaData object with the specified class name.

Parameters:
classname - The fully-qualified classname of the class this meta object is to represent.
Method Detail

setXmlFileUrl

public void setXmlFileUrl(URL xmlFileUrl)
Set the xmlFileUrl property of this meta data object.

Parameters:
xmlFileUrl - The File object used to describe this persistent object.

setClassName

public void setClassName(String classname)
Set the classname property of this meta data object.

Parameters:
classname - The fully qualified class name of the class this meta object represents.

setTable

public void setTable(String table)
Set the table property of this meta data object

Parameters:
table - The database table name used to store this object

addKeyField

public void addKeyField(String attName,
                        String type,
                        boolean autogen)
Add a primary key field attribute to this meta data object.

Parameters:
attName - The name of the primary key attribute to be added.
type - The Java type of the primary key attribute.
autogen - Indicates if the key will be auto-generated.

addAttribute

public void addAttribute(String attName,
                         String type)
Add an attribute to this meta data object.

Parameters:
attName - The attribute to be added.
type - The Java type of the attribute to be added.

addSqlName

public void addSqlName(String attName,
                       String sqlName)
Add a new sql name for an attribute to this meta object.

Parameters:
attName - The name of the attribute for which the sql name is to be added.
sqlName - The sql name of the attribute.

addSqlType

public void addSqlType(String attName,
                       String type)
Add sql type data for a particular attribute in this meta data object.

Parameters:
attName - The name of the attribute for which sql type is to be added.
type - The sql type for the attribute.

addMember

public void addMember(String attName,
                      String memberName)
Add a member for an attribute to this meta object.

Parameters:
attName - The name of the attribute for which the member is to be added.
memberName - The name of the member variable.

validate

public void validate()
Uses the Introspection service to ensure that the correct accessors and mutators exist for each attribtue specified in the mapping file. The runtime exception ClassMetaDataValidationRuntimeException is thrown in case any error occurs in the introspection, or if all accessors/mutators could not be located for all the attributes.


getXmlFileUrl

public URL getXmlFileUrl()
Returns the URL object that was parsed to obtain the meta data for this object.

Returns:
The URL of the xml File that describes this object.

getClassName

public String getClassName()
Returns the fully-qualified class name of the class that this meta object represents.

Returns:
Fully qualified class name of the class that this meta object represents.

getTable

public String getTable()
Return the database table name that the object represented by this meta object is to be stored in.

Returns:
Database table name that this object is stored in.

getAllKeyFieldNames

public Map getAllKeyFieldNames()
Returns a Map where key is the name of a primary key attribute for the class and value is its corresponding Java type.

Since 1.3 - This include both manual and auto genrated key fields, use getNonAutoKeyFieldNames() to get just the manual key fields.

Returns:
Map of the key attributes and their types.

getNonAutoKeyFieldNames

public Map getNonAutoKeyFieldNames()
Returns a Map where key is the name of a primary key attribute for the class and value is its corresponding Java type. Only the keys that are not auto generated by the database are returned, these are the keys that are valid when inserting a row, as auto gnerated keys should not be provided.

Returns:
Map of the key attributes and their types.
Since:
1.3

getAttributes

public Map getAttributes()
Returns a Map of the non-primary-key attributes of the class where key is the name of the attribtue and value is its Java type.

Returns:
Map representing the non-primary-key attributes of the class.

getType

public String getType(String attName)
Returns the Java type of the specified attribute.

Parameters:
attName - The name of the attribute to be checked.
Returns:
The Java type of the specified attribute.

getSqlName

public String getSqlName(String attributeName)
Returns the name of the sql column in which the specified attribute is stored, as defined in the mapping file.

Parameters:
attributeName - Name of the attribute for which the sql name is required.
Returns:
The column name for the specified attribute.

getSqlType

public String getSqlType(String attributeName)
Returns the database sql type for the specified attribute, as defined in the mapping file.

Parameters:
attributeName - Name of the attribute for which sql type is required.
Returns:
The sql type for the specified attribtue.

getAccessors

public Map getAccessors()
Return a Map of the accessor Field/Method objects for the defined class where key is the name of the attribute and value is the accessor Field/Method object.

Returns:
A Map of the accessor Field/Method objects for the defined class.

getAccessor

public AccessibleObject getAccessor(String attributeName)
Returns the accessor Field/Method for the specified attribute.

Parameters:
attributeName - Name of the attribute for which accessor is required.
Returns:
The accessor Field/Method for the attribute.

getMutators

public Map getMutators()
Return a Map of the mutator Field/Method objects for the defined class where key is the name of the attribute and value is the mutator Field/Method object.

Returns:
A Map of the mutator Field/Method objects for the defined class.

getMutator

public AccessibleObject getMutator(String attributeName)
Returns the mutator Field/Method for the specified attribute.

Parameters:
attributeName - Name of the attribute for which mutator is required.
Returns:
The mutator Field/Method for the attribute.


Copyright © 2002-2004 JAFFA Project.