org.apache.chemistry.opencmis.server.support.query
Class QueryObject

java.lang.Object
  extended by org.apache.chemistry.opencmis.server.support.query.QueryObject
Direct Known Subclasses:
QueryUtil

public class QueryObject
extends Object

QueryObject is a class used to encapsulate a CMIS query. It is created from an ANTLR parser on an incoming query string. During parsing various informations are collected and stored in objects suitable for evaluating the query (like selected properties, effected types and order statements. A query evaluator can use this information to perform the query and build the result.


Nested Class Summary
static class QueryObject.JoinSpec
           
 class QueryObject.SortSpec
           
 
Field Summary
protected  Map<String,CmisSelector> colOrFuncAlias
           
protected  Map<Integer,CmisSelector> columnReferences
           
protected  String from
          main from alias name
protected  Map<String,String> froms
          map from alias name to type query name
protected  List<CmisSelector> joinReferences
           
protected  List<QueryObject.JoinSpec> joinSpecs
           
protected  List<CmisSelector> selectReferences
           
protected  List<QueryObject.SortSpec> sortSpecs
           
protected  TypeManager typeMgr
           
protected  List<CmisSelector> whereReferences
           
 
Constructor Summary
QueryObject()
           
QueryObject(TypeManager tm)
           
 
Method Summary
 void addAlias(String aliasName, CmisSelector aliasRef)
           
 void addJoin(String kind, String alias, boolean hasSpec)
           
 void addJoinReference(org.antlr.runtime.tree.Tree node, CmisSelector reference)
           
 void addSelectReference(org.antlr.runtime.tree.Tree node, CmisSelector selRef)
           
 void addSortCriterium(org.antlr.runtime.tree.Tree node, ColumnReference colRef, boolean ascending)
           
 String addType(String aliasName, String typeQueryName)
           
 void addWhereReference(org.antlr.runtime.tree.Tree node, CmisSelector reference)
           
 CmisSelector getColumnReference(Integer token)
           
 Map<Integer,CmisSelector> getColumnReferences()
           
 String getErrorMessage()
           
 List<CmisSelector> getJoinReferences()
           
 List<QueryObject.JoinSpec> getJoins()
           
 TypeDefinition getMainFromName()
           
 String getMainTypeAlias()
           
 List<QueryObject.SortSpec> getOrderBys()
           
 TypeDefinition getParentType(String typeId)
           
 TypeDefinition getParentType(TypeDefinition td)
           
protected  String getReferencedTypeQueryName(String typeQueryNameOrAlias)
           
 Map<String,String> getRequestedFuncs()
          return a map of all functions that have been requested in the SELECT part of the statement.
 Map<String,String> getRequestedProperties()
          return a map of all columns that have been requested in the SELECT part of the statement.
 CmisSelector getSelectAlias(String aliasName)
           
 List<CmisSelector> getSelectReferences()
           
 TypeDefinition getTypeDefinitionFromQueryName(String queryName)
           
 String getTypeQueryName(String alias)
           
 Map<String,String> getTypes()
           
 List<CmisSelector> getWhereReferences()
           
protected  void resolveTypeForAlias(ColumnReference colRef)
           
protected  void resolveTypeForColumnReference(ColumnReference colRef)
           
 boolean resolveTypes()
           
protected  void validateColumnReferenceAndResolveType(ColumnReference colRef)
           
protected  void validateColumnReferenceAndResolveType(TypeDefinition td, ColumnReference colRef)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

typeMgr

protected TypeManager typeMgr

selectReferences

protected List<CmisSelector> selectReferences

whereReferences

protected List<CmisSelector> whereReferences

joinReferences

protected List<CmisSelector> joinReferences

colOrFuncAlias

protected Map<String,CmisSelector> colOrFuncAlias

froms

protected Map<String,String> froms
map from alias name to type query name


from

protected String from
main from alias name


joinSpecs

protected List<QueryObject.JoinSpec> joinSpecs

columnReferences

protected Map<Integer,CmisSelector> columnReferences

sortSpecs

protected List<QueryObject.SortSpec> sortSpecs
Constructor Detail

QueryObject

public QueryObject()

QueryObject

public QueryObject(TypeManager tm)
Method Detail

getColumnReferences

public Map<Integer,CmisSelector> getColumnReferences()

getColumnReference

public CmisSelector getColumnReference(Integer token)

getErrorMessage

public String getErrorMessage()

getSelectReferences

public List<CmisSelector> getSelectReferences()

addSelectReference

public void addSelectReference(org.antlr.runtime.tree.Tree node,
                               CmisSelector selRef)

addAlias

public void addAlias(String aliasName,
                     CmisSelector aliasRef)

getSelectAlias

public CmisSelector getSelectAlias(String aliasName)

addType

public String addType(String aliasName,
                      String typeQueryName)

getMainTypeAlias

public String getMainTypeAlias()

getTypes

public Map<String,String> getTypes()

getTypeQueryName

public String getTypeQueryName(String alias)

getTypeDefinitionFromQueryName

public TypeDefinition getTypeDefinitionFromQueryName(String queryName)

getParentType

public TypeDefinition getParentType(TypeDefinition td)

getParentType

public TypeDefinition getParentType(String typeId)

getMainFromName

public TypeDefinition getMainFromName()

getRequestedProperties

public Map<String,String> getRequestedProperties()
return a map of all columns that have been requested in the SELECT part of the statement.

Returns:
a map with a String as a key and value. key is the query name of the property, value is the alias if an alias was given or the query name otherwise.

getRequestedFuncs

public Map<String,String> getRequestedFuncs()
return a map of all functions that have been requested in the SELECT part of the statement.

Returns:
a map with a String as a key and value. key is the function name of the property, value is the alias if an alias was given or the function name otherwise.

addJoinReference

public void addJoinReference(org.antlr.runtime.tree.Tree node,
                             CmisSelector reference)

getJoinReferences

public List<CmisSelector> getJoinReferences()

addJoin

public void addJoin(String kind,
                    String alias,
                    boolean hasSpec)

getJoins

public List<QueryObject.JoinSpec> getJoins()

addWhereReference

public void addWhereReference(org.antlr.runtime.tree.Tree node,
                              CmisSelector reference)

getWhereReferences

public List<CmisSelector> getWhereReferences()

getOrderBys

public List<QueryObject.SortSpec> getOrderBys()

addSortCriterium

public void addSortCriterium(org.antlr.runtime.tree.Tree node,
                             ColumnReference colRef,
                             boolean ascending)

resolveTypes

public boolean resolveTypes()

resolveTypeForAlias

protected void resolveTypeForAlias(ColumnReference colRef)

resolveTypeForColumnReference

protected void resolveTypeForColumnReference(ColumnReference colRef)

validateColumnReferenceAndResolveType

protected void validateColumnReferenceAndResolveType(ColumnReference colRef)

validateColumnReferenceAndResolveType

protected void validateColumnReferenceAndResolveType(TypeDefinition td,
                                                     ColumnReference colRef)

getReferencedTypeQueryName

protected String getReferencedTypeQueryName(String typeQueryNameOrAlias)


Copyright © 2009-2011 The Apache Software Foundation. All Rights Reserved.