org.objectweb.medor.query.jorm.lib
Class BasicJormExtent

java.lang.Object
  |
  +--org.objectweb.medor.query.jorm.lib.BasicJormExtent
All Implemented Interfaces:
Cloneable, java.lang.Cloneable, JormExtent, QueryLeaf, QueryTree, TupleStructure
Direct Known Subclasses:
ClassExtent, GenClassExtent

public abstract class BasicJormExtent
extends java.lang.Object
implements JormExtent, QueryLeaf, TupleStructure

This class is the common implementation of the jorm leaves (ClassExtent, GenClassExtent).

Author:
S.Chassande-Barrioz

Field Summary
protected  java.util.ArrayList fields
          List of fields
protected  PNameField identifier
           
protected  PMapper mapper
          The mapper of the extent.
protected  DataStore myStore
          The datastore of the extent
protected  java.lang.String name
          Node name
protected  java.util.HashMap name2field
          List of fields indexed by their name
protected  java.lang.String pnFieldName
          Name of the field which is the PName of the extent
protected  java.lang.String projectName
           
 
Constructor Summary
BasicJormExtent(java.lang.String _name, java.lang.String pnFieldName)
           
 
Method Summary
 java.lang.Object clone()
           
 boolean contains(Field f)
          Checks whether a given input Field is present in the current TupleStructure.
 boolean contains(java.lang.String fieldName)
          Checks whether the current TupleStructure has a field of a given name.
 DataStore getDataStore()
          Methods inherited from QueryLeaf
 boolean getDistinct()
          Tests whether the results should be distinct or not.
 Field getField(int fieldrank)
          Returns the Field of a given rank in the current TupleStructure.
 Field getField(java.lang.String fieldname)
          Returns a Field object present in this TupleStructure given its name.
 java.lang.String getFieldName(java.lang.String nodeName, java.lang.String fieldName)
           
 int getFieldRank(Field f)
          Returns the rank of a given Field in the current TupleStructure.
 Field[] getFields()
          Returns the array of Fields in the current TupleStructure.
 JormField getIdentifierField()
           
abstract  java.lang.String getJormName()
           
 java.lang.String getName()
          It returns the name of the query tree.
 OrderField[] getOrderBy()
          Returns the array of OrderFields indicating how the result should be ordered.
 PMapper getPMapper()
           
 java.lang.String getPNameFieldName()
           
 java.lang.String getProjectName()
           
 int getSize()
          Returns the size of the current TupleStructure, ie the number of Fields.
 TupleStructure getTupleStructure()
          Methods inherited from QueryTree
 java.util.Iterator iterateFields()
           
 void setDataStore(DataStore ds)
           
 void setDistinct(boolean d)
          Indicates whether evaluating the QueryTree should return unique results (duplicate elimination) or not.
 void setOrderBy(OrderField[] orderfields)
          Sets the OrderBy array of OrderFields.
 void setPMapper(PMapper m, java.lang.String projectName)
           
 void setProjectName(java.lang.String projectName)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.medor.query.jorm.api.JormExtent
getMetaObject
 

Field Detail

name

protected java.lang.String name
Node name


pnFieldName

protected java.lang.String pnFieldName
Name of the field which is the PName of the extent


identifier

protected PNameField identifier

fields

protected java.util.ArrayList fields
List of fields


name2field

protected java.util.HashMap name2field
List of fields indexed by their name


myStore

protected DataStore myStore
The datastore of the extent


mapper

protected PMapper mapper
The mapper of the extent.


projectName

protected java.lang.String projectName
Constructor Detail

BasicJormExtent

public BasicJormExtent(java.lang.String _name,
                       java.lang.String pnFieldName)
Method Detail

iterateFields

public java.util.Iterator iterateFields()

getFieldName

public java.lang.String getFieldName(java.lang.String nodeName,
                                     java.lang.String fieldName)

getPMapper

public PMapper getPMapper()
Specified by:
getPMapper in interface JormExtent

setPMapper

public void setPMapper(PMapper m,
                       java.lang.String projectName)
Specified by:
setPMapper in interface JormExtent

getProjectName

public java.lang.String getProjectName()
Specified by:
getProjectName in interface JormExtent

setProjectName

public void setProjectName(java.lang.String projectName)
Specified by:
setProjectName in interface JormExtent

setDataStore

public void setDataStore(DataStore ds)
Specified by:
setDataStore in interface JormExtent

getPNameFieldName

public java.lang.String getPNameFieldName()
Specified by:
getPNameFieldName in interface JormExtent

getJormName

