Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.makumba.providers.query.oql
Class QueryAST

    java.lang.Object
      antlr.BaseAST
          antlr.CommonAST
              org.makumba.providers.query.oql.OQLAST
                  org.makumba.providers.query.oql.QueryAST

All Implemented Interfaces:
  antlr.collections.AST, Serializable, QueryAnalysis

    public class QueryAST

extends OQLAST
implements QueryAnalysis

an OQL query, writes out the translated SQL query

See Also:
  Serialized Form

Nested Class Summary
`(package private) class` | `QueryAST.Join` the four elements of a join: label1.field1 = label2.field2

Field Summary
`(package private) antlr.collections.AST` | `afterWhereAST` markers in the chain of tokens for the different parts of the query
`(package private) Hashtable<String,String>` | `aliases` support aliases in query
`(package private) Vector<antlr.collections.AST>` | `expressionIdentifiers` makumba identifiers label.field or label detected inside expressions
`(package private) Vector<antlr.collections.AST>` | `expressions` expressions, for type analysis
`(package private) antlr.collections.AST` | `firstProjection` markers in the chain of tokens for the different parts of the query
`(package private) antlr.collections.AST` | `fromAST` markers in the chain of tokens for the different parts of the query
`(package private) Hashtable<String,DataDefinition>` | `fromLabels` labels explicitly defined in OQL FROM
`(package private) antlr.collections.AST` | `groupAST` markers in the chain of tokens for the different parts of the query
`(package private) Hashtable<String,String>` | `joinNames` finder for joins in the form label.field, used in order not to repeat the same join
`(package private) Vector<QueryAST.Join>` | `joins` the joins needed out of the label.field from this query
`(package private) Hashtable<String,DataDefinition>` | `labels` associate each label to its makumba type
`(package private) String` | `oneProjectionLabel` label of the projection, in case of an all-table projection, doesn't work presently
`(package private) antlr.collections.AST` | `orderAST` markers in the chain of tokens for the different parts of the query
`(package private) String` | `originalQuery`
`(package private) Vector<ParamAST>` | `parameters` parameters for this query
`(package private) DataDefinition` | `paramInfo` the parameter types
`(package private) Vector<String>` | `projectionLabels` labels of the projections, given or attributed automatically
`(package private) Hashtable<String,Projection>` | `projectionLabelSearch` searcher for projection labels
`(package private) Vector<Projection>` | `projections` projections
`(package private) DataDefinition` | `resultInfo` the type of the returned result
`(package private) QueryAST` | `superQuery` the enclosing query, never tested
`(package private) antlr.collections.AST` | `whereAST` markers in the chain of tokens for the different parts of the query

Fields inherited from class org.makumba.providers.query.oql.OQLAST
`extraInfo, makumbaType, tree`

Fields inherited from class antlr.BaseAST
`down, right`

Constructor Summary
`QueryAST()`
`QueryAST(antlr.Token t)`

