org.castor.jdo.jpa.info
Class ClassInfo

java.lang.Object
  extended by org.castor.jdo.jpa.info.ClassInfo
All Implemented Interfaces:
NatureExtendable, PropertyHolder

public final class ClassInfo
extends Object
implements PropertyHolder

This class holds the necessary information so that Castor can properly map a JPA annotated Class to the database.

Since:
1.3
Author:
Peter Schmidt

Constructor Summary
ClassInfo()
          Creates a new empty ClassInfo.
ClassInfo(Class<?> describedClass)
          Creates a new ClassInfo, describing a given Class.
 
Method Summary
 void addFieldInfo(FieldInfo fieldInfo)
          Add a FieldInfo to this ClassInfo; if the FieldInfo is already in the set of fields, it is NOT added a second time (FieldInfos are unique).
 void addKey(FieldInfo key)
          Add a FieldInfo to the key set of this ClassInfo (keys and attributes are disjunct!).
 void addNature(String nature)
          
 Class<?> getDescribedClass()
          Returns the reference to the Class object that is described by this ClassInfo.
 Class<?> getExtendedClass()
          Get the reference to the Class object that is extended by this class.
 int getFieldCount()
          Indicates the number of FieldInfos already known to this ClassInfo.
 FieldInfo getFieldInfoByName(String memberName)
          Returns a FieldInfo that corresponds to an element with the given node name.
 Set<FieldInfo> getFieldInfos()
          Returns Set of associated fields.
 int getKeyFieldCount()
           
 FieldInfo getKeyFieldInfoByName(String keyName)
          Returns a FieldInfo that corresponds to a key element with the given node name.
 Set<FieldInfo> getKeyFieldInfos()
          Returns Set of key fields.
 Object getProperty(String name)
          
 boolean hasNature(String nature)
          
 void setDescribedClass(Class<?> describedClass)
          Sets the Class that is described by this ClassInfo.
 void setProperty(String name, Object value)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassInfo

public ClassInfo()
Creates a new empty ClassInfo.


ClassInfo

public ClassInfo(Class<?> describedClass)
Creates a new ClassInfo, describing a given Class.

Parameters:
describedClass - the Class that is described by this ClassInfo.
Method Detail

addNature

public void addNature(String nature)

Specified by:
addNature in interface NatureExtendable
See Also:
NatureExtendable.addNature(java.lang.String)

hasNature

public boolean hasNature(String nature)

Specified by:
hasNature in interface NatureExtendable
See Also:
NatureExtendable.hasNature(java.lang.String)

getProperty

public Object getProperty(String name)

Specified by:
getProperty in interface PropertyHolder
See Also:
PropertyHolder.getProperty(java.lang.String)

setProperty

public void setProperty(String name,
                        Object value)

Specified by:
setProperty in interface PropertyHolder
See Also:
PropertyHolder.setProperty(java.lang.String, java.lang.Object)

getDescribedClass

public Class<?> getDescribedClass()
Returns the reference to the Class object that is described by this ClassInfo.

Returns:
The reference to the Class object that is described by this ClassInfo.

setDescribedClass

public void setDescribedClass(Class<?> describedClass)
Sets the Class that is described by this ClassInfo.

Parameters:
describedClass - The Class that is described by this ClassInfo.

addFieldInfo

public void addFieldInfo(FieldInfo fieldInfo)
Add a FieldInfo to this ClassInfo; if the FieldInfo is already in the set of fields, it is NOT added a second time (FieldInfos are unique).

Parameters:
fieldInfo - The FieldInfo to add to this ClassInfo

getFieldCount

public int getFieldCount()
Indicates the number of FieldInfos already known to this ClassInfo.

Returns:
The number of FieldInfo definitions for this ClassInfo.

getFieldInfoByName

public FieldInfo getFieldInfoByName(String memberName)
Returns a FieldInfo that corresponds to an element with the given node name.

Parameters:
memberName - the name of the field to get.
Returns:
a FieldInfo that corresponds to an element with the given node name or null if that field does not exist.

getFieldInfos

public Set<FieldInfo> getFieldInfos()
Returns Set of associated fields. If no fields are associated, null is returned. This returned set is just a copy of the internal one, so changes to the Set will not affect the internal Set.

Returns:
a Set of associated fields.

addKey

public void addKey(FieldInfo key)
Add a FieldInfo to the key set of this ClassInfo (keys and attributes are disjunct!). It is only inserted once in each of these lists, so normal elements can be "raised" to be keys after first adding them to the class.

Parameters:
key - - the FieldInfo to add to the set of key fields.

getKeyFieldCount

public int getKeyFieldCount()
Returns:
the number of FieldInfo definitions for this ClassInfo's key.

getKeyFieldInfoByName

public FieldInfo getKeyFieldInfoByName(String keyName)
Returns a FieldInfo that corresponds to a key element with the given node name.

Parameters:
keyName - the name of the key field to get.
Returns:
a FieldInfo that corresponds to a key element with the given node name or null if that field is not in the key set.

getKeyFieldInfos

public Set<FieldInfo> getKeyFieldInfos()
Returns Set of key fields. If no fields are associated, null is returned. This returned Set is just a copy of the internal one, so changes to the Set will not affect the internal key set.

Returns:
an array of associated fields.

getExtendedClass

public Class<?> getExtendedClass()
Get the reference to the Class object that is extended by this class.

Returns:
the superclass of the described class.


Copyright © 2010. All Rights Reserved.