public abstract java.lang.String getJormName()
Specified by:
getJormName in interface JormExtent

getIdentifierField

public JormField getIdentifierField()
Specified by:
getIdentifierField in interface JormExtent

getName

public java.lang.String getName()
Description copied from interface: QueryTree
It returns the name of the query tree.

Specified by:
getName in interface QueryTree

getTupleStructure

public TupleStructure getTupleStructure()
Methods inherited from QueryTree

Specified by:
getTupleStructure in interface QueryTree

getDataStore

public DataStore getDataStore()
Methods inherited from QueryLeaf

Specified by:
getDataStore in interface QueryLeaf

clone

public java.lang.Object clone()
Specified by:
clone in interface Cloneable
Overrides:
clone in class java.lang.Object

getFields

public Field[] getFields()
Description copied from interface: TupleStructure
Returns the array of Fields in the current TupleStructure.

Specified by:
getFields in interface TupleStructure
Returns:
the array of Fields in the current TupleStructure.

getField

public Field getField(java.lang.String fieldname)
               throws MedorException
Description copied from interface: TupleStructure
Returns a Field object present in this TupleStructure given its name.

Specified by:
getField in interface TupleStructure
Parameters:
fieldname - the name of the searched Field
Returns:
the Field in the current TupleStructure which has the input name.
Throws:
MedorException - if no Field corresponds to the input name.

getField

public Field getField(int fieldrank)
               throws MedorException
Description copied from interface: TupleStructure
Returns the Field of a given rank in the current TupleStructure.

Specified by:
getField in interface TupleStructure
Parameters:
fieldrank - the rank of the searched Field in the current TupleStructure
Returns:
the Field in the current TupleStructure corresponding to the input rank.
Throws:
MedorException - if the input rank is too large.

getFieldRank

public int getFieldRank(Field f)
                 throws MedorException
Description copied from interface: TupleStructure
Returns the rank of a given Field in the current TupleStructure.

Specified by:
getFieldRank in interface TupleStructure
Parameters:
f - the Field for which the rank is searched.
Returns:
the rank of the input Field in the current TupleStructure.
Throws:
MedorException - if there is no such Field in the current TupleStructure.

getSize

public int getSize()
Description copied from interface: TupleStructure
Returns the size of the current TupleStructure, ie the number of Fields.

Specified by:
getSize in interface TupleStructure
Returns:
the number of Fields in the current TupleStructure.

contains

public boolean contains(Field f)
Description copied from interface: TupleStructure
Checks whether a given input Field is present in the current TupleStructure.

Specified by:
contains in interface TupleStructure
Parameters:
f - the Field for which to check whether it is present in the current TupleStructure.
Returns:
true if the Field is part of the current TupleStructure, false otherwise.

contains

public boolean contains(java.lang.String fieldName)
Description copied from interface: TupleStructure
Checks whether the current TupleStructure has a field of a given name.

Specified by:
contains in interface TupleStructure
Parameters:
fieldName - the Field name for which to check whether the current TupleStructure contains a Field.
Returns:
true if the current TupleStructure contains a Field of the input name, false otherwise.

setDistinct

public void setDistinct(boolean d)
                 throws MedorException
Description copied from interface: QueryTree
Indicates whether evaluating the QueryTree should return unique results (duplicate elimination) or not.

The default should be that duplicates are not eliminated (distinct is false).

Specified by:
setDistinct in interface QueryTree
Parameters:
d - is true if duplicates should be eliminated, false otherwise.
Throws:
MedorException - if the distinct operation is not supported.

getDistinct

public boolean getDistinct()
Description copied from interface: QueryTree
Tests whether the results should be distinct or not.

Specified by:
getDistinct in interface QueryTree
Returns:
true if there results should be distinct, false otherwise.

setOrderBy

public void setOrderBy(OrderField[] orderfields)
                throws MedorException
Description copied from interface: QueryTree
Sets the OrderBy array of OrderFields.

This array indicates the fields by which the results should be ordered.

Like for filters assigned to QueryNodes, the Fields used for ordering must belong to children of the current QueryTree.

A noticeable exception is the case of RdbExpQueryLeaves, where ordering fields are fields of the QueryLeaf itself.

Specified by:
setOrderBy in interface QueryTree
Parameters:
orderfields - the array of OrderFields indicating the ordering in which the result should be returned.
Throws:
MedorException - if ordering is not supported.

getOrderBy

public OrderField[] getOrderBy()
Description copied from interface: QueryTree
Returns the array of OrderFields indicating how the result should be ordered.

Specified by:
getOrderBy in interface QueryTree
Returns:
the array of OrderFields.