org.objectweb.jorm.metainfo.lib
Class BasicClass

java.lang.Object
  |
  +--org.objectweb.jorm.metainfo.lib.BasicClass
All Implemented Interfaces:
Class, Loggable, MetaObject, java.io.Serializable

public class BasicClass
extends java.lang.Object
implements Class, Loggable

BasicClass is an implementation of the Class interface defined in the meta information system. This object is defined by a list of fields, a name, a list of mapping.

Author:
X. Spengler
See Also:
Serialized Form

Constructor Summary
BasicClass(java.lang.String className, boolean abstractClass, MetaObject parent)
          Builds a new Class object.
 
Method Summary
 void addAllInheritedClass(java.util.Map table)
          Constructs an Map with inherited class
 void addInheritedClass(Class class_)
          Adds a new inherited class to the list of the inherited classes for the current class object.
 ClassMapping createClassMapping(java.lang.String mapperName, java.lang.String mappingName)
          Creates a new ClassMapping object for the current class.
 ClassRef createClassRef(java.lang.String fieldName, Class class_)
          Allows to obtain a new ClassRef from a field name an its class.
 GenClassRef createGenClassRef(java.lang.String fieldName, java.lang.String genName)
          Allows to obtain a new GenClassRef from a field name an its generic class.
 ScalarField createHiddenField(java.lang.String fieldName, PType type)
          Creates a new scalar field and adds it to the list of hidden fields.
 NameDef createNameDef()
          Creates a new NameDef object for the current Class object.
 PrimitiveElement createPrimitiveElement(java.lang.String fieldName, PType type)
          Allows to obtain a new PrimitiveElement from a class field name an its type.
 java.util.Collection getAllFields()
           
 ClassMapping getClassMapping(java.lang.String mapperName, java.lang.String mappingName)
          Returns an existing ClassMapping object for the current class object.
 int getFieldRefNumber()
          Returns the number of fields which are references to classes.
 java.lang.String getFQName()
           
 ScalarField getHiddenField(java.lang.String fieldName)
          retrieve an hiddenfield from its name.
 int getInheritedClassNumber()
          Returns the number of inherited classes for the current Class object.
 org.objectweb.util.monolog.api.Logger getLogger()
          Returns a logger to an component that wants to log things.
 org.objectweb.util.monolog.api.LoggerFactory getLoggerFactory()
          Returns a logger factory that allows the creation of new loggers.
 java.lang.String getName()
          Allows to know the name of the current class object.
 NameDef getNameDef(java.lang.String mappingName)
          Returns a NameDef object from a given mapperName and mappingName.
 MetaObject getParent()
          Allows to know the parent MetaObject of the current MetaObject.
 TypedElement getTypedElement(java.lang.String fieldName)
          Allows to obtain an existing Field.
 boolean isAbstract()
          Allows to know if the current class is an abstract class or not.
 boolean isInherited()
          Tests if this class is inherited by another one.
 java.util.Iterator iterateAllField()
          Returns an iterator on existing class fields + fields from super classes.
 java.util.Iterator iterateAllHiddenField()
          Provides an iterator over the all the hiddenfield of the class including inherited fields.
 java.util.Iterator iterateClassMapping()
          Allows to know all the ClassMapping object used for the current class.
 java.util.Iterator iterateField()
          Returns an iterator on existing class fields.
 java.util.Iterator iterateHiddenField()
          return an iterator over the hiddenfield of the class definition.
 java.util.Iterator iterateInheritedClass()
          Allows to obtain all the inherited classes from the current class object.
 java.util.Iterator iterateNameDef()
          Returns an iterator on existing NameDef for the current Class.
protected  java.util.Collection listField()
          returns an ArrayList which contains the current fields.
 void setInherited()
          Specifies that this class is inherited by another one within the set of compiled ones.
 void setLogger(org.objectweb.util.monolog.api.Logger logger)
          Defines a logger object.
 void setLoggerFactory(org.objectweb.util.monolog.api.LoggerFactory loggerFactory)
          Defines the logger factory to obtain new logger.
 void setParent(MetaObject itsParent)
          Set the parent of the current meta object if it is not yet done by the constructor of the meta object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicClass

public BasicClass(java.lang.String className,
                  boolean abstractClass,
                  MetaObject parent)
Builds a new Class object. This object is mainly defined by its name, if the class is abstract or not, and its parent (a schema).
Parameters:
className - the name of the current class
abstractClass - true if the current class is abstract, else false if the current class is not abstract
parent - the parent of the current object
Method Detail

isAbstract

public boolean isAbstract()
Allows to know if the current class is an abstract class or not.
Specified by:
isAbstract in interface Class
Returns:
true, if the current class is an abstract class, and false, if the current class is not abstract

getName

