org.objectweb.jorm.metainfo.lib
Class BasicClass

java.lang.Object
  extended byorg.objectweb.jorm.metainfo.lib.BasicMetaObject
      extended byorg.objectweb.jorm.metainfo.lib.BasicClass
All Implemented Interfaces:
Class, Loggable, MetaObject, java.io.Serializable

public class BasicClass
extends BasicMetaObject
implements Class

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

Field Summary
 
Fields inherited from class org.objectweb.jorm.metainfo.lib.BasicMetaObject
logger, loggerFactory, parent
 
Constructor Summary
BasicClass(java.lang.String className, MetaObject parent)
          Builds a new Class object.
 
Method Summary
 void addAllInheritedClass(java.util.Map table)
          Constructs an Map with inherited class
 void addClassProject(java.lang.String projectName, ClassProject classProject)
          Adds a ClassProject object.
 void addDerivedClass(Class class_)
          Adds a new class to the list of the derived classes for the current class object.
 Extension addInheritedClass(Class class_)
          Adds a new inherited class to the list of the inherited classes for the current class object.
 ClassProject createClassProject(java.lang.String projectName)
          Creates a new ClassProject object.
 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, int size)
          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, int size)
          Allows to obtain a new PrimitiveElement from a class field name an its type.
 java.util.Collection getAllFields()
           
 java.util.Collection getAllHiddenFields()
           
protected  java.util.Collection getChildren()
           
 ClassMapping getClassMapping(java.lang.String projectName, java.lang.String mapperName)
          Returns a ClassMapping object.
 ClassProject getClassProject(java.lang.String projectName)
          Returns a ClassProject object.
 java.util.Collection getClassProjects()
          Returns a collection of ClassProject objects.
 java.util.Collection getDerivedClasses()
          Allows us to obtain all classes derived from the current class object.
 Extension getExtension(java.lang.String fqcn)
          Returns an Extension object.
 java.util.Collection getExtensions()
          Returns a collection of Extension objects.
 int getFieldRefNumber()
          Returns the number of fields which are references to classes.
 java.lang.String getFileName()
          Allows to retrieve the file name of this class MO.
 java.lang.String getFQName()
          Gets the fully qualified name (including the package name) associated with this class.
 ScalarField getHiddenField(java.lang.String fieldName)
          retrieve an hiddenfield from its name.
 Expression getInheritanceFilter(NameDef nd)
           
 int getInheritedClassNumber()
          Returns the number of inherited classes for the current Class object.
 java.lang.String getName()
          Allows to know the name of the current class object.
 NameDef getNameDef(java.lang.String name)
          Returns a NameDef object.
 java.util.Collection getNameDefs()
           
 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.
 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 iterateClassProjects()
          return an iterator over the ClassProject objects.
 java.util.Iterator iterateExtension()
          Allows us to obtain all the Extension objects from the current class object.
 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 us 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.List listField()
          returns an ArrayList which contains the current fields.
 ClassProject removeClassProject(java.lang.String projectname)
          Removes a ClassProject instance.
 TypedElement removeTypedElement(java.lang.String fieldName)
          Removes a typed element.
 void setAbstract(boolean isAbstract)
           
 void setFileName(java.lang.String filename)
          Allows to assign the file name of this class MO.
 void setInheritanceFilter(NameDef nd, Expression e)
           
 
Methods inherited from class org.objectweb.jorm.metainfo.lib.BasicMetaObject
getLogger, getLoggerFactory, getManager, getParent, setLogger, setLoggerFactory, setLoggingOnChild, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.jorm.metainfo.api.MetaObject
getParent, setParent
 

Constructor Detail

BasicClass

