org.objectweb.jorm.metainfo.lib
Class BasicGenClassRef

java.lang.Object
  |
  +--org.objectweb.jorm.metainfo.lib.BasicGenClassRef
All Implemented Interfaces:
GenClassRef, Loggable, MetaObject, Reference, java.io.Serializable, TypedElement

public class BasicGenClassRef
extends java.lang.Object
implements GenClassRef, Loggable

BasicGenClassRef defines a reference to a generic class which is class field. This object is created by the GenClass object to define its fields.

Author:
X. Spengler
See Also:
Serialized Form

Constructor Summary
BasicGenClassRef(java.lang.String genClassName, java.lang.String name, MetaObject parent)
          Builds a new BasicGenClassRef object.
 
Method Summary
 ClassMapping createClassMapping(java.lang.String mapperName, java.lang.String mappingName)
          Creates a new ClassMapping object for the current reference.
 ClassRef createClassRef(Class clazz)
          Creates a new ClassRef object, and attach it to the current GenClassRef This method must be used when the recursion is finished (we are on final object which is a ClassRef).
 GenClassRef createGenClassRef(java.lang.String genClassRefName)
          Creates a new GenClassRef object.
 ScalarField createHiddenField(java.lang.String fieldName, PType type)
          Create a new hidden field for the refgenclass.
 NameDef createNameDef()
          Creates a new NameDef object for the current reference class object.
 PrimitiveElement createPrimitiveElement(PType type)
          Creates a new PrimitiveElement object, and attach it to the current GenClassRef This method must be used when the recursion is finished (we are on final object which is a PrimitiveElement).
 NameDef createRefNameDef()
          Creates a new NameDef object for the new GenClassRef object.
 ClassMapping getClassMapping(java.lang.String mapperName, java.lang.String mappingName)
          Returns an existing ClassMapping object for the current reference object from a given mapper name and mapping name.
 ClassRef getClassRef()
          Returns the ClassRef object which defines the current GenClassRef object.
 GenClass getGenClass()
          Returns the underlying GenClass object which describes the generic class object used.
 java.lang.String getGenClassName()
          Returns the name of the GenClass object.
 GenClassRef getGenClassRef()
          Returns the GenClassRef object which defines the current GenClassRef object.
 ScalarField getHiddenField(java.lang.String fieldName)
          retrieve an hiddenfield from its name.
 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()
          Returns the name of the current typed element.
 NameDef getNameDef(java.lang.String mappingName)
          Returns a NameDef object from a given mappingName.
 MetaObject getParent()
          Allows to know the parent MetaObject of the current MetaObject.
 PrimitiveElement getPrimitiveElement()
          Returns the PrimitiveElement object which defines the current GenClassRef object.
 NameDef getRefNameDef(java.lang.String mappingName)
          Returns a NameDef object from a given mapperName and mappingName.
 PType getType()
          Allows to know the type of the field.
 boolean isClassRef()
          Allows to know if the current object is a reference to a Class or not.
 boolean isGenClassRef()
          Allows to know if the current object is a reference to a generic class or not.
 boolean isPrimitive()
          Allows to know if the current object is primitive or not (final and "basic").
 java.util.Iterator iterateClassMapping()
          Allows to know all the ClassMapping objects used for the current reference.
 java.util.Iterator iterateHiddenField()
          return an iterator over the hiddenfield of the refgenclass definition.
 java.util.Iterator iterateNameDef()
          Returns an iterator on existing NameDef for the current Class.
 java.util.Iterator iterateRefNameDef()
          Returns an iterator on existing NameDef of GenClassRef object.
 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

BasicGenClassRef

public BasicGenClassRef(java.lang.String genClassName,
                        java.lang.String name,
                        MetaObject parent)
Builds a new BasicGenClassRef object. This object is defined by its name, the reference to the generic class and its parent.
Parameters:
genClassName - the name of the generic class reference
name - the string representation of the generic class field name
parent - the parent of the current object
Method Detail

createPrimitiveElement

public PrimitiveElement createPrimitiveElement(PType type)
Creates a new PrimitiveElement object, and attach it to the current GenClassRef This method must be used when the recursion is finished (we are on final object which is a PrimitiveElement).
Specified by:
createPrimitiveElement in interface GenClassRef
Parameters:
type - is the PType of the primitive element which will be created
Returns:
PrimitiveElement the primitive element which defines the current GenClassRef object. This object is the final object of the recursion.

createClassRef

public ClassRef createClassRef(Class clazz)
Creates a new ClassRef object, and attach it to the current GenClassRef This method must be used when the recursion is finished (we are on final object which is a ClassRef).
Specified by:
createClassRef in interface GenClassRef
Parameters:
clazz - the reference to the Class object which defines the current GenClassRef object. This object is the final object of the recursion.
Returns:
ClassRef a new ClassRef object

createGenClassRef

public GenClassRef createGenClassRef(java.lang.String genClassRefName)
Creates a new GenClassRef object. This method must be used when the recursion is not finished (we are on not final object).
Specified by:
createGenClassRef in interface GenClassRef
Parameters:
genClassRefName - the name of the generic class used to create a new GenClassRef object
Returns:
a new GenClassRef object

getPrimitiveElement

public PrimitiveElement getPrimitiveElement()
Returns the PrimitiveElement object which defines the current GenClassRef object. This method is used after a call to isPrimitive() method, to determine if the current object is a "basic" type.
Specified by:
getPrimitiveElement in interface GenClassRef
Returns:
the current type of the field. This method always returns a PType object, and can not return null value because of the previous test.