public java.lang.String getName()
Allows to know the name of the current class object.
Specified by:
getName in interface Class
Returns:
the string representation of the class name

getFQName

public java.lang.String getFQName()
Specified by:
getFQName in interface Class

getTypedElement

public TypedElement getTypedElement(java.lang.String fieldName)
Allows to obtain an existing Field. A TypedElement is a class field, and this method finds a field with its name (fieldName). This method is a generic method to return a TypedElement object. The field can be hidden or not.
Specified by:
getTypedElement in interface Class
Parameters:
fieldName - the name of the class field
Returns:
a field object. If the field does not exist, null is returned.

createNameDef

public NameDef createNameDef()
Creates a new NameDef object for the current Class object. Here we can define if the namedef is defined outside jorm or not. In the case where the namedef is already defined for the current class, the old one is used and returned.
Specified by:
createNameDef in interface Class
Parameters:
nameDefName - the name of the nameDef read in the persistence description file
isSystem - true, the namedef is defined outside jorm, and false, the namedef is define inside jorm
Returns:
a new object used to describe the PName projection for the current Class

getNameDef

public NameDef getNameDef(java.lang.String mappingName)
Returns a NameDef object from a given mapperName and mappingName. If the namedef does not exist, null is returned.
Specified by:
getNameDef in interface Class
Parameters:
mappingName - the name of the mapping
Returns:
an existing namedef object if exists, either null

iterateNameDef

public java.util.Iterator iterateNameDef()
Returns an iterator on existing NameDef for the current Class. This method returns an empty iterator if no namedef exists in this Class.
Specified by:
iterateNameDef in interface Class
Returns:
an iterator on NameDef, or an empty iterator if no namedef is defined

createPrimitiveElement

public PrimitiveElement createPrimitiveElement(java.lang.String fieldName,
                                               PType type)
Allows to obtain a new PrimitiveElement from a class field name an its type. A PrimitiveElement is a Class field. If the class field already exists, it is returned.
Specified by:
createPrimitiveElement in interface Class
Parameters:
fieldName - the name of the primitive field
type - the PType of the primitive field
Returns:
a new PrimitiveElement object, or the existing one if already defined

createHiddenField

public ScalarField createHiddenField(java.lang.String fieldName,
                                     PType type)
Creates a new scalar field and adds it to the list of hidden fields. If the field already exists, it is returned, else a new one is built.
Specified by:
createHiddenField in interface Class
Parameters:
fieldName - the name of the field to create
type - the type of the field to create
Returns:
a new ScalarField object if this object does not already exist

createClassRef

public ClassRef createClassRef(java.lang.String fieldName,
                               Class class_)
Allows to obtain a new ClassRef from a field name an its class. A ClassRef object is a field which is represented by a reference to a Class. If the field already exists, it is returned.
Specified by:
createClassRef in interface Class
Parameters:
fieldName - the name of the field
className - the string representation of the class which represents the reference of the field
Returns:
a new ClassRef object, or the existing one if already defined

createGenClassRef

public GenClassRef createGenClassRef(java.lang.String fieldName,
                                     java.lang.String genName)
Allows to obtain a new GenClassRef from a field name an its generic class. A GenClassRef object is a field which is represented by a reference to a generic class. If the field already exists, it is returned.
Specified by:
createGenClassRef in interface Class
Parameters:
fieldName - the name of the field
genName - the GenClass object which represents the reference of the field
Returns:
a new GenClassRef object, or the existing one if already defined

iterateField

public java.util.Iterator iterateField()
Returns an iterator on existing class fields. If no field is defined, an empty iterator is returned. This iterator contains PrimitiveElements, ClassRef and GenClassRef objects. The top level object is TypedElement.
Specified by:
iterateField in interface Class
Returns:
an iterator on fields, or null if there is no defined field

listField

protected java.util.Collection listField()
returns an ArrayList which contains the current fields.
Returns:
a list of current fields

iterateAllField

public java.util.Iterator iterateAllField()
Returns an iterator on existing class fields + fields from super classes. This iterator contains PrimitiveElement, ClassRef and GenClassRef objects. This iterator does not contains the hiddenfield of the class.
Specified by:
iterateAllField in interface Class
Returns:
an iterator on all defined fields, plus fields from super

getAllFields

public java.util.Collection getAllFields()

iterateAllHiddenField

public java.util.Iterator iterateAllHiddenField()
Provides an iterator over the all the hiddenfield of the class including inherited fields.
Specified by:
iterateAllHiddenField in interface Class
Returns:
the iterator embeding scalarfield object describing the hiddenfields.

iterateHiddenField

public java.util.Iterator iterateHiddenField()
return an iterator over the hiddenfield of the class definition.
Specified by:
iterateHiddenField in interface Class
Following copied from interface: org.objectweb.jorm.metainfo.api.Class
Returns:
the iterator embeding scalarfield object describing the hiddenfields.