Method Summary
`void` | `addExpression(antlr.collections.AST token)`
`void` | `addExpressionIdentifier(antlr.collections.AST token)` add a makumba identifier
`void` | `addFrom(String frm, String label, boolean leftJoin)` add a FROM projection, if it's just a label declaration, associate the label with the type, otherwise (label.field) generate the needed joins
`(package private) String` | `addJoin(String l1, String f1, String name, String f2, DataDefinition type, boolean leftJoin)` make a new join with the name and associate teh label with the type
`void` | `addParameter(ParamAST p)` add a parameter during parsing
`void` | `addProjection(Projection p)` add a projection during parsing
`(package private) void` | `computeExpressionTypes()` treat the makumba identifiers, generate the needed joins
`void` | `computeParameterTypes()`
`(package private) void` | `computeProjectionTypes()` treat the existing projections, check the type of each and make up the returned type
`protected String` | `getFieldName(String label, String field, NameResolver nr)` return the database-level name of the given field of the given label
`String` | `getFieldOfExpr(String expr)`
`DataDefinition` | `getLabelType(String s)` get the type of the returned result
`Map<String,DataDefinition>` | `getLabelTypes()` Gets the type of the fields between FROM and WHERE
`DataDefinition` | `getParameterTypes()` Gets the types of the query parameters, as resulted from the query analysis.
`Map<String,String>` | `getProjections()`
`DataDefinition` | `getProjectionType()` get the type of the returned result
`String` | `getQuery()` Gets the original query that is analyzed by this object
`QueryAST` | `getSuperQuery()`
`protected String` | `getTableName(String label, NameResolver nr)` return the database-level name of the type of the given label
`DataDefinition` | `getTypeOfExprField(String expr)`
`(package private) String` | `join(String label, String field, String labelf, boolean leftJoin)` produce a new label out of label.field, with the indicated labelf name for the result check if the indicated field exists in the type of the label determine the type of the result label if more joins are necesary inbetween (e.g. for sets), add these joins as well
`int` | `parameterAt(int i)` the parameter at the given index
`int` | `parameterNumber()` the number of parameters
`static QueryAnalysis` | `parseQueryFundamental(String oqlQuery)` Performs the analysis of an OQL query
`void` | `prepare()` prepare the query for writing, by looking at the expression identifiers and projections
`void` | `setFromAST(antlr.collections.AST token)` mark the FROM token during parsing
`void` | `setGroupAST(antlr.collections.AST token)` mark the GROUP BY token during parsing
`void` | `setOneProjection(String label)` set the unique projection during parsing, doesn't work
`void` | `setOQL(String s)`
`void` | `setOrderAST(antlr.collections.AST token)` mark the ORDER BY token during parsing
`void` | `setSuperQuery(QueryAST sp)`
`void` | `setWhereAST(antlr.collections.AST token)` mark the WHERE token during parsing
`(package private) void` | `treatExpressionIdentifiers()` treat the makumba identifiers, generate the needed joins
`protected void` | `writeAfterWhere(NameResolver nr, StringBuffer ret)` writes the rest of the query, after the WHERE part
`protected void` | `writeConditions(NameResolver nr, StringBuffer ret)` writes the where conditions
`protected void` | `writeDistinct(NameResolver nr, StringBuffer ret)` writes SELECT [DISTINCT]
`protected void` | `writeFrom(NameResolver nr, StringBuffer ret)` writes the iterator definitions (FROM part)
`String` | `writeInSQLQuery(NameResolver nr)` write in SQL query, calling the methods for the sections
`protected void` | `writeJoins(NameResolver nr, StringBuffer ret)` write the translator-generated joins
`protected void` | `writeProjection(NameResolver nr, StringBuffer ret)` writes the part between SELECT and from FROM (i.e. the projections)

Methods inherited from class org.makumba.providers.query.oql.OQLAST
`getMakumbaType`

Methods inherited from class antlr.CommonAST
`getText, getType, initialize, initialize, initialize, setText, setType`

Methods inherited from class antlr.BaseAST
`addChild, decode, encode, equals, equalsList, equalsListPartial, equalsTree, equalsTreePartial, findAll, findAllPartial, getColumn, getFirstChild, getLine, getNextSibling, getNumberOfChildren, getTokenNames, removeChildren, setFirstChild, setNextSibling, setVerboseStringConversion, toString, toStringList, toStringTree, xmlSerialize, xmlSerializeNode, xmlSerializeRootClose, xmlSerializeRootOpen`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### originalQuery

    String originalQuery

### fromAST

    antlr.collections.AST fromAST

  markers in the chain of tokens for the different parts of the query

### whereAST

    antlr.collections.AST whereAST

  markers in the chain of tokens for the different parts of the query

### groupAST

    antlr.collections.AST groupAST

  markers in the chain of tokens for the different parts of the query

### orderAST

    antlr.collections.AST orderAST

  markers in the chain of tokens for the different parts of the query

### afterWhereAST

    antlr.collections.AST afterWhereAST

  markers in the chain of tokens for the different parts of the query

### firstProjection

    antlr.collections.AST firstProjection

  markers in the chain of tokens for the different parts of the query

### superQuery

    QueryAST superQuery

  the enclosing query, never tested

### oneProjectionLabel

    String oneProjectionLabel

  label of the projection, in case of an all-table projection, doesn't work presently

### projections

    Vector<Projection> projections

  projections

