|
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||
java.lang.Objectantlr.BaseAST
antlr.CommonAST
org.makumba.providers.query.oql.OQLAST
org.makumba.providers.query.oql.QueryAST
public class QueryAST
an OQL query, writes out the translated SQL query
| 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 |
|---|
String originalQuery
antlr.collections.AST fromAST
antlr.collections.AST whereAST
antlr.collections.AST groupAST
antlr.collections.AST orderAST
antlr.collections.AST afterWhereAST
antlr.collections.AST firstProjection
QueryAST superQuery
String oneProjectionLabel
Vector<Projection> projections
Vector<String> projectionLabels
Hashtable<String,Projection> projectionLabelSearch
Vector<ParamAST> parameters
DataDefinition resultInfo
DataDefinition paramInfo
Hashtable<String,DataDefinition> labels
Hashtable<String,DataDefinition> fromLabels
Hashtable<String,String> aliases
Vector<QueryAST.Join> joins
Hashtable<String,String> joinNames
Vector<antlr.collections.AST> expressions
Vector<antlr.collections.AST> expressionIdentifiers
| Constructor Detail |
|---|
public QueryAST()
public QueryAST(antlr.Token t)
| Method Detail |
|---|
public void setOQL(String s)
public void setFromAST(antlr.collections.AST token)
public void setWhereAST(antlr.collections.AST token)
public void setGroupAST(antlr.collections.AST token)
public void setOrderAST(antlr.collections.AST token)
public void setSuperQuery(QueryAST sp)
public QueryAST getSuperQuery()
public void addProjection(Projection p)
public void addParameter(ParamAST p)
public int parameterNumber()
parameterNumber in interface QueryAnalysisQueryAnalysis.parameterAt(int)public int parameterAt(int i)
parameterAt in interface QueryAnalysisQueryAnalysis.parameterNumber()public DataDefinition getProjectionType()
getProjectionType in interface QueryAnalysispublic DataDefinition getParameterTypes()
QueryAnalysis
getParameterTypes in interface QueryAnalysispublic DataDefinition getLabelType(String s)
getLabelType in interface QueryAnalysiss - the name of the label
public void setOneProjection(String label)
void computeProjectionTypes()
throws antlr.RecognitionException
antlr.RecognitionExceptionpublic void computeParameterTypes()
String addJoin(String l1,
String f1,
String name,
String f2,
DataDefinition type,
boolean leftJoin)
throws antlr.SemanticException
leftJoin -
antlr.SemanticException
String join(String label,
String field,
String labelf,
boolean leftJoin)
throws antlr.RecognitionException
leftJoin -
antlr.RecognitionException
public void addFrom(String frm,
String label,
boolean leftJoin)
throws antlr.RecognitionException
antlr.RecognitionExceptionpublic void addExpression(antlr.collections.AST token)
void computeExpressionTypes()
throws antlr.RecognitionException
antlr.RecognitionExceptionpublic void addExpressionIdentifier(antlr.collections.AST token)
void treatExpressionIdentifiers()
throws antlr.RecognitionException
antlr.RecognitionException
protected void writeDistinct(NameResolver nr,
StringBuffer ret)
protected void writeProjection(NameResolver nr,
StringBuffer ret)
protected void writeFrom(NameResolver nr,
StringBuffer ret)
protected String getTableName(String label,
NameResolver nr)
protected String getFieldName(String label,
String field,
NameResolver nr)
protected void writeJoins(NameResolver nr,
StringBuffer ret)
protected void writeConditions(NameResolver nr,
StringBuffer ret)
protected void writeAfterWhere(NameResolver nr,
StringBuffer ret)
public void prepare()
throws antlr.RecognitionException
antlr.RecognitionExceptionpublic String writeInSQLQuery(NameResolver nr)
writeInSQLQuery in interface QueryAnalysiswriteInSQLQuery in class OQLASTnr - the NameResolver that maps DataDefinition names to database names
public String getQuery()
QueryAnalysis
getQuery in interface QueryAnalysispublic Map<String,DataDefinition> getLabelTypes()
QueryAnalysis
getLabelTypes in interface QueryAnalysispublic DataDefinition getTypeOfExprField(String expr)
public Map<String,String> getProjections()
public String getFieldOfExpr(String expr)
public static QueryAnalysis parseQueryFundamental(String oqlQuery)
throws antlr.RecognitionException
oqlQuery - the query to analyse
antlr.RecognitionException
|
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||