Package org.castor.cpa.jpa.info
Class ClassInfo
- java.lang.Object
-
- org.castor.cpa.jpa.info.ClassInfo
-
- All Implemented Interfaces:
NatureExtendable,PropertyHolder
public final class ClassInfo extends java.lang.Object implements PropertyHolder
This class holds the necessary information so that Castor can properly map a JPA annotatedClassto the database.- Since:
- 1.3
- Author:
- Peter Schmidt
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFieldInfo(FieldInfo fieldInfo)voidaddKey(FieldInfo key)Add aFieldInfoto the key set of this ClassInfo (keys and attributes are disjunct!).voidaddNature(java.lang.String nature)Adds a specified nature.java.lang.Class<?>getDescribedClass()Returns the reference to theClassobject that is described by thisClassInfo.java.lang.Class<?>getExtendedClass()Get the reference to the Class object that is extended by this class.intgetFieldCount()FieldInfogetFieldInfoByName(java.lang.String memberName)Returns aFieldInfothat corresponds to an element with the given node name.java.util.Set<FieldInfo>getFieldInfos()Returns Set of associated fields.intgetKeyFieldCount()FieldInfogetKeyFieldInfoByName(java.lang.String keyName)Returns aFieldInfothat corresponds to a key element with the given node name.java.util.Set<FieldInfo>getKeyFieldInfos()Returns Set of key fields.java.lang.ObjectgetProperty(java.lang.String name)Get a property by its name.booleanhasNature(java.lang.String nature)Checks if a specified nature has been added.voidsetDescribedClass(java.lang.Class<?> describedClass)Sets theClassthat is described by thisClassInfo.voidsetProperty(java.lang.String name, java.lang.Object value)Set a property specified by the name to the passed value.
-
-
-
Method Detail
-
addNature
public void addNature(java.lang.String nature)
Adds a specified nature.- Specified by:
addNaturein interfaceNatureExtendable- Parameters:
nature- the name of the nature- See Also:
NatureExtendable.addNature(java.lang.String)
-
hasNature
public boolean hasNature(java.lang.String nature)
Checks if a specified nature has been added.- Specified by:
hasNaturein interfaceNatureExtendable- Parameters:
nature- the name of the nature.- Returns:
- true if the specified nature was added.
- See Also:
NatureExtendable.hasNature(java.lang.String)
-
getProperty
public java.lang.Object getProperty(java.lang.String name)
Get a property by its name.- Specified by:
getPropertyin interfacePropertyHolder- Parameters:
name- the name of the property to get.- Returns:
- the property as specified by the name.
- See Also:
PropertyHolder.getProperty(java.lang.String)
-
setProperty
public void setProperty(java.lang.String name, java.lang.Object value)Set a property specified by the name to the passed value.- Specified by:
setPropertyin interfacePropertyHolder- Parameters:
name- the name of the property to set.value- the value to set the specified property to.- See Also:
PropertyHolder.setProperty(java.lang.String, java.lang.Object)
-
getDescribedClass
public java.lang.Class<?> getDescribedClass()
Returns the reference to theClassobject that is described by thisClassInfo.- Returns:
- The reference to the Class object that is described by this ClassInfo.
-
setDescribedClass
public void setDescribedClass(java.lang.Class<?> describedClass)
Sets theClassthat is described by thisClassInfo.- Parameters:
describedClass- TheClassthat is described by thisClassInfo.
-
addFieldInfo
public void addFieldInfo(FieldInfo fieldInfo)
-
getFieldCount
public int getFieldCount()
-
getFieldInfoByName
public FieldInfo getFieldInfoByName(java.lang.String memberName)
Returns aFieldInfothat corresponds to an element with the given node name.- Parameters:
memberName- the name of the field to get.- Returns:
- a
FieldInfothat corresponds to an element with the given node name or null if that field does not exist.
-
getFieldInfos
public java.util.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 aFieldInfoto 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
FieldInfodefinitions for this ClassInfo's key.
-
getKeyFieldInfoByName
public FieldInfo getKeyFieldInfoByName(java.lang.String keyName)
Returns aFieldInfothat corresponds to a key element with the given node name.- Parameters:
keyName- the name of the key field to get.- Returns:
- a
FieldInfothat corresponds to a key element with the given node name or null if that field is not in the key set.
-
getKeyFieldInfos
public java.util.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 java.lang.Class<?> getExtendedClass()
Get the reference to the Class object that is extended by this class.- Returns:
- the superclass of the described class.
-
-