getHiddenField

public ScalarField getHiddenField(java.lang.String fieldName)
retrieve an hiddenfield from its name.
Specified by:
getHiddenField in interface Class
Following copied from interface: org.objectweb.jorm.metainfo.api.Class
Parameters:
fieldname - the name of the hiddenfield.
Returns:
the scalarfield object describing the hiddenfield or null if the field does not exist in the class.

iterateInheritedClass

public java.util.Iterator iterateInheritedClass()
Allows to obtain all the inherited classes from the current class object. This iterator contains Class objects. In the case where there is no inherited class, an empty iterator is returned.
Specified by:
iterateInheritedClass in interface Class
Returns:
an iterator on inherited classes (Class objets). If no object exists, an empty iterator is returned.

addInheritedClass

public void addInheritedClass(Class class_)
Adds a new inherited class to the list of the inherited classes for the current class object. If the class already exists, nothing is done.
Specified by:
addInheritedClass in interface Class
Parameters:
class_ - the inherited class to add to inherited classes list

getInheritedClassNumber

public int getInheritedClassNumber()
Returns the number of inherited classes for the current Class object.
Specified by:
getInheritedClassNumber in interface Class
Returns:
the number of inherited classes

getClassMapping

public ClassMapping getClassMapping(java.lang.String mapperName,
                                    java.lang.String mappingName)
Returns an existing ClassMapping object for the current class object. If the ClassMapping object does not exist, null is returned.
Specified by:
getClassMapping in interface Class
Parameters:
mapperName - the name of the mapper class name
Returns:
a ClassMapping object. If the ClassMapping does not exist for the mapper, null is returned.

createClassMapping

public ClassMapping createClassMapping(java.lang.String mapperName,
                                       java.lang.String mappingName)
Creates a new ClassMapping object for the current class. This mapping is defined by the name of the mapper, and the name of the mapping. If the ClassMapping object already exists, the existing one is returned.
Specified by:
createClassMapping in interface Class
Parameters:
mapperName - the name of the class mapper
mappingName - the name of the class mapping
Returns:
a new ClassMapping object. This object is dependent from the mapper. In the case the ClassMapping exists, it is returned.

iterateClassMapping

public java.util.Iterator iterateClassMapping()
Allows to know all the ClassMapping object used for the current class. If no ClassMapping object are defined, an empty iterator is returned.
Specified by:
iterateClassMapping in interface Class
Returns:
an Iterator object on ClassMapping object. If there is no object, an empty iterator is returned.

addAllInheritedClass

public void addAllInheritedClass(java.util.Map table)
Constructs an Map with inherited class
Specified by:
addAllInheritedClass in interface Class
Parameters:
table - the hashtable to build

getFieldRefNumber

public int getFieldRefNumber()
Returns the number of fields which are references to classes.
Specified by:
getFieldRefNumber in interface Class
Returns:
the number of fieldRef

setInherited

public void setInherited()
Specifies that this class is inherited by another one within the set of compiled ones.
Specified by:
setInherited in interface Class

isInherited

public boolean isInherited()
Tests if this class is inherited by another one.
Specified by:
isInherited in interface Class

getParent

public MetaObject getParent()
Allows to know the parent MetaObject of the current MetaObject.
Specified by:
getParent in interface MetaObject
Returns:
the MetaObject corresponding to the parent of the current object. If there is no parent, null is returned.

setParent

public void setParent(MetaObject itsParent)
Set the parent of the current meta object if it is not yet done by the constructor of the meta object
Specified by:
setParent in interface MetaObject
Parameters:
itsParent - the parent MetaObject of the current object

setLogger

public void setLogger(org.objectweb.util.monolog.api.Logger logger)
Defines a logger object.
Specified by:
setLogger in interface Loggable
Parameters:
logger - the logger object

setLoggerFactory

public void setLoggerFactory(org.objectweb.util.monolog.api.LoggerFactory loggerFactory)
Defines the logger factory to obtain new logger.
Specified by:
setLoggerFactory in interface Loggable
Parameters:
loggerFactory - the LoggerFactory object to obtain a logger object

getLogger

public org.objectweb.util.monolog.api.Logger getLogger()
Description copied from interface: Loggable
Returns a logger to an component that wants to log things.
Specified by:
getLogger in interface Loggable
Following copied from interface: org.objectweb.jorm.util.api.Loggable
Parameters:
logger - the logger object

getLoggerFactory

public org.objectweb.util.monolog.api.LoggerFactory getLoggerFactory()
Description copied from interface: Loggable
Returns a logger factory that allows the creation of new loggers.
Specified by:
getLoggerFactory in interface Loggable
Following copied from interface: org.objectweb.jorm.util.api.Loggable
Parameters:
loggerfactory - the LoggerFactory object to obtain new loggers