getClassRef

public ClassRef getClassRef()
Returns the ClassRef object which defines the current GenClassRef object. This method is used after a call to isClassRef() method, to determine if the current object is defined by a final class or not.
Specified by:
getClassRef in interface GenClassRef
Returns:
the final Class which describes the type of the object which defines the GenClassRef object. This method always returns a Class, and can not return null value because of the previous test.

getGenClassRef

public GenClassRef getGenClassRef()
Returns the GenClassRef object which defines the current GenClassRef object. This object exists when it is in a recursion. This method is used after a call to isGenClassRef() method, to determine if the current object is a reference to a generic class or not.
Specified by:
getGenClassRef in interface GenClassRef
Returns:
the underlying reference to the generic class. This method always returns a GenClassRef, and can not return null value because of the previous test.

isPrimitive

public boolean isPrimitive()
Allows to know if the current object is primitive or not (final and "basic").
Specified by:
isPrimitive in interface GenClassRef
Returns:
true, if the current object is primitive, else false, if the object is not primitive (either a reference to a Class, or a reference to a generic class).

isClassRef

public boolean isClassRef()
Allows to know if the current object is a reference to a Class or not.
Specified by:
isClassRef in interface GenClassRef
Returns:
true, if the object is a reference to a Class, else false, if the object is not a reference to a Class (either a primitive object, or a reference to a generic class).

isGenClassRef

public boolean isGenClassRef()
Allows to know if the current object is a reference to a generic class or not.
Specified by:
isGenClassRef in interface GenClassRef
Returns:
true, if the object is a reference to a generic class, else false, if the object is not a reference to a generic class (either a primitive object, or a reference to a class).

getRefNameDef

public NameDef getRefNameDef(java.lang.String mappingName)
Description copied from interface: GenClassRef
Returns a NameDef object from a given mapperName and mappingName. If the corresponding NameDef does not exist, null is returned.
Specified by:
getRefNameDef in interface GenClassRef
Following copied from interface: org.objectweb.jorm.metainfo.api.GenClassRef
Parameters:
mapperName - the name of the mapper
mappingName - the name of the mapping
Returns:
an existing namedef object if exists, either null

createRefNameDef

public NameDef createRefNameDef()
Creates a new NameDef object for the new GenClassRef object. If the specified namedef object already exists, it is returned, else a new NameDef object is created.
Specified by:
createRefNameDef in interface GenClassRef
Parameters:
nameDefName - the name of the nameDef read in the persistence description file
isSystem - true, the namedef is defined outside jorm, else false, the namedef is define inside jorm
Returns:
a new object used to describe the PName projection for the current Class, or an existing object if already defined

iterateRefNameDef

public java.util.Iterator iterateRefNameDef()
Returns an iterator on existing NameDef of GenClassRef object. If no NameDef exists, an empty iterator is returned.
Specified by:
iterateRefNameDef in interface GenClassRef
Returns:
an iterator on NameDef object

createHiddenField

public ScalarField createHiddenField(java.lang.String fieldName,
                                     PType type)
Create a new hidden field for the refgenclass.
Specified by:
createHiddenField in interface GenClassRef

iterateHiddenField

public java.util.Iterator iterateHiddenField()
return an iterator over the hiddenfield of the refgenclass definition.
Specified by:
iterateHiddenField in interface GenClassRef

getHiddenField

public ScalarField getHiddenField(java.lang.String fieldName)
retrieve an hiddenfield from its name.
Specified by:
getHiddenField in interface GenClassRef

getGenClass

public GenClass getGenClass()
Returns the underlying GenClass object which describes the generic class object used.
Specified by:
getGenClass in interface GenClassRef
Returns:
the underlying generic class object

getClassMapping

public ClassMapping getClassMapping(java.lang.String mapperName,
                                    java.lang.String mappingName)
Returns an existing ClassMapping object for the current reference object from a given mapper name and mapping name.
Specified by:
getClassMapping in interface GenClassRef
Parameters:
mapperName - the name of the mapper reference name
mappingName - the name of the mapping reference 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 reference. This mapping is defined by the name of the mapper, and the name of the mapping.
Specified by:
createClassMapping in interface GenClassRef
Parameters:
mapperName - the name of the reference mapper
mappingName - the name of the reference mapping
Returns:
a new ClassMapping object. This object is dependent from the mapper.

iterateClassMapping

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

getGenClassName

public java.lang.String getGenClassName()
Returns the name of the GenClass object.
Specified by:
getGenClassName in interface GenClassRef

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

createNameDef

public NameDef createNameDef()
Creates a new NameDef object for the current reference class object. If this NameDef already exists for the current object, it is returned, in other case, a new NameDef object is created and returned.
Specified by:
createNameDef in interface Reference
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 name projection for the current reference class, or an existing one if it already exists

getNameDef

public NameDef getNameDef(java.lang.String mappingName)
Returns a NameDef object from a given mappingName. If the namedef does not exist, null is returned.
Specified by:
getNameDef in interface Reference
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 Reference
Returns:
an iterator on NameDef, or an empty iterator if no namedef is defined

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

getName

public java.lang.String getName()
Returns the name of the current typed element.
Specified by:
getName in interface TypedElement
Returns:
the string representation of the typed element

getType

public PType getType()
Allows to know the type of the field.
Specified by:
getType in interface TypedElement
Returns:
a PType object which defines the type of the current field