org.objectweb.jorm.metainfo.lib
Class BasicGenClassRef

java.lang.Object
  extended byorg.objectweb.jorm.metainfo.lib.BasicMetaObject
      extended byorg.objectweb.jorm.metainfo.lib.BasicGenClassRef
All Implemented Interfaces:
java.lang.Comparable, GenClassRef, Loggable, MetaObject, Reference, java.io.Serializable, TypedElement

public class BasicGenClassRef
extends BasicMetaObject
implements GenClassRef, java.lang.Comparable

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

Field Summary
 
Fields inherited from class org.objectweb.jorm.metainfo.lib.BasicMetaObject
debug, logger, loggerFactory, parent
 
Constructor Summary
BasicGenClassRef(java.lang.String genClassName, java.lang.String name, MetaObject parent)
          Builds a new BasicGenClassRef object.
 
Method Summary
 void addIndexField(java.lang.String indexFieldName)
           
 int compareTo(java.lang.Object o)
           
 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, int size, int scale)
          Create a new hidden field for the refgenclass.
 NameDef createIdNameDef()
          Creates a new NameDef object for the new GenClassRef object.
 ScalarField createIndexField(java.lang.String indexFieldName, PType type, int size, int scale)
          Returns a new ScalarField object.
 PrimitiveElement createPrimitiveElement(PType type, int size, int scale)
          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 current reference class object.
protected  java.util.Collection getChildren()
           
 ClassRef getClassRef()
          Returns the ClassRef object which defines the current GenClassRef object.
 java.lang.String getGenClassId()
          Returns the id of the GenClass object.
 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.
 java.util.Collection getHiddenFields()
          return an iterator over the hiddenfield of the refgenclass definition.
 java.util.Collection getIdNameDef()
          Returns an iterator on existing NameDef of GenClassRef object.
 NameDef getIdNameDef(java.lang.String name)
          Returns a NameDef object.
 ScalarField getIndexField()
          Returns the ScalarField object corresponding to the index field.
 java.util.Collection getIndexFields()
          Allows to know all the existing index field for the current generic class.
 java.lang.String getName()
          Returns the name of the current typed element.
 PrimitiveElement getPrimitiveElement()
          Returns the PrimitiveElement object which defines the current GenClassRef object.
 java.util.Collection getRefNameDef()
          Returns an iterator on existing NameDef for the current Class.
 NameDef getRefNameDef(java.lang.String name)
          Returns a NameDef object.
 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").
 TypedElement removeTypedElement(java.lang.String fieldName)
          Removes the primitive element.
 
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

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

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable

createPrimitiveElement

public PrimitiveElement createPrimitiveElement(PType type,
                                               int size,
                                               int scale)
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.

createIndexField

public ScalarField createIndexField(java.lang.String indexFieldName,
                                    PType type,
                                    int size,
                                    int scale)
Returns a new ScalarField object.

Parameters:
indexFieldName - the name of the index field
type - the type of the index field
Returns:
a new ScalarField object for the index field

getIndexField

public ScalarField getIndexField()
Returns the ScalarField object corresponding to the index field.

Returns:
a ScalarField object.

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.

removeTypedElement

public TypedElement removeTypedElement(java.lang.String fieldName)
Description copied from interface: GenClassRef
Removes the primitive element.

Specified by:
removeTypedElement in interface GenClassRef
Parameters:
fieldName - is the name of the field to be removed
Returns:
the removed primitive element.

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).

createIdNameDef

public NameDef createIdNameDef()
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:
createIdNameDef in interface GenClassRef
Returns:
a new object used to describe the PName projection for the current Class, or an existing object if already defined

getIdNameDef

public java.util.Collection getIdNameDef()
Returns an iterator on existing NameDef of GenClassRef object. If no NameDef exists, an empty iterator is returned.

Specified by:
getIdNameDef in interface GenClassRef
Returns:
an iterator on NameDef object

createHiddenField

public ScalarField createHiddenField(java.lang.String fieldName,
                                     PType type,
                                     int size,
                                     int scale)
Create a new hidden field for the refgenclass.

Specified by:
createHiddenField in interface GenClassRef
Returns:
the ScalarField

getHiddenFields

public java.util.Collection getHiddenFields()
return an iterator over the hiddenfield of the refgenclass definition.

Specified by:
getHiddenFields in interface GenClassRef
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 GenClassRef
Returns:
the hiddenfield.

getGenClassName

public java.lang.String getGenClassName()
Returns the name of the GenClass object.

Specified by:
getGenClassName in interface GenClassRef
Returns:
the name of the GenClassRef object

getGenClassId

public java.lang.String getGenClassId()
Description copied from interface: GenClassRef
Returns the id of the GenClass object. ("Set/List/String", ..)

Specified by:
getGenClassId in interface GenClassRef
Returns:
the id of the GenClassRef object

createRefNameDef

public NameDef createRefNameDef()
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:
createRefNameDef in interface Reference
Returns:
a new object used to describe the name projection for the current reference class, or an existing one if it already exists

getRefNameDef

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

Specified by:
getRefNameDef in interface Reference
Parameters:
name - the name of the namedef.
Returns:
an existing namedef object,else null is returned.

getIdNameDef

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

Specified by:
getIdNameDef in interface GenClassRef
Parameters:
name - the name of the namedef.
Returns:
an existing namedef object,else null is returned.

getRefNameDef

public java.util.Collection getRefNameDef()
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:
getRefNameDef in interface Reference
Returns:
an iterator on NameDef, or an empty iterator if no namedef is defined

addIndexField

public void addIndexField(java.lang.String indexFieldName)
Specified by:
addIndexField in interface GenClassRef
Parameters:
indexFieldName - the name of the index field

getIndexFields

public java.util.Collection getIndexFields()
Allows to know all the existing index field for the current generic class. This iterator contains PrimitiveElement objects. If no index field exists, an empty iterator is returned.

Specified by:
getIndexFields in interface GenClassRef
Returns:
an Iterator on index field (PrimitiveElement). If there is no index field to return, an empty iterator is returned.

getChildren

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

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