Package org.exolab.castor.builder.info
Class ClassInfo
- java.lang.Object
-
- org.exolab.castor.builder.info.ClassInfo
-
- All Implemented Interfaces:
NatureExtendable
,PropertyHolder
,XMLInfo
public final class ClassInfo extends java.lang.Object implements XMLInfo, PropertyHolder
This class holds the necessary information so that the source generator can properly create the necessary classes for the object model.- Version:
- $Revision: 7943 $ $Date: 2006-04-13 07:37:49 -0600 (Thu, 13 Apr 2006) $
- Author:
- Keith Visco
-
-
Field Summary
-
Fields inherited from interface org.exolab.castor.builder.info.XMLInfo
CHOICE_NODE_NAME_ERROR_INDICATION
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFieldInfo(FieldInfo fieldInfo)
Adds the given FieldInfo to this ClassInfo.void
addFieldInfo(FieldInfo[] fields)
Adds the given set of FieldInfos to this ClassInfo.void
addNature(java.lang.String nature)
Adds a specified nature.boolean
allowContent()
boolean
contains(FieldInfo fieldInfo)
Returns true if the given FieldInfo is contained within this ClassInfo.FieldInfo
getAttributeField(java.lang.String nodeName)
Returns a fieldInfo that corresponds to an attribute with the given node name.FieldInfo[]
getAttributeFields()
Returns an array of XML attribute associated fields.java.util.Collection<FieldInfo>
getAttributeFieldsAsCollection()
Returns all attributeFieldInfo
s as a collection.ClassInfo
getBaseClass()
Returns the base class of this classInfo if any.FieldInfo
getElementField(java.lang.String nodeName)
Returns a fieldInfo that corresponds to an element with the given node name.FieldInfo[]
getElementFields()
Returns an array of XML element associated fields.java.util.Collection<FieldInfo>
getElementFieldsAsCollection()
Returns all elementFieldInfo
s as a collection.int
getFieldCount()
Returns the number of FieldInfo definitions for this ClassInfo.JClass
getJClass()
Returns the JClass described by this ClassInfo.java.lang.Object
getProperty(java.lang.String name)
Get a property by its name.FieldInfo
getTextField()
Returns the FieldInfo for the XML text associated field.boolean
hasNature(java.lang.String nature)
Checks if a specified nature has been added.boolean
isAbstract()
Returns true if the JClass represented by this ClassInfo is abstract.void
setAbstract(boolean abstractClass)
Sets the class of this ClassInfo to be abstract ofabstractClass
is true, false otherwise.void
setBaseClass(ClassInfo base)
Sets the base class of this classInfo.void
setProperty(java.lang.String name, java.lang.Object value)
Set a property specified by the name to the passed value.
-
-
-
Constructor Detail
-
ClassInfo
public ClassInfo(JClass jClass)
Creates a new ClassInfo. Adds theXMLInfoNature
for legacy compliance.- Parameters:
jClass
- the JClass which this ClassInfo describes
-
-
Method Detail
-
addFieldInfo
public void addFieldInfo(FieldInfo fieldInfo)
Adds the given FieldInfo to this ClassInfo.- Parameters:
fieldInfo
- the FieldInfo to add
-
addFieldInfo
public void addFieldInfo(FieldInfo[] fields)
Adds the given set of FieldInfos to this ClassInfo.- Parameters:
fields
- an Array of FieldInfo objects
-
allowContent
public boolean allowContent()
- Returns:
- true if Classes created with this ClassInfo allow content
-
contains
public boolean contains(FieldInfo fieldInfo)
Returns true if the given FieldInfo is contained within this ClassInfo.- Parameters:
fieldInfo
- the FieldInfo to check- Returns:
- true if the given FieldInfo is contained within this ClassInfo
-
getAttributeFields
public FieldInfo[] getAttributeFields()
Returns an array of XML attribute associated fields.- Returns:
- an array of XML attribute associated fields.
-
getAttributeField
public FieldInfo getAttributeField(java.lang.String nodeName)
Returns a fieldInfo that corresponds to an attribute with the given node name. A ClassInfo cannot have 2 attributes with the same xml name.- Parameters:
nodeName
- the NodeName of the field to get.- Returns:
- a fieldInfo that corresponds to an attribute with the given node name.
-
getBaseClass
public ClassInfo getBaseClass()
Returns the base class of this classInfo if any. A classInfo can indeed extend another classInfo to reflect the extension mechanism used in the XML Schema.- Returns:
- the base class of this classInfo if any.
-
getElementFields
public FieldInfo[] getElementFields()
Returns an array of XML element associated fields.- Returns:
- an array of XML element associated fields.
-
getElementField
public FieldInfo getElementField(java.lang.String nodeName)
Returns a fieldInfo that corresponds to an element with the given node name. A ClassInfo cannot have 2 elements with the same xml name.- Parameters:
nodeName
- the NodeName of the field to get.- Returns:
- a fieldInfo that corresponds to an element with the given node name.
-
getFieldCount
public int getFieldCount()
Returns the number of FieldInfo definitions for this ClassInfo.- Returns:
- the number of FieldInfo definitions for this ClassInfo.
-
getJClass
public JClass getJClass()
Returns the JClass described by this ClassInfo.- Returns:
- the JClass which is described by this ClassInfo
-
getTextField
public FieldInfo getTextField()
Returns the FieldInfo for the XML text associated field.- Returns:
- the FieldInfo for the text content associated field, this may be null.
-
isAbstract
public boolean isAbstract()
Returns true if the JClass represented by this ClassInfo is abstract.- Returns:
- true if the JClass represented by this ClassInfo is abstract
-
setAbstract
public void setAbstract(boolean abstractClass)
Sets the class of this ClassInfo to be abstract ofabstractClass
is true, false otherwise.- Parameters:
abstractClass
- true if the class represented by this ClassInfo is abstract
-
setBaseClass
public void setBaseClass(ClassInfo base)
Sets the base class of this classInfo. A classInfo can indeed extend another classInfo to reflect the extension mechanism used in the XML Schema- Parameters:
base
- the base class of this classInfo.
-
getProperty
public java.lang.Object getProperty(java.lang.String name)
Description copied from interface:PropertyHolder
Get a property by its name.- Specified by:
getProperty
in interfacePropertyHolder
- Parameters:
name
- of the property- Returns:
- value of the property
-
setProperty
public void setProperty(java.lang.String name, java.lang.Object value)
Description copied from interface:PropertyHolder
Set a property specified by the name to the passed value.- Specified by:
setProperty
in interfacePropertyHolder
- Parameters:
name
- of the propertyvalue
- of the property
-
addNature
public void addNature(java.lang.String nature)
Description copied from interface:NatureExtendable
Adds a specified nature.- Specified by:
addNature
in interfaceNatureExtendable
- Parameters:
nature
- ID of the Nature
-
hasNature
public boolean hasNature(java.lang.String nature)
Description copied from interface:NatureExtendable
Checks if a specified nature has been added.- Specified by:
hasNature
in interfaceNatureExtendable
- Parameters:
nature
- ID of the Nature- Returns:
- true if the Nature ID was added.
-
getAttributeFieldsAsCollection
public java.util.Collection<FieldInfo> getAttributeFieldsAsCollection()
Returns all attributeFieldInfo
s as a collection.- Returns:
- attribute fields.
-
-