You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fg...@apache.org on 2010/09/27 18:16:03 UTC

svn commit: r1001800 - /incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryObject.java

Author: fguillaume
Date: Mon Sep 27 16:16:02 2010
New Revision: 1001800

URL: http://svn.apache.org/viewvc?rev=1001800&view=rev
Log:
format/whitespace

Modified:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryObject.java

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryObject.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryObject.java?rev=1001800&r1=1001799&r2=1001800&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryObject.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryObject.java Mon Sep 27 16:16:02 2010
@@ -34,106 +34,110 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 /**
- * QueryObject is a class used to encapsulate a CMIS query. It is created from an ANTLR
- * parser on an incoming query string. During parsing varoius 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.  
- *
+ * 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.
  */
 public class QueryObject {
-    
+
     private static Log LOG = LogFactory.getLog(QueryObject.class);
-    
-    // For error handling see: http://www.antlr.org/pipermail/antlr-interest/2008-April/027600.html
-    // select part 
+
+    // For error handling see:
+    // http://www.antlr.org/pipermail/antlr-interest/2008-April/027600.html
+    // select part
     private TypeManager typeMgr;
-    private List<CmisSelector> selectReferences = new ArrayList<CmisSelector> ();
-    private List<CmisSelector> whereReferences = new ArrayList<CmisSelector> ();
-    private List<CmisSelector> joinReferences = new ArrayList<CmisSelector> (); // --> Join not implemented yet
+    private List<CmisSelector> selectReferences = new ArrayList<CmisSelector>();
+    private List<CmisSelector> whereReferences = new ArrayList<CmisSelector>();
+    private List<CmisSelector> joinReferences = new ArrayList<CmisSelector>();
+    // --> Join not implemented yet
     private Map<String, CmisSelector> colOrFuncAlias = new HashMap<String, CmisSelector>();
     private QueryConditionProcessor queryProcessor;
-    
+
     // from part
-    /** 
+    /**
      * map from alias name to type query name
      */
-    private Map<String,String> froms = new LinkedHashMap<String,String>();
+    private Map<String, String> froms = new LinkedHashMap<String, String>();
 
     // where part
-    private Map<Integer, CmisSelector> columnReferences = new HashMap<Integer, CmisSelector>(); 
+    private Map<Integer, CmisSelector> columnReferences = new HashMap<Integer, CmisSelector>();
 
     // order by part
     private List<SortSpec> sortSpecs = new ArrayList<SortSpec>();
 
     public class SortSpec {
-        private  boolean ascending;
-        private Integer colRefKey; // key in columnReferencesMap point to column descriptions
-        
+        private boolean ascending;
+        private Integer colRefKey; // key in columnReferencesMap point to column
+                                    // descriptions
+
         public SortSpec(Integer key, boolean ascending) {
             this.colRefKey = key;
             this.ascending = ascending;
         }
-        
+
         public CmisSelector getSelector() {
             return columnReferences.get(colRefKey);
         }
-        
+
         public boolean isAscending() {
             return ascending;
         }
     };
-    
+
     public QueryObject() {
     }
-    
+
     public QueryObject(TypeManager tm, QueryConditionProcessor wp) {
-        typeMgr = tm;        
+        typeMgr = tm;
         queryProcessor = wp;
     }
-    
+
     public Map<Integer, CmisSelector> getColumnReferences() {
         return Collections.unmodifiableMap(columnReferences);
     }
-    
-    public CmisSelector getColumnReference (Integer token) {
+
+    public CmisSelector getColumnReference(Integer token) {
         return columnReferences.get(token);
     }
-    
-    /////////////////////////////////////////////////////////
+
+    // ///////////////////////////////////////////////////////
     // SELECT part
-    
+
     // public accessor methods
     public List<CmisSelector> getSelectReferences() {
         return selectReferences;
     }
 
     void addSelectReference(Object node, CmisSelector selRef) {
-        selectReferences.add(selRef);        
-        columnReferences.put(((Tree)node).getTokenStartIndex(), selRef);
+        selectReferences.add(selRef);
+        columnReferences.put(((Tree) node).getTokenStartIndex(), selRef);
     }
 
     void addAlias(String aliasName, CmisSelector aliasRef) {
         LOG.debug("add alias: " + aliasName + " for: " + aliasRef);
         if (colOrFuncAlias.containsKey(aliasName)) {
-            throw new CmisInvalidArgumentException("You cannot use name " + aliasName + " more than once as alias in a select.");
+            throw new CmisInvalidArgumentException("You cannot use name " + aliasName
+                    + " more than once as alias in a select.");
         } else {
             aliasRef.setAliasName(aliasName);
             colOrFuncAlias.put(aliasName, aliasRef);
         }
     }
-    
+
     CmisSelector getSelectAlias(String aliasName) {
         return colOrFuncAlias.get(aliasName);
     }
 
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
     // FROM part
 
     void addType(String aliasName, String typeQueryName) {
         LOG.debug("add alias: " + aliasName + " for: " + typeQueryName);
         if (froms.containsKey(aliasName)) {
-            throw new CmisInvalidArgumentException ("You cannot use name " + aliasName + " more than once as alias in a from part.");
+            throw new CmisInvalidArgumentException("You cannot use name " + aliasName
+                    + " more than once as alias in a from part.");
         } else {
             if (null != aliasName)
                 froms.put(aliasName, typeQueryName);
@@ -142,70 +146,70 @@ public class QueryObject {
         }
     }
 
-    public Map<String,String> getTypes() {
+    public Map<String, String> getTypes() {
         return Collections.unmodifiableMap(froms);
     }
-    
+
     public String getTypeQueryName(String alias) {
         return froms.get(alias);
     }
-    
+
     public TypeDefinition getTypeDefinitionFromQueryName(String queryName) {
-        return typeMgr.getTypeByQueryName(queryName);       
+        return typeMgr.getTypeByQueryName(queryName);
     }
-    
+
     public TypeDefinition getParentType(TypeDefinition td) {
         String parentType = td.getParentTypeId();
-        return parentType==null ? null : typeMgr.getTypeById(parentType).getTypeDefinition();
+        return parentType == null ? null : typeMgr.getTypeById(parentType).getTypeDefinition();
     }
-    
+
     public TypeDefinition getParentType(String typeId) {
         TypeDefinition td = typeMgr.getTypeById(typeId).getTypeDefinition();
         String parentType = td == null ? null : td.getParentTypeId();
-        return parentType==null ? null : typeMgr.getTypeById(parentType).getTypeDefinition();
+        return parentType == null ? null : typeMgr.getTypeById(parentType).getTypeDefinition();
     }
-    
+
     public TypeDefinition getMainFromName() {
-        String queryName = froms.values().iterator().next(); // as we don't support JOINS take first type
+        // as we don't support JOINS take first type
+        String queryName = froms.values().iterator().next();
         TypeDefinition td = getTypeDefinitionFromQueryName(queryName);
         return td;
     }
-    
+
     /**
-     * return a map of all columns that have been requested in the SELECT
-     * part of the statement.
-     * 
-     * @return
-     *      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.
+     * return a map of all columns that have been requested in the SELECT part
+     * of the statement.
+     *
+     * @return 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.
      */
     public Map<String, String> getRequestedProperties() {
-        Map<String, String> res = new HashMap<String, String> ();
+        Map<String, String> res = new HashMap<String, String>();
         for (CmisSelector sel : selectReferences) {
             if (sel instanceof ColumnReference) {
                 ColumnReference colRef = (ColumnReference) sel;
                 String key = colRef.getPropertyId();
                 if (null == key)
                     key = colRef.getPropertyQueryName(); // happens for *
-                String propDescr = colRef.getAliasName() == null ? colRef.getPropertyQueryName() : colRef.getAliasName();
+                String propDescr = colRef.getAliasName() == null ? colRef.getPropertyQueryName() : colRef
+                        .getAliasName();
                 res.put(key, propDescr);
             }
         }
         return res;
     }
-    
+
     /**
-     * return a map of all functions that have been requested in the SELECT
-     * part of the statement.
-     * 
-     * @return
-     *      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.
+     * return a map of all functions that have been requested in the SELECT part
+     * of the statement.
+     *
+     * @return 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.
      */
     public Map<String, String> getRequestedFuncs() {
-        Map<String, String> res = new HashMap<String, String> ();
+        Map<String, String> res = new HashMap<String, String>();
         for (CmisSelector sel : selectReferences) {
             if (sel instanceof FunctionReference) {
                 FunctionReference funcRef = (FunctionReference) sel;
@@ -215,91 +219,98 @@ public class QueryObject {
         }
         return res;
     }
-    
-    /////////////////////////////////////////////////////////
+
+    // ///////////////////////////////////////////////////////
     // JOINS
-    
+
     void addJoinReference(Object node, CmisSelector reference) {
-        columnReferences.put(((Tree)node).getTokenStartIndex(), reference);
+        columnReferences.put(((Tree) node).getTokenStartIndex(), reference);
         joinReferences.add(reference);
     }
-    
+
     public List<CmisSelector> getJoinReferences() {
         return Collections.unmodifiableList(joinReferences);
     }
 
-    
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
     // WHERE part
-    
+
     void addWhereReference(Object node, CmisSelector reference) {
         LOG.debug("add node to where: " + System.identityHashCode(node));
 
-        columnReferences.put(((Tree)node).getTokenStartIndex(), reference);
+        columnReferences.put(((Tree) node).getTokenStartIndex(), reference);
         whereReferences.add(reference);
     }
-    
+
     public List<CmisSelector> getWhereReferences() {
         return Collections.unmodifiableList(whereReferences);
     }
 
-    
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
     // ORDER_BY part
-    
+
     public List<SortSpec> getOrderBys() {
         return Collections.unmodifiableList(sortSpecs);
     }
-    
+
     public void addSortCriterium(Tree node, ColumnReference colRef, boolean ascending) {
         LOG.debug("addSortCriterium: " + colRef + " ascending: " + ascending);
         columnReferences.put(node.getTokenStartIndex(), colRef);
         sortSpecs.add(new SortSpec(node.getTokenStartIndex(), ascending));
     }
 
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
     // resolve types after first pass traversing the AST is complete
-    
+
     public void resolveTypes() {
         LOG.debug("First pass of query traversal is complete, resolving types");
         if (null == typeMgr)
             return;
-        
+
         // First resolve all alias names defined in SELECT:
         for (CmisSelector alias : colOrFuncAlias.values()) {
-            if (alias instanceof ColumnReference) { 
+            if (alias instanceof ColumnReference) {
                 ColumnReference colRef = ((ColumnReference) alias);
                 resolveTypeForAlias(colRef);
             }
         }
-        
-        // Then replace all aliases used somewhere by their resolved column reference:
+
+        // Then replace all aliases used somewhere by their resolved column
+        // reference:
         for (Integer obj : columnReferences.keySet()) {
             CmisSelector selector = columnReferences.get(obj);
             String key = selector.getName();
             if (colOrFuncAlias.containsKey(key)) { // it is an alias
-              CmisSelector resolvedReference = colOrFuncAlias.get(key);
-              columnReferences.put(obj, resolvedReference);
-                // Note: ^ This may replace the value in the map with the same value, but this does not harm.
-                //       Otherwise we need to check if it is resolved or not which causes two more ifs: 
-//                if (selector instanceof ColumnReference) {
-//                    ColumnReference colRef = ((ColumnReference) selector);
-//                    if (colRef.getTypeDefinition() == null) // it is not yet resolved
-//                        // replace unresolved column reference by resolved on from alias map
-//                        columnReferences.put(obj, colOrFuncAlias.get(selector.getAliasName()));
-//                } else
-//                    columnReferences.put(obj, colOrFuncAlias.get(selector.getAliasName()));
-              if (whereReferences.remove(selector))
-                  whereReferences.add(resolvedReference); // replace unresolved by resolved reference
-              if (joinReferences.remove(selector))
-                  joinReferences.add(resolvedReference); // replace unresolved by resolved reference
+                CmisSelector resolvedReference = colOrFuncAlias.get(key);
+                columnReferences.put(obj, resolvedReference);
+                // Note: ^ This may replace the value in the map with the same
+                // value, but this does not harm.
+                // Otherwise we need to check if it is resolved or not which
+                // causes two more ifs:
+                // if (selector instanceof ColumnReference) {
+                // ColumnReference colRef = ((ColumnReference) selector);
+                // if (colRef.getTypeDefinition() == null) // it is not yet
+                // resolved
+                // // replace unresolved column reference by resolved on from
+                // alias map
+                // columnReferences.put(obj,
+                // colOrFuncAlias.get(selector.getAliasName()));
+                // } else
+                // columnReferences.put(obj,
+                // colOrFuncAlias.get(selector.getAliasName()));
+                if (whereReferences.remove(selector))
+                    // replace unresolved by resolved reference
+                    whereReferences.add(resolvedReference);
+                if (joinReferences.remove(selector))
+                    // replace unresolved by resolved reference
+                    joinReferences.add(resolvedReference);
             }
         }
-        
+
         // The replace all remaining column references not using an alias
         for (CmisSelector select : columnReferences.values()) {
             // ignore functions here
-            if (select instanceof ColumnReference) { 
+            if (select instanceof ColumnReference) {
                 ColumnReference colRef = ((ColumnReference) select);
                 if (colRef.getTypeDefinition() == null) { // not yet resolved
                     if (colRef.getTypeQueryName() == null) {
@@ -313,11 +324,10 @@ public class QueryObject {
             }
         }
     }
-    
-    
+
     private void resolveTypeForAlias(ColumnReference colRef) {
         String aliasName = colRef.getAliasName();
-        
+
         if (colOrFuncAlias.containsKey(aliasName)) {
             CmisSelector selector = colOrFuncAlias.get(aliasName);
             if (selector instanceof ColumnReference) {
@@ -333,19 +343,18 @@ public class QueryObject {
             // else --> ignore FunctionReference
         }
     }
-        
-        
+
     // for a select x from y, z ... find the type in type manager for x
     private void resolveTypeForColumnReference(ColumnReference colRef) {
         String propName = colRef.getPropertyQueryName();
         boolean isStar = propName.equals("*");
-        
+
         // it is property query name without a type, so find type
         int noFound = 0;
         TypeDefinition tdFound = null;
         for (String typeQueryName : froms.values()) {
             TypeDefinition td = typeMgr.getTypeByQueryName(typeQueryName);
-            if (null == td) 
+            if (null == td)
                 throw new CmisInvalidArgumentException(typeQueryName + " is neither a type query name nor an alias.");
             else if (isStar) {
                 ++noFound;
@@ -356,28 +365,32 @@ public class QueryObject {
             }
         }
         if (noFound == 0)
-            throw new CmisInvalidArgumentException(propName + " is not a property query name in any of the types in from ...");
+            throw new CmisInvalidArgumentException(propName
+                    + " is not a property query name in any of the types in from ...");
         else if (noFound > 1 && !isStar)
-            throw new CmisInvalidArgumentException(propName + " is not a unique property query name within the types in from ...");
+            throw new CmisInvalidArgumentException(propName
+                    + " is not a unique property query name within the types in from ...");
         else {
             if (null != tdFound) // can be null in select * from t1 JOIN t2....
                 validateColumnReferenceAndResolveType(tdFound, colRef);
         }
     }
 
-    // for a select x.y from x ... check that x has property y and that x is in from
+    // for a select x.y from x ... check that x has property y and that x is in
+    // from
     private void validateColumnReferenceAndResolveType(ColumnReference colRef) {
-        
-        String typeQueryName = getReferencedTypeQueryName(colRef.getTypeQueryName()); // either same name or mapped alias
+        // either same name or mapped alias
+        String typeQueryName = getReferencedTypeQueryName(colRef.getTypeQueryName());
         TypeDefinition td = typeMgr.getTypeByQueryName(typeQueryName);
-        if (null == td) 
-            throw new CmisInvalidArgumentException(colRef.getTypeQueryName() + " is neither a type query name nor an alias.");
-        
+        if (null == td)
+            throw new CmisInvalidArgumentException(colRef.getTypeQueryName()
+                    + " is neither a type query name nor an alias.");
+
         validateColumnReferenceAndResolveType(td, colRef);
     }
 
     private void validateColumnReferenceAndResolveType(TypeDefinition td, ColumnReference colRef) {
-        
+
         // type found, check if property exists
         boolean hasProp;
         if (colRef.getPropertyQueryName().equals("*"))
@@ -385,191 +398,193 @@ public class QueryObject {
         else
             hasProp = TypeValidator.typeContainsPropertyWithQueryName(td, colRef.getPropertyQueryName());
         if (!hasProp)
-            throw new CmisInvalidArgumentException(colRef.getPropertyQueryName() + " is not a valid property query name in type " + td.getId() + ".");
-        
+            throw new CmisInvalidArgumentException(colRef.getPropertyQueryName()
+                    + " is not a valid property query name in type " + td.getId() + ".");
+
         colRef.setTypeDefinition(typeMgr.getPropertyIdForQueryName(td, colRef.getPropertyQueryName()), td);
     }
-    
-    // return type query name for a referenced column (which can be the name itself or an alias
+
+    // return type query name for a referenced column (which can be the name
+    // itself or an alias
     private String getReferencedTypeQueryName(String typeQueryNameOrAlias) {
         String typeQueryName = froms.get(typeQueryNameOrAlias);
         if (null == typeQueryName) {
-            // if an alias was defined but still the original is used we have to search case: SELECT T.p FROM T AS TAlias 
+            // if an alias was defined but still the original is used we have to
+            // search case: SELECT T.p FROM T AS TAlias
             for (String tqn : froms.values()) {
-              if (typeQueryNameOrAlias.equals(tqn))
-                  return tqn;
+                if (typeQueryNameOrAlias.equals(tqn))
+                    return tqn;
             }
             return null;
         } else
             return typeQueryName;
     }
-    
-    
-    public void processWhereClause(Tree whereRoot)
-    {
-        if (null!=queryProcessor && null != whereRoot) {
+
+    public void processWhereClause(Tree whereRoot) {
+        if (null != queryProcessor && null != whereRoot) {
             queryProcessor.onStartProcessing(whereRoot);
             processWhereNode(whereRoot);
             queryProcessor.onStopProcessing();
         }
     }
-    
+
     private void processWhereNode(Tree root) {
         int count = root.getChildCount();
-        for (int i=0; i<count; i++) {
+        for (int i = 0; i < count; i++) {
             Tree child = root.getChild(i);
             evalWhereNode(child);
-//            processWhereNode(child);  // recursive descent
+            // processWhereNode(child); // recursive descent
         }
     }
-    
-    /////////////////////////////////////////////////////////
+
+    // ///////////////////////////////////////////////////////
     // Processing the WHERE clause
-    
+
     private void evalWhereNode(Tree node) {
-        // Ensure that we receive only valid tokens and nodes in the where clause:
-            LOG.debug("evaluating node: " + node.toString());
-            switch (node.getType()) {
-            case CmisQlStrictLexer.WHERE:;
-                break; // ignore
-            case CmisQlStrictLexer.EQ:
-                evalWhereNode(node.getChild(0));
-                queryProcessor.onEquals(node, node.getChild(0), node.getChild(1));
-                evalWhereNode(node.getChild(1));
-                break;
-            case CmisQlStrictLexer.NEQ:
-                evalWhereNode(node.getChild(0));
-                queryProcessor.onNotEquals(node, node.getChild(0), node.getChild(1));
-                evalWhereNode(node.getChild(1));
-                break;
-            case CmisQlStrictLexer.GT:
-                evalWhereNode(node.getChild(0));
-                queryProcessor.onGreaterThan(node, node.getChild(0), node.getChild(1));
-                evalWhereNode(node.getChild(1));
-                break;
-            case CmisQlStrictLexer.GTEQ:
-                evalWhereNode(node.getChild(0));
-                queryProcessor.onGreaterOrEquals(node, node.getChild(0), node.getChild(1));
-                evalWhereNode(node.getChild(1));
-                break;
-            case CmisQlStrictLexer.LT:
-                evalWhereNode(node.getChild(0));
-                queryProcessor.onLessThan(node, node.getChild(0), node.getChild(1));
-                evalWhereNode(node.getChild(1));
-                break;
-            case CmisQlStrictLexer.LTEQ:
+        // Ensure that we receive only valid tokens and nodes in the where
+        // clause:
+        LOG.debug("evaluating node: " + node.toString());
+        switch (node.getType()) {
+        case CmisQlStrictLexer.WHERE:
+            break; // ignore
+        case CmisQlStrictLexer.EQ:
+            evalWhereNode(node.getChild(0));
+            queryProcessor.onEquals(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+        case CmisQlStrictLexer.NEQ:
+            evalWhereNode(node.getChild(0));
+            queryProcessor.onNotEquals(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+        case CmisQlStrictLexer.GT:
+            evalWhereNode(node.getChild(0));
+            queryProcessor.onGreaterThan(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+        case CmisQlStrictLexer.GTEQ:
+            evalWhereNode(node.getChild(0));
+            queryProcessor.onGreaterOrEquals(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+        case CmisQlStrictLexer.LT:
+            evalWhereNode(node.getChild(0));
+            queryProcessor.onLessThan(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+        case CmisQlStrictLexer.LTEQ:
+            evalWhereNode(node.getChild(0));
+            queryProcessor.onLessOrEquals(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+
+        case CmisQlStrictLexer.NOT:
+            queryProcessor.onPreNot(node, node.getChild(0));
+            queryProcessor.onNot(node, node.getChild(0));
+            evalWhereNode(node.getChild(0));
+            queryProcessor.onPostNot(node, node.getChild(0));
+            break;
+        case CmisQlStrictLexer.AND:
+            queryProcessor.onPreAnd(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(0));
+            queryProcessor.onAnd(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            queryProcessor.onPostAnd(node, node.getChild(0), node.getChild(1));
+            break;
+        case CmisQlStrictLexer.OR:
+            queryProcessor.onPreOr(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(0));
+            queryProcessor.onOr(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            queryProcessor.onPostOr(node, node.getChild(0), node.getChild(1));
+            break;
+
+        // Multi-value:
+        case CmisQlStrictLexer.IN:
+            evalWhereNode(node.getChild(0));
+            queryProcessor.onIn(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+        case CmisQlStrictLexer.NOT_IN:
+            evalWhereNode(node.getChild(0));
+            queryProcessor.onNotIn(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+        case CmisQlStrictLexer.IN_ANY:
+            evalWhereNode(node.getChild(0));
+            queryProcessor.onInAny(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+        case CmisQlStrictLexer.NOT_IN_ANY:
+            evalWhereNode(node.getChild(0));
+            queryProcessor.onNotInAny(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+        case CmisQlStrictLexer.EQ_ANY:
+            evalWhereNode(node.getChild(0));
+            queryProcessor.onEqAny(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+
+        // Null comparisons:
+        case CmisQlStrictLexer.IS_NULL:
+            queryProcessor.onIsNull(node, node.getChild(0));
+            evalWhereNode(node.getChild(0));
+            break;
+        case CmisQlStrictLexer.IS_NOT_NULL:
+            queryProcessor.onIsNotNull(node, node.getChild(0));
+            evalWhereNode(node.getChild(0));
+            break;
+
+        // String matching
+        case CmisQlStrictLexer.LIKE:
+            evalWhereNode(node.getChild(0));
+            queryProcessor.onIsLike(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+        case CmisQlStrictLexer.NOT_LIKE:
+            evalWhereNode(node.getChild(0));
+            queryProcessor.onIsNotLike(node, node.getChild(0), node.getChild(1));
+            evalWhereNode(node.getChild(1));
+            break;
+
+        // Functions
+        case CmisQlStrictLexer.CONTAINS:
+            if (node.getChildCount() == 1) {
+                queryProcessor.onContains(node, null, node.getChild(0));
                 evalWhereNode(node.getChild(0));
-                queryProcessor.onLessOrEquals(node, node.getChild(0), node.getChild(1));
-                evalWhereNode(node.getChild(1));
-                break;
-                
-            case CmisQlStrictLexer.NOT:
-                queryProcessor.onPreNot(node, node.getChild(0));
-                queryProcessor.onNot(node, node.getChild(0));                
-                evalWhereNode(node.getChild(0));
-                queryProcessor.onPostNot(node, node.getChild(0));
-                break;
-            case CmisQlStrictLexer.AND:
-                queryProcessor.onPreAnd(node, node.getChild(0), node.getChild(1));
+            } else {
                 evalWhereNode(node.getChild(0));
-                queryProcessor.onAnd(node, node.getChild(0), node.getChild(1));
+                queryProcessor.onContains(node, node.getChild(0), node.getChild(1));
                 evalWhereNode(node.getChild(1));
-                queryProcessor.onPostAnd(node, node.getChild(0), node.getChild(1));
-                break;
-            case CmisQlStrictLexer.OR:
-                queryProcessor.onPreOr(node, node.getChild(0), node.getChild(1));
-                evalWhereNode(node.getChild(0));
-                queryProcessor.onOr(node, node.getChild(0), node.getChild(1));
-                evalWhereNode(node.getChild(1));
-                queryProcessor.onPostOr(node, node.getChild(0), node.getChild(1));
-                break;
-                
-            // Multi-value:
-            case CmisQlStrictLexer.IN:
-                evalWhereNode(node.getChild(0));
-                queryProcessor.onIn(node, node.getChild(0), node.getChild(1));
-                evalWhereNode(node.getChild(1));
-                break;
-            case CmisQlStrictLexer.NOT_IN:
-                evalWhereNode(node.getChild(0));
-                queryProcessor.onNotIn(node, node.getChild(0), node.getChild(1));
-                evalWhereNode(node.getChild(1));
-                break;
-            case CmisQlStrictLexer.IN_ANY:
-                evalWhereNode(node.getChild(0));
-                queryProcessor.onInAny(node, node.getChild(0), node.getChild(1));
-                evalWhereNode(node.getChild(1));
-                break;
-            case CmisQlStrictLexer.NOT_IN_ANY:
+            }
+            break;
+        case CmisQlStrictLexer.IN_FOLDER:
+            if (node.getChildCount() == 1) {
+                queryProcessor.onInFolder(node, null, node.getChild(0));
                 evalWhereNode(node.getChild(0));
-                queryProcessor.onNotInAny(node, node.getChild(0), node.getChild(1));
-                evalWhereNode(node.getChild(1));
-                break;
-            case CmisQlStrictLexer.EQ_ANY:
+            } else {
                 evalWhereNode(node.getChild(0));
-                queryProcessor.onEqAny(node, node.getChild(0), node.getChild(1));
+                queryProcessor.onInFolder(node, node.getChild(0), node.getChild(1));
                 evalWhereNode(node.getChild(1));
-                break;
-
-            // Null comparisons:
-            case CmisQlStrictLexer.IS_NULL:
-                queryProcessor.onIsNull(node, node.getChild(0));
-                evalWhereNode(node.getChild(0));
-                break;
-            case CmisQlStrictLexer.IS_NOT_NULL:
-                queryProcessor.onIsNotNull(node, node.getChild(0));
-                evalWhereNode(node.getChild(0));
-                break;
-
-                // String matching
-            case CmisQlStrictLexer.LIKE:
+            }
+            break;
+        case CmisQlStrictLexer.IN_TREE:
+            if (node.getChildCount() == 1) {
+                queryProcessor.onInTree(node, null, node.getChild(0));
                 evalWhereNode(node.getChild(0));
-                queryProcessor.onIsLike(node, node.getChild(0), node.getChild(1));
-                evalWhereNode(node.getChild(1));
-                break;
-            case CmisQlStrictLexer.NOT_LIKE:
+            } else {
                 evalWhereNode(node.getChild(0));
-                queryProcessor.onIsNotLike(node, node.getChild(0), node.getChild(1));
+                queryProcessor.onInTree(node, node.getChild(0), node.getChild(1));
                 evalWhereNode(node.getChild(1));
-                break;
-
-                // Functions
-            case CmisQlStrictLexer.CONTAINS:
-                if (node.getChildCount()==1) {
-                    queryProcessor.onContains(node, null, node.getChild(0));
-                    evalWhereNode(node.getChild(0));
-                } else {
-                    evalWhereNode(node.getChild(0));
-                    queryProcessor.onContains(node, node.getChild(0), node.getChild(1));
-                    evalWhereNode(node.getChild(1));
-                } 
-                break;
-            case CmisQlStrictLexer.IN_FOLDER:
-                if (node.getChildCount()==1) {
-                    queryProcessor.onInFolder(node, null, node.getChild(0));
-                    evalWhereNode(node.getChild(0));
-                } else {
-                    evalWhereNode(node.getChild(0));
-                    queryProcessor.onInFolder(node, node.getChild(0), node.getChild(1));
-                    evalWhereNode(node.getChild(1));
-                } 
-                break;
-            case CmisQlStrictLexer.IN_TREE:
-                if (node.getChildCount()==1) {
-                    queryProcessor.onInTree(node, null, node.getChild(0));
-                    evalWhereNode(node.getChild(0));
-                } else {
-                    evalWhereNode(node.getChild(0));
-                    queryProcessor.onInTree(node, node.getChild(0), node.getChild(1));
-                    evalWhereNode(node.getChild(1));
-                } 
-                break;
-            case CmisQlStrictLexer.SCORE:
-                queryProcessor.onScore(node);
-                break;
-                
-            default:
-               // do nothing;
             }
+            break;
+        case CmisQlStrictLexer.SCORE:
+            queryProcessor.onScore(node);
+            break;
+
+        default:
+            // do nothing;
+        }
     }
 }