public BasicClass(java.lang.String className,
                  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
parent - the parent of the current object
Method Detail

getChildren

protected java.util.Collection getChildren()
Overrides:
getChildren in class BasicMetaObject

getFileName

public java.lang.String getFileName()
Allows to retrieve the file name of this class MO.

Specified by:
getFileName in interface Class
Returns:
The file name.

setFileName

public void setFileName(java.lang.String filename)
Allows to assign the file name of this class MO.

Specified by:
setFileName in interface Class
Parameters:
filename - The file name.

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

setAbstract

public void setAbstract(boolean isAbstract)
Specified by:
setAbstract in interface Class

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()
Description copied from interface: Class
Gets the fully qualified name (including the package name) associated with this class.

Specified by:
getFQName in interface Class
Returns:
the string representation of the fully qualified class name

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.

removeTypedElement

public TypedElement removeTypedElement(java.lang.String fieldName)
Removes a typed element.

Specified by:
removeTypedElement in interface Class
Parameters:
fieldName - is the name of the field to be removed
Returns:
the removed element or null if the field has not been found.

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
Returns:
a new object used to describe the PName projection for the current Class

getNameDef

public NameDef getNameDef(java.lang.String name)
Returns a NameDef object. If the namedef does not exist, null is returned.

Specified by:
getNameDef in interface Class
Parameters:
name - the name of a NameDef object.
Returns:
a namedef object, else null is returned.

getNameDefs

public java.util.Collection getNameDefs()
Specified by:
getNameDefs in interface Class

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

getInheritanceFilter

public Expression getInheritanceFilter(NameDef nd)
Specified by:
getInheritanceFilter in interface Class
Returns:
the filter expression (Medor expression) permitting to known if instance of the parent class is in fact an instance of the current persistent class. The filter uses the field name (composite field in case of a composite or the field class name). If the current class has no parent, then this method return null;

setInheritanceFilter

public void setInheritanceFilter(NameDef nd,
                                 Expression e)
Specified by:
setInheritanceFilter in interface Class
Parameters:
e - is the filter expression (Medor expression) permitting to known if instance of the parent class is in fact an instance of the current persistent class. The filter uses the field name (composite field in case of a composite or the field class name).

createPrimitiveElement

public PrimitiveElement createPrimitiveElement(java.lang.String fieldName,
                                               PType type,
                                               int size)
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,
                                     int size)
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
class_ - 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.List 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.

getAllHiddenFields

public java.util.Collection getAllHiddenFields()

iterateHiddenField

public java.util.Iterator iterateHiddenField()
return an iterator over the hiddenfield of the class definition.

Specified by:
iterateHiddenField in interface Class
Returns:
the iterator containing the hiddenfield.

getHiddenField

public ScalarField getHiddenField(java.lang.String fieldName)
retrieve an hiddenfield from its name.

Specified by:
getHiddenField in interface Class
Parameters:
fieldName - the name of the hiddenfield.
Returns:
the hiddenfield or null if the field does not exist.

iterateInheritedClass

public java.util.Iterator iterateInheritedClass()
Allows us 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.

getDerivedClasses

public java.util.Collection getDerivedClasses()
Description copied from interface: Class
Allows us to obtain all classes derived from the current class object. This collection contains Class objects. In the case where there is no derived class, an empty collection is returned.

Specified by:
getDerivedClasses in interface Class
Returns:
a collection on derived classes (Class objets). If no object exists, an empty collection is returned.

iterateExtension

public java.util.Iterator iterateExtension()
Allows us to obtain all the Extension objects from the current class object. If there is no Extension object, an empty iterator is returned.

Specified by:
iterateExtension in interface Class
Returns:
an iterator on Extension classes. If no object exists, an empty iterator is returned.

getExtensions

public java.util.Collection getExtensions()
Returns a collection of Extension objects.

Specified by:
getExtensions in interface Class
Returns:
a collection.

getExtension

public Extension getExtension(java.lang.String fqcn)
Returns an Extension object.

Specified by:
getExtension in interface Class
Parameters:
fqcn - a full qualified class name.
Returns:
an Extension object.

addInheritedClass

public Extension 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
Returns:
an Extension object.

addDerivedClass

public void addDerivedClass(Class class_)
Description copied from interface: Class
Adds a new class to the list of the derived classes for the current class object. If the class already exists, nothing is done.

Specified by:
addDerivedClass 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

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

getClassProject

public ClassProject getClassProject(java.lang.String projectName)
Returns a ClassProject object.

Specified by:
getClassProject in interface Class
Parameters:
projectName - a project name.
Returns:
a ClassProject object.

getClassMapping

public ClassMapping getClassMapping(java.lang.String projectName,
                                    java.lang.String mapperName)
Returns a ClassMapping object.

Specified by:
getClassMapping in interface Class
Parameters:
projectName - a project name, mappername a mapper name.
Returns:
a ClassMapping object.

getClassProjects

public java.util.Collection getClassProjects()
Returns a collection of ClassProject objects.

Specified by:
getClassProjects in interface Class
Returns:
a collection.

iterateClassProjects

public java.util.Iterator iterateClassProjects()
return an iterator over the ClassProject objects.

Returns:
an iterator.

addClassProject

public void addClassProject(java.lang.String projectName,
                            ClassProject classProject)
Adds a ClassProject object.

Specified by:
addClassProject in interface Class
Parameters:
projectName - a project name, classProject a ClassProject object.

createClassProject

public ClassProject createClassProject(java.lang.String projectName)
Creates a new ClassProject object.

Specified by:
createClassProject in interface Class
Parameters:
projectName - the name of the project.
Returns:
a new ClassProject object, or an existing one.

removeClassProject

public ClassProject removeClassProject(java.lang.String projectname)
Removes a ClassProject instance.

Specified by:
removeClassProject in interface Class
Parameters:
projectname - is the name of removed ClassProject
Returns:
The removed ClassProject