### projectionLabels

    Vector<String> projectionLabels

  labels of the projections, given or attributed automatically

### projectionLabelSearch

    Hashtable<String,Projection> projectionLabelSearch

  searcher for projection labels

### parameters

    Vector<ParamAST> parameters

  parameters for this query

### resultInfo

    DataDefinition resultInfo

  the type of the returned result

### paramInfo

    DataDefinition paramInfo

  the parameter types

### labels

    Hashtable<String,DataDefinition> labels

  associate each label to its makumba type

### fromLabels

    Hashtable<String,DataDefinition> fromLabels

  labels explicitly defined in OQL FROM

### aliases

    Hashtable<String,String> aliases

  support aliases in query

### joins

    Vector<QueryAST.Join> joins

  the joins needed out of the label.field from this query

### joinNames

    Hashtable<String,String> joinNames

  finder for joins in the form label.field, used in order not to repeat the same join

### expressions

    Vector<antlr.collections.AST> expressions

  expressions, for type analysis

### expressionIdentifiers

    Vector<antlr.collections.AST> expressionIdentifiers

  makumba identifiers label.field or label detected inside expressions

Constructor Detail

### QueryAST

    public QueryAST()

### QueryAST

    public QueryAST(antlr.Token t)

Method Detail

### setOQL

    public void setOQL(String s)

### setFromAST

    public void setFromAST(antlr.collections.AST token)

  mark the FROM token during parsing

### setWhereAST

    public void setWhereAST(antlr.collections.AST token)

  mark the WHERE token during parsing

### setGroupAST

    public void setGroupAST(antlr.collections.AST token)

  mark the GROUP BY token during parsing

### setOrderAST

    public void setOrderAST(antlr.collections.AST token)

  mark the ORDER BY token during parsing

### setSuperQuery

    public void setSuperQuery(QueryAST sp)

### getSuperQuery

    public QueryAST getSuperQuery()

### addProjection

    public void addProjection(Projection p)

  add a projection during parsing

### addParameter

    public void addParameter(ParamAST p)

  add a parameter during parsing

### parameterNumber

    public int parameterNumber()

  the number of parameters

  Specified by:
    `parameterNumber` in interface `QueryAnalysis`
  See Also:
    `QueryAnalysis.parameterAt(int)`

### parameterAt

    public int parameterAt(int i)

  the parameter at the given index

  Specified by:
    `parameterAt` in interface `QueryAnalysis`
  See Also:
    `QueryAnalysis.parameterNumber()`

### getProjectionType

    public DataDefinition getProjectionType()

  get the type of the returned result

  Specified by:
    `getProjectionType` in interface `QueryAnalysis`
  Returns:
    A DataDefinition containing in the first field the type and name of the first QL projection, the second field the type and name of the second QL projection $2 etc.

### getParameterTypes

    public DataDefinition getParameterTypes()

  Description copied from interface: `QueryAnalysis`
  Gets the types of the query parameters, as resulted from the query analysis.

  Specified by:
    `getParameterTypes` in interface `QueryAnalysis`
  Returns:
    A DataDefinition containing in the first field the type of the QL parameter mentioned first in the query. Each mentioning of a parameter new will get a new field in this DataDefinition!

### getLabelType

    public DataDefinition getLabelType(String s)

  get the type of the returned result

  Specified by:
    `getLabelType` in interface `QueryAnalysis`
  Parameters:
    `s` - the name of the label
  Returns:
    The type of the label as declared in the FROM part of the query

### setOneProjection

    public void setOneProjection(String label)

  set the unique projection during parsing, doesn't work

### computeProjectionTypes

    void computeProjectionTypes()
                          throws antlr.RecognitionException

  treat the existing projections, check the type of each and make up the returned type

  Throws:
    `antlr.RecognitionException`

### computeParameterTypes

    public void computeParameterTypes()

### addJoin

    String addJoin(String l1,
                   String f1,
                   String name,
                   String f2,
                   DataDefinition type,
                   boolean leftJoin)
             throws antlr.SemanticException

  make a new join with the name and associate teh label with the type

  Parameters:
    `leftJoin` -
  Throws:
    `antlr.SemanticException`

### join

    String join(String label,
                String field,
                String labelf,
                boolean leftJoin)
          throws antlr.RecognitionException

  produce a new label out of label.field, with the indicated labelf name for the result check if the indicated field exists in the type of the label determine the type of the result label if more joins are necesary inbetween (e.g. for sets), add these joins as well

  Parameters:
    `leftJoin` -
  Throws:
    `antlr.RecognitionException`

### addFrom

    public void addFrom(String frm,
                        String label,
                        boolean leftJoin)
                 throws antlr.RecognitionException

  add a FROM projection, if it's just a label declaration, associate the label with the type, otherwise (label.field) generate the needed joins

  Throws:
    `antlr.RecognitionException`

### addExpression

    public void addExpression(antlr.collections.AST token)

### computeExpressionTypes

    void computeExpressionTypes()
                          throws antlr.RecognitionException

  treat the makumba identifiers, generate the needed joins

  Throws:
    `antlr.RecognitionException`

### addExpressionIdentifier

    public void addExpressionIdentifier(antlr.collections.AST token)

  add a makumba identifier

### treatExpressionIdentifiers

    void treatExpressionIdentifiers()
                              throws antlr.RecognitionException

  treat the makumba identifiers, generate the needed joins

  Throws:
    `antlr.RecognitionException`

### writeDistinct

    protected void writeDistinct(NameResolver nr,
                                 StringBuffer ret)

  writes SELECT [DISTINCT]

### writeProjection

    protected void writeProjection(NameResolver nr,
                                   StringBuffer ret)

  writes the part between SELECT and from FROM (i.e. the projections)

### writeFrom

    protected void writeFrom(NameResolver nr,
                             StringBuffer ret)

  writes the iterator definitions (FROM part)

### getTableName

    protected String getTableName(String label,
                                  NameResolver nr)

  return the database-level name of the type of the given label

### getFieldName

    protected String getFieldName(String label,
                                  String field,
                                  NameResolver nr)

  return the database-level name of the given field of the given label

### writeJoins

    protected void writeJoins(NameResolver nr,
                              StringBuffer ret)

  write the translator-generated joins

### writeConditions

    protected void writeConditions(NameResolver nr,
                                   StringBuffer ret)

  writes the where conditions

### writeAfterWhere

    protected void writeAfterWhere(NameResolver nr,
                                   StringBuffer ret)

  writes the rest of the query, after the WHERE part

### prepare

    public void prepare()
                 throws antlr.RecognitionException

  prepare the query for writing, by looking at the expression identifiers and projections

  Throws:
    `antlr.RecognitionException`

### writeInSQLQuery

    public String writeInSQLQuery(NameResolver nr)

  write in SQL query, calling the methods for the sections

  Specified by:
    `writeInSQLQuery` in interface `QueryAnalysis`
  Overrides:
    `writeInSQLQuery` in class `OQLAST`
  Parameters:
    `nr` - the NameResolver that maps DataDefinition names to database names
  Returns:
    a SQL string

### getQuery

    public String getQuery()

  Description copied from interface: `QueryAnalysis`
  Gets the original query that is analyzed by this object

  Specified by:
    `getQuery` in interface `QueryAnalysis`

### getLabelTypes

    public Map<String,DataDefinition> getLabelTypes()

  Description copied from interface: `QueryAnalysis`
  Gets the type of the fields between FROM and WHERE

  Specified by:
    `getLabelTypes` in interface `QueryAnalysis`
  Returns:
    A DataDefinition containing in the first field the type and name of the first label, the second field the type and name of the second label $2 etc.

### getTypeOfExprField

    public DataDefinition getTypeOfExprField(String expr)

### getProjections

    public Map<String,String> getProjections()

### getFieldOfExpr

    public String getFieldOfExpr(String expr)

### parseQueryFundamental

    public static QueryAnalysis parseQueryFundamental(String oqlQuery)
                                               throws antlr.RecognitionException

  Performs the analysis of an OQL query

  Parameters:
    `oqlQuery` - the query to analyse
  Returns:
    the OQL analysis correponding to the query
  Throws:
    `antlr.RecognitionException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Docs generated on 2009-02-25 14:20