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

java.lang.Object
  extended by org.apache.chemistry.opencmis.server.support.query.QueryObject

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  Map<Integer,String> typeReferences
           
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)
           
 void addWhereTypeReference(org.antlr.runtime.tree.Tree node, String qualifier)
           
 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 qualifier)
           
 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 qualifier)
           
 String getTypeReference(Integer token)
           
 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 final List<CmisSelector> selectReferences

whereReferences

protected final List<CmisSelector> whereReferences

joinReferences

protected final List<CmisSelector> joinReferences

colOrFuncAlias

protected final Map<String,CmisSelector> colOrFuncAlias

froms

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


from

protected String from
main from alias name


joinSpecs

protected final List<QueryObject.JoinSpec> joinSpecs

columnReferences

protected final Map<Integer,CmisSelector> columnReferences

typeReferences

protected final Map<Integer,String> typeReferences

sortSpecs

protected final 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)

getTypeReference

public String getTypeReference(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 qualifier)

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

addWhereTypeReference

public void addWhereTypeReference(org.antlr.runtime.tree.Tree node,
                                  String qualifier)

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


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