You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by md...@apache.org on 2011/09/07 15:45:25 UTC

svn commit: r1166179 [2/2] - in /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons: ./ batch/ conversion/ iterator/ logging/ name/ namespace/ nodetype/ nodetype/constraint/ query/ query/qom/ query/s...

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelFactoryImpl.java?rev=1166179&r1=1166178&r2=1166179&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelFactoryImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelFactoryImpl.java Wed Sep  7 13:45:24 2011
@@ -138,17 +138,17 @@ public abstract class QueryObjectModelFa
         if (constraint != null && !(constraint instanceof ConstraintImpl)) {
             throw new RepositoryException("Unknown Constraint implementation");
         }
-        OrderingImpl[] ords;
+        OrderingImpl[] ord;
         if (orderings != null) {
-            ords = new OrderingImpl[orderings.length];
+            ord = new OrderingImpl[orderings.length];
             for (int i = 0; i < orderings.length; i++) {
                 if (!(orderings[i] instanceof OrderingImpl)) {
                     throw new RepositoryException("Unknown Ordering implementation");
                 }
-                ords[i] = (OrderingImpl) orderings[i];
+                ord[i] = (OrderingImpl) orderings[i];
             }
         } else {
-            ords = OrderingImpl.EMPTY_ARRAY;
+            ord = OrderingImpl.EMPTY_ARRAY;
         }
         ColumnImpl[] cols;
         if (columns != null) {
@@ -164,7 +164,7 @@ public abstract class QueryObjectModelFa
         }
         QueryObjectModelTree qomTree = new QueryObjectModelTree(
                 resolver, (SourceImpl) source,
-                (ConstraintImpl) constraint, ords, cols);
+                (ConstraintImpl) constraint, ord, cols);
         return createQuery(qomTree);
     }
 
@@ -223,7 +223,7 @@ public abstract class QueryObjectModelFa
             throw new RepositoryException("Unknown Source implementation");
         }
         if (!(joinCondition instanceof JoinConditionImpl)) {
-            throw new RepositoryException("Unknwon JoinCondition implementation");
+            throw new RepositoryException("Unknown JoinCondition implementation");
         }
         return new JoinImpl(
                 resolver,
@@ -479,7 +479,7 @@ public abstract class QueryObjectModelFa
      *
      * @param propertyName             the property name, or null to search all
      *                                 full-text indexed properties of the node
-     *                                 (or node subtree, in some implementations)
+     *                                 (or node sub tree, in some implementations)
      * @param fullTextSearchExpression the full-text search expression;
      *                                 non-null
      * @return the constraint; non-null
@@ -505,7 +505,7 @@ public abstract class QueryObjectModelFa
      * @param selectorName             the selector name; non-null
      * @param propertyName             the property name, or null to search all
      *                                 full-text indexed properties of the node
-     *                                 (or node subtree, in some implementations)
+     *                                 (or node sub tree, in some implementations)
      * @param fullTextSearchExpression the full-text search expression;
      *                                 non-null
      * @return the constraint; non-null
@@ -686,7 +686,7 @@ public abstract class QueryObjectModelFa
      *                                       selector or is otherwise invalid
      * @throws javax.jcr.RepositoryException if the operation otherwise fails
      */
-    public NodeName nodeName() throws RepositoryException {
+    public NodeName nodeName() {
         return new NodeNameImpl(resolver, null);
     }
 
@@ -715,7 +715,7 @@ public abstract class QueryObjectModelFa
      *                                       selector or is otherwise invalid
      * @throws javax.jcr.RepositoryException if the operation otherwise fails
      */
-    public NodeLocalName nodeLocalName() throws RepositoryException {
+    public NodeLocalName nodeLocalName() {
         return new NodeLocalNameImpl(resolver, null);
     }
 
@@ -744,7 +744,7 @@ public abstract class QueryObjectModelFa
      *                                       selector or is otherwise invalid
      * @throws javax.jcr.RepositoryException if the operation otherwise fails
      */
-    public FullTextSearchScore fullTextSearchScore() throws RepositoryException {
+    public FullTextSearchScore fullTextSearchScore() {
         return new FullTextSearchScoreImpl(resolver, null);
     }
 

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelTree.java?rev=1166179&r1=1166178&r2=1166179&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelTree.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelTree.java Wed Sep  7 13:45:24 2011
@@ -220,8 +220,7 @@ public class QueryObjectModelTree extend
                     return checkSelector(node.getSelector2QName());
                 }
 
-                private Object checkSelector(Name selectorName)
-                        throws InvalidQueryException {
+                private Object checkSelector(Name selectorName) throws InvalidQueryException {
                     if (!selectors.containsKey(selectorName)) {
                         String msg = "Unknown selector: ";
                         if (selectorName != null) {

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/JCRSQLQueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/JCRSQLQueryBuilder.java?rev=1166179&r1=1166178&r2=1166179&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/JCRSQLQueryBuilder.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/JCRSQLQueryBuilder.java Wed Sep  7 13:45:24 2011
@@ -860,7 +860,7 @@ public class JCRSQLQueryBuilder implemen
 
         /**
          * Creates a new {@code MergingPathQueryNode} with the operation
-         * tpye of a parent node. {@code operation} must be one of:
+         * type of a parent node. {@code operation} must be one of:
          * {@link org.apache.jackrabbit.spi.commons.query.QueryNode#TYPE_OR},
          * {@link org.apache.jackrabbit.spi.commons.query.QueryNode#TYPE_AND} or
          * {@link org.apache.jackrabbit.spi.commons.query.QueryNode#TYPE_NOT}.

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/QueryFormat.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/QueryFormat.java?rev=1166179&r1=1166178&r2=1166179&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/QueryFormat.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/QueryFormat.java Wed Sep  7 13:45:24 2011
@@ -31,7 +31,6 @@ import org.apache.jackrabbit.spi.commons
 import org.apache.jackrabbit.spi.commons.query.OrderQueryNode.OrderSpec;
 import org.apache.jackrabbit.spi.commons.query.PathQueryNode;
 import org.apache.jackrabbit.spi.commons.query.PropertyFunctionQueryNode;
-import org.apache.jackrabbit.spi.commons.query.QueryConstants;
 import org.apache.jackrabbit.spi.commons.query.QueryNode;
 import org.apache.jackrabbit.spi.commons.query.QueryNodeVisitor;
 import org.apache.jackrabbit.spi.commons.query.QueryRootNode;
@@ -44,14 +43,36 @@ import javax.jcr.RepositoryException;
 import javax.jcr.query.InvalidQueryException;
 import java.util.ArrayList;
 import java.util.Calendar;
-import java.util.Iterator;
 import java.util.List;
 import java.util.TimeZone;
 
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_EQ_GENERAL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_EQ_VALUE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_GE_GENERAL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_GE_VALUE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_GT_GENERAL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_GT_VALUE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_LE_GENERAL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_LE_VALUE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_LIKE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_LT_GENERAL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_LT_VALUE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_NE_GENERAL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_NE_VALUE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_NOT_NULL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_NULL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_SIMILAR;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_SPELLCHECK;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.TYPE_DATE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.TYPE_DOUBLE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.TYPE_LONG;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.TYPE_STRING;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.TYPE_TIMESTAMP;
+
 /**
  * Implements the query node tree serialization into a String.
  */
-class QueryFormat implements QueryNodeVisitor, QueryConstants {
+class QueryFormat implements QueryNodeVisitor {
 
     /**
      * Will be used to resolve QNames
@@ -157,15 +178,14 @@ class QueryFormat implements QueryNodeVi
 
             // node types have been collected by now
             String comma = "";
-            int ntCount = 0;
-            for (Iterator it = nodeTypes.iterator(); it.hasNext(); ntCount++) {
-                Name nt = (Name) it.next();
+            for (Object nodeType : nodeTypes) {
+                Name nt = (Name) nodeType;
                 sb.append(comma).append(' ');
                 appendName(nt, resolver, sb);
                 comma = ",";
             }
 
-            if (ntCount == 0) {
+            if (nodeTypes.isEmpty()) {
                 sb.append(' ');
                 sb.append(resolver.getJCRName(NameConstants.NT_BASE));
             }
@@ -175,9 +195,7 @@ class QueryFormat implements QueryNodeVi
 
             if (steps.length == 2
                     && steps[1].getIncludeDescendants()
-                    && steps[1].getNameTest() == null) {
-                // then this query selects all paths
-            } else if (steps.length == 1
+                    && steps[1].getNameTest() == null || steps.length == 1
                     && steps[0].getIncludeDescendants()
                     && steps[0].getNameTest() == null) {
                 // then this query selects all paths

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java?rev=1166179&r1=1166178&r2=1166179&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java Wed Sep  7 13:45:24 2011
@@ -33,7 +33,6 @@ import org.apache.jackrabbit.spi.commons
 import org.apache.jackrabbit.spi.commons.query.OrderQueryNode.OrderSpec;
 import org.apache.jackrabbit.spi.commons.query.PathQueryNode;
 import org.apache.jackrabbit.spi.commons.query.PropertyFunctionQueryNode;
-import org.apache.jackrabbit.spi.commons.query.QueryConstants;
 import org.apache.jackrabbit.spi.commons.query.QueryNode;
 import org.apache.jackrabbit.spi.commons.query.QueryNodeVisitor;
 import org.apache.jackrabbit.spi.commons.query.QueryRootNode;
@@ -50,10 +49,34 @@ import java.util.Calendar;
 import java.util.List;
 import java.util.TimeZone;
 
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_EQ_GENERAL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_EQ_VALUE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_GE_GENERAL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_GE_VALUE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_GT_GENERAL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_GT_VALUE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_LE_GENERAL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_LE_VALUE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_LIKE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_LT_GENERAL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_LT_VALUE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_NE_GENERAL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_NE_VALUE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_NOT_NULL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_NULL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_SIMILAR;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_SPELLCHECK;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.TYPE_DATE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.TYPE_DOUBLE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.TYPE_LONG;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.TYPE_POSITION;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.TYPE_STRING;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.TYPE_TIMESTAMP;
+
 /**
  * Implements the query node tree serialization into a String.
  */
-class QueryFormat implements QueryNodeVisitor, QueryConstants {
+class QueryFormat implements QueryNodeVisitor {
 
     /**
      * Will be used to resolve QNames

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/SimpleNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/SimpleNode.java?rev=1166179&r1=1166178&r2=1166179&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/SimpleNode.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/SimpleNode.java Wed Sep  7 13:45:24 2011
@@ -22,10 +22,9 @@ package org.apache.jackrabbit.spi.common
  * This Class was initially created by JavaCC and then adapted for our needs.
  */
 public class SimpleNode implements Node {
-    protected Node parent;
-    protected Node[] children;
-    protected int id;
-    protected XPath parser;
+    private Node parent;
+    private Node[] children;
+    private final int id;
 
     public SimpleNode(int i) {
         id = i;
@@ -33,7 +32,6 @@ public class SimpleNode implements Node 
 
     public SimpleNode(XPath p, int i) {
         this(i);
-        parser = p;
     }
 
     // Factory method

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/XPathQueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/XPathQueryBuilder.java?rev=1166179&r1=1166178&r2=1166179&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/XPathQueryBuilder.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/XPathQueryBuilder.java Wed Sep  7 13:45:24 2011
@@ -38,7 +38,6 @@ import org.apache.jackrabbit.spi.commons
 import org.apache.jackrabbit.spi.commons.query.OrderQueryNode;
 import org.apache.jackrabbit.spi.commons.query.PathQueryNode;
 import org.apache.jackrabbit.spi.commons.query.PropertyFunctionQueryNode;
-import org.apache.jackrabbit.spi.commons.query.QueryConstants;
 import org.apache.jackrabbit.spi.commons.query.QueryNode;
 import org.apache.jackrabbit.spi.commons.query.QueryNodeFactory;
 import org.apache.jackrabbit.spi.commons.query.QueryRootNode;
@@ -56,10 +55,61 @@ import java.util.Calendar;
 import java.util.List;
 import java.util.Map;
 
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_EQ_GENERAL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_EQ_VALUE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_GE_GENERAL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_GE_VALUE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_GT_GENERAL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_GT_VALUE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_LE_GENERAL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_LE_VALUE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_LIKE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_LT_GENERAL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_LT_VALUE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_NE_GENERAL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_NE_VALUE;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_NOT_NULL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_NULL;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_SIMILAR;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.OPERATION_SPELLCHECK;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.TYPE_POSITION;
+import static org.apache.jackrabbit.spi.commons.query.QueryConstants.TYPE_STRING;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTANDEXPR;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTANYNAME;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTAT;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTCOMPARISONEXPR;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTDECIMALLITERAL;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTDESCENDING;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTDOTDOT;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTDOUBLELITERAL;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTELEMENTNAMEORWILDCARD;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTFUNCTIONCALL;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTINTEGERLITERAL;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTNAMETEST;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTORDERBYCLAUSE;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTORDERMODIFIER;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTORDERSPEC;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTOREXPR;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTPREDICATE;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTPREDICATELIST;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTQNAME;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTQNAMEFORITEMTYPE;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTQNAMELPAR;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTROOT;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTROOTDESCENDANTS;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTSLASHSLASH;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTSTAR;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTSTEPEXPR;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTSTRINGLITERAL;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTTEXTTEST;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTTYPENAME;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTUNARYMINUS;
+import static org.apache.jackrabbit.spi.commons.query.xpath.XPathTreeConstants.JJTXPATH2;
+
 /**
  * Query builder that translates a XPath statement into a query tree structure.
  */
-public class XPathQueryBuilder implements XPathVisitor, XPathTreeConstants {
+public class XPathQueryBuilder implements XPathVisitor {
 
     private static final NameFactory NAME_FACTORY = NameFactoryImpl.getInstance();
     private static final PathFactory PATH_FACTORY = PathFactoryImpl.getInstance();
@@ -392,9 +442,7 @@ public class XPathQueryBuilder implement
                         node.childrenAccept(this, queryNode);
                     } else if (queryNode.getType() == QueryNode.TYPE_NOT) {
                         // is null expression
-                        RelationQueryNode isNull
-                                = factory.createRelationQueryNode(queryNode,
-                                        RelationQueryNode.OPERATION_NULL);
+                        RelationQueryNode isNull = factory.createRelationQueryNode(queryNode, OPERATION_NULL);
                         applyRelativePath(isNull);
                         node.childrenAccept(this, isNull);
                         NotQueryNode notNode = (NotQueryNode) queryNode;
@@ -403,9 +451,7 @@ public class XPathQueryBuilder implement
                         parent.addOperand(isNull);
                     } else {
                         // not null expression
-                        RelationQueryNode notNull =
-                                factory.createRelationQueryNode(queryNode,
-                                        RelationQueryNode.OPERATION_NOT_NULL);
+                        RelationQueryNode notNull = factory.createRelationQueryNode(queryNode, OPERATION_NOT_NULL);
                         applyRelativePath(notNull);
                         node.childrenAccept(this, notNull);
                         ((NAryQueryNode) queryNode).addOperand(notNull);
@@ -418,8 +464,7 @@ public class XPathQueryBuilder implement
                         node.childrenAccept(this, queryNode);
                     } else {
                         // step within a predicate
-                        RelationQueryNode tmp = factory.createRelationQueryNode(
-                                null, RelationQueryNode.OPERATION_NOT_NULL);
+                        RelationQueryNode tmp = factory.createRelationQueryNode(null, OPERATION_NOT_NULL);
                         node.childrenAccept(this, tmp);
                         if (tmpRelPath == null) {
                             tmpRelPath = new PathBuilder();
@@ -626,7 +671,7 @@ public class XPathQueryBuilder implement
                 parent.addOperand(queryNode);
                 break;
             }
-            descendant = (c.getId() == JJTSLASHSLASH || c.getId() == JJTROOTDESCENDANTS);
+            descendant = c.getId() == JJTSLASHSLASH || c.getId() == JJTROOTDESCENDANTS;
         }
 
         node.childrenAccept(this, queryNode);
@@ -635,7 +680,7 @@ public class XPathQueryBuilder implement
     }
 
     /**
-     * Assigns a Name to one of the follwing QueryNodes:
+     * Assigns a Name to one of the following QueryNodes:
      * {@link RelationQueryNode}, {@link DerefQueryNode}, {@link RelationQueryNode},
      * {@link PathQueryNode}, {@link OrderQueryNode}, {@link TextsearchQueryNode}.
      *
@@ -703,29 +748,29 @@ public class XPathQueryBuilder implement
         String opType = node.getValue();
         int type = 0;
         if (opType.equals(OP_EQ)) {
-            type = RelationQueryNode.OPERATION_EQ_VALUE;
+            type = OPERATION_EQ_VALUE;
         } else if (opType.equals(OP_SIGN_EQ)) {
-            type = RelationQueryNode.OPERATION_EQ_GENERAL;
+            type = OPERATION_EQ_GENERAL;
         } else if (opType.equals(OP_GT)) {
-            type = RelationQueryNode.OPERATION_GT_VALUE;
+            type = OPERATION_GT_VALUE;
         } else if (opType.equals(OP_SIGN_GT)) {
-            type = RelationQueryNode.OPERATION_GT_GENERAL;
+            type = OPERATION_GT_GENERAL;
         } else if (opType.equals(OP_GE)) {
-            type = RelationQueryNode.OPERATION_GE_VALUE;
+            type = OPERATION_GE_VALUE;
         } else if (opType.equals(OP_SIGN_GE)) {
-            type = RelationQueryNode.OPERATION_GE_GENERAL;
+            type = OPERATION_GE_GENERAL;
         } else if (opType.equals(OP_LE)) {
-            type = RelationQueryNode.OPERATION_LE_VALUE;
+            type = OPERATION_LE_VALUE;
         } else if (opType.equals(OP_SIGN_LE)) {
-            type = RelationQueryNode.OPERATION_LE_GENERAL;
+            type = OPERATION_LE_GENERAL;
         } else if (opType.equals(OP_LT)) {
-            type = RelationQueryNode.OPERATION_LT_VALUE;
+            type = OPERATION_LT_VALUE;
         } else if (opType.equals(OP_SIGN_LT)) {
-            type = RelationQueryNode.OPERATION_LT_GENERAL;
+            type = OPERATION_LT_GENERAL;
         } else if (opType.equals(OP_NE)) {
-            type = RelationQueryNode.OPERATION_NE_VALUE;
+            type = OPERATION_NE_VALUE;
         } else if (opType.equals(OP_SIGN_NE)) {
-            type = RelationQueryNode.OPERATION_NE_GENERAL;
+            type = OPERATION_NE_GENERAL;
         } else {
             exceptions.add(new InvalidQueryException("Unsupported ComparisonExpr type:" + node.getValue()));
         }
@@ -743,7 +788,7 @@ public class XPathQueryBuilder implement
                     String functionName = node.getFunctionName();
                     if ((functionName.equals(PropertyFunctionQueryNode.LOWER_CASE)
                             || functionName.equals(PropertyFunctionQueryNode.UPPER_CASE))
-                                && rqn.getValueType() != QueryConstants.TYPE_STRING) {
+                                && rqn.getValueType() != TYPE_STRING) {
                         String msg = "Upper and lower case function are only supported with String literals";
                         exceptions.add(new InvalidQueryException(msg));
                     }
@@ -762,7 +807,7 @@ public class XPathQueryBuilder implement
      * Creates the primary path query node.
      *
      * @param node xpath node representing the root of the parsed tree.
-     * @return the path qurey node
+     * @return the path query node
      */
     private PathQueryNode createPathQueryNode(SimpleNode node) {
         root.setLocationNode(factory.createPathQueryNode(root));
@@ -780,14 +825,12 @@ public class XPathQueryBuilder implement
     private void assignValue(SimpleNode node, RelationQueryNode queryNode) {
         if (node.getId() == JJTSTRINGLITERAL) {
             queryNode.setStringValue(unescapeQuotes(node.getValue()));
-        } else if (node.getId() == JJTDECIMALLITERAL) {
-            queryNode.setDoubleValue(Double.parseDouble(node.getValue()));
-        } else if (node.getId() == JJTDOUBLELITERAL) {
+        } else if (node.getId() == JJTDECIMALLITERAL || node.getId() == JJTDOUBLELITERAL) {
             queryNode.setDoubleValue(Double.parseDouble(node.getValue()));
         } else if (node.getId() == JJTINTEGERLITERAL) {
             // if this is an expression that contains position() do not change
             // the type.
-            if (queryNode.getValueType() == QueryConstants.TYPE_POSITION) {
+            if (queryNode.getValueType() == TYPE_POSITION) {
                 queryNode.setPositionValue(Integer.parseInt(node.getValue()));
             } else {
                 queryNode.setLongValue(Long.parseLong(node.getValue()));
@@ -876,8 +919,7 @@ public class XPathQueryBuilder implement
                 // check number of arguments
                 if (node.jjtGetNumChildren() == 3) {
                     if (queryNode instanceof NAryQueryNode) {
-                        RelationQueryNode like = factory.createRelationQueryNode(
-                                queryNode, RelationQueryNode.OPERATION_LIKE);
+                        RelationQueryNode like = factory.createRelationQueryNode(queryNode, OPERATION_LIKE);
                         ((NAryQueryNode) queryNode).addOperand(like);
 
                         // assign property name
@@ -917,9 +959,9 @@ public class XPathQueryBuilder implement
             } else if (FN_POSITION.equals(funName)) {
                 if (queryNode.getType() == QueryNode.TYPE_RELATION) {
                     RelationQueryNode rel = (RelationQueryNode) queryNode;
-                    if (rel.getOperation() == RelationQueryNode.OPERATION_EQ_GENERAL) {
+                    if (rel.getOperation() == OPERATION_EQ_GENERAL) {
                         // set dummy value to set type of relation query node
-                        // will be overwritten when the tree is furhter parsed.
+                        // will be overwritten when the tree is further parsed.
                         rel.setPositionValue(1);
                         rel.addPathElement(PATH_FACTORY.createElement(FN_POSITION_FULL));
                     } else {
@@ -1011,8 +1053,7 @@ public class XPathQueryBuilder implement
                 if (node.jjtGetNumChildren() == 3) {
                     if (queryNode instanceof NAryQueryNode) {
                         NAryQueryNode parent = (NAryQueryNode) queryNode;
-                        RelationQueryNode rel = factory.createRelationQueryNode(
-                                parent, RelationQueryNode.OPERATION_SIMILAR);
+                        RelationQueryNode rel = factory.createRelationQueryNode(parent, OPERATION_SIMILAR);
                         parent.addOperand(rel);
                         // assign path
                         node.jjtGetChild(1).jjtAccept(this, rel);
@@ -1037,27 +1078,23 @@ public class XPathQueryBuilder implement
                 if (node.jjtGetNumChildren() == 2) {
                     if (queryNode instanceof NAryQueryNode) {
                         NAryQueryNode parent = (NAryQueryNode) queryNode;
-                        RelationQueryNode rel = factory.createRelationQueryNode(
-                                parent, RelationQueryNode.OPERATION_SPELLCHECK);
+                        RelationQueryNode rel = factory.createRelationQueryNode(parent, OPERATION_SPELLCHECK);
                         parent.addOperand(rel);
 
                         // get string to check
                         node.jjtGetChild(1).jjtAccept(this, rel);
                         // check if string is set
                         if (rel.getStringValue() == null) {
-                            exceptions.add(new InvalidQueryException(
-                                    "Argument for rep:spellcheck() must be of type string"));
+                            exceptions.add(new InvalidQueryException("Argument for rep:spellcheck() must be of type string"));
                         }
 
                         // set a dummy property name
                         rel.addPathElement(PATH_FACTORY.createElement(NameConstants.JCR_PRIMARYTYPE));
                     } else {
-                        exceptions.add(new InvalidQueryException(
-                                "Unsupported location for rep:spellcheck()"));
+                        exceptions.add(new InvalidQueryException("Unsupported location for rep:spellcheck()"));
                     }
                 } else {
-                    exceptions.add(new InvalidQueryException(
-                            "Wrong number of arguments for rep:spellcheck()"));
+                    exceptions.add(new InvalidQueryException("Wrong number of arguments for rep:spellcheck()"));
                 }
             } else if (queryNode.getType() == QueryNode.TYPE_RELATION) {
                 // use function name as name of a pseudo property in a relation
@@ -1125,7 +1162,7 @@ public class XPathQueryBuilder implement
                 if (c == node) {
                     break;
                 }
-                descendant = (c.getId() == JJTSLASHSLASH || c.getId() == JJTROOTDESCENDANTS);
+                descendant = c.getId() == JJTSLASHSLASH || c.getId() == JJTROOTDESCENDANTS;
             }
         }
         derefNode.setIncludeDescendants(descendant);
@@ -1161,7 +1198,7 @@ public class XPathQueryBuilder implement
      * Returns true if {@code node} has a child node which is the attribute
      * axis.
      *
-     * @param node a node with type {@link #JJTSTEPEXPR}.
+     * @param node
      * @return {@code true} if this step expression uses the attribute axis.
      */
     private static boolean isAttributeAxis(SimpleNode node) {
@@ -1184,7 +1221,7 @@ public class XPathQueryBuilder implement
      *         NameTest
      *             Name foo
      * </pre>
-     * @param node a node with type {@link #JJTNAMETEST}.
+     * @param node 
      * @return {@code true} if the name test {@code node} is on the
      * attribute axis.
      */

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/util/StringCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/util/StringCache.java?rev=1166179&r1=1166178&r2=1166179&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/util/StringCache.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/util/StringCache.java Wed Sep  7 13:45:24 2011
@@ -35,7 +35,7 @@ public class StringCache {
     private static int nextPowerOf2(int x) {
         long i = 1;
         while (i < x && i < Integer.MAX_VALUE / 2) {
-            i += i;
+            i *= 2;
         }
         return (int) i;
     }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueFactoryImpl.java?rev=1166179&r1=1166178&r2=1166179&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueFactoryImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueFactoryImpl.java Wed Sep  7 13:45:24 2011
@@ -154,7 +154,7 @@ public class QValueFactoryImpl extends A
          * The {@code temp} parameter governs whether dynamically allocated
          * resources will be freed explicitly on {@link #discard()}. Note that any
          * dynamically allocated resources (temp file/buffer) will be freed
-         * implicitly once this instance has been gc'ed.
+         * implicitly once this instance has been gc-ed.
          *
          * @param in stream to be represented as a {@code BinaryQValue} instance
          * @param temp flag indicating whether this instance represents a
@@ -279,9 +279,8 @@ public class QValueFactoryImpl extends A
                 // this instance is backed by a 'real' file
                 try {
                     return new FileInputStream(file);
-                } catch (FileNotFoundException fnfe) {
-                    throw new RepositoryException("file backing binary value not found",
-                        fnfe);
+                } catch (FileNotFoundException e) {
+                    throw new RepositoryException("file backing binary value not found", e);
                 }
             } else {
                 return new ByteArrayInputStream(buffer);
@@ -403,7 +402,7 @@ public class QValueFactoryImpl extends A
             in.defaultReadObject();
             boolean hasFile = in.readBoolean();
             if (hasFile) {
-                file = File.createTempFile("binary-qvalue", "bin");
+                file = File.createTempFile("binary QValue", "bin");
 
                 OutputStream out = new FileOutputStream(file);
                 byte[] buffer = new byte[4096];
@@ -416,7 +415,7 @@ public class QValueFactoryImpl extends A
                 }
                 out.close();
             }
-            // deserialized value is always temp
+            // de-serialized value is always temp
             temp = true;
         }
     }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFactoryQImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFactoryQImpl.java?rev=1166179&r1=1166178&r2=1166179&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFactoryQImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFactoryQImpl.java Wed Sep  7 13:45:24 2011
@@ -49,18 +49,18 @@ import java.util.Calendar;
  */
 public class ValueFactoryQImpl implements ValueFactory {
 
-    private final QValueFactory qfactory;
+    private final QValueFactory qValueFactory;
     private final NamePathResolver resolver;
 
     /**
      * Constructs a new {@code ValueFactoryQImpl} based
      * on an existing SPI {@code QValueFactory} and a
      * {@code NamePathResolver}.
-     * @param qfactory wrapped {@code QValueFactory}
+     * @param qValueFactory wrapped {@code QValueFactory}
      * @param resolver wrapped {@code NamePathResolver}
      */
-    public ValueFactoryQImpl(QValueFactory qfactory, NamePathResolver resolver) {
-        this.qfactory = qfactory;
+    public ValueFactoryQImpl(QValueFactory qValueFactory, NamePathResolver resolver) {
+        this.qValueFactory = qValueFactory;
         this.resolver = resolver;
     }
 
@@ -68,20 +68,20 @@ public class ValueFactoryQImpl implement
      * The {@code QValueFactory} that is wrapped by this {@code ValueFactory}
      * instance.
      *
-     * @return qfactory The {@code QValueFactory} wrapped by this instance.
+     * @return  The {@code QValueFactory} wrapped by this instance.
      */
     public QValueFactory getQValueFactory() {
-        return qfactory;
+        return qValueFactory;
     }
 
     /**
      * Create a new {@code Value} based on an existing
      * {@code QValue}
-     * @param qvalue existing {@code QValue}
+     * @param qValue existing {@code QValue}
      * @return a {@code Value} representing the {@code QValue}
      */
-    public Value createValue(QValue qvalue) {
-        return new QValueValue(qvalue, resolver);
+    public Value createValue(QValue qValue) {
+        return new QValueValue(qValue, resolver);
     }
 
     //---------------------------------------------------------< ValueFactory >
@@ -89,7 +89,7 @@ public class ValueFactoryQImpl implement
     @Override
     public Value createValue(String value) {
         try {
-            QValue qvalue = qfactory.create(value, PropertyType.STRING);
+            QValue qvalue = qValueFactory.create(value, PropertyType.STRING);
             return new QValueValue(qvalue, resolver);
         } catch (RepositoryException ex) {
             throw new RuntimeException(ex);
@@ -99,7 +99,7 @@ public class ValueFactoryQImpl implement
     @Override
     public Value createValue(long value) {
         try {
-            QValue qvalue = qfactory.create(value);
+            QValue qvalue = qValueFactory.create(value);
             return new QValueValue(qvalue, resolver);
         } catch (RepositoryException ex) {
             throw new RuntimeException(ex);
@@ -109,7 +109,7 @@ public class ValueFactoryQImpl implement
     @Override
     public Value createValue(double value) {
         try {
-            QValue qvalue = qfactory.create(value);
+            QValue qvalue = qValueFactory.create(value);
             return new QValueValue(qvalue, resolver);
         } catch (RepositoryException ex) {
             throw new RuntimeException(ex);
@@ -119,7 +119,7 @@ public class ValueFactoryQImpl implement
     @Override
     public Value createValue(boolean value) {
         try {
-            QValue qvalue = qfactory.create(value);
+            QValue qvalue = qValueFactory.create(value);
             return new QValueValue(qvalue, resolver);
         } catch (RepositoryException ex) {
             throw new RuntimeException(ex);
@@ -130,7 +130,7 @@ public class ValueFactoryQImpl implement
     public Value createValue(Calendar value) {
         try {
             ISO8601.getYear(value);
-            QValue qvalue = qfactory.create(value);
+            QValue qvalue = qValueFactory.create(value);
             return new QValueValue(qvalue, resolver);
         } catch (RepositoryException ex) {
             throw new RuntimeException(ex);
@@ -140,7 +140,7 @@ public class ValueFactoryQImpl implement
     @Override
     public Value createValue(InputStream value) {
         try {
-            QValue qvalue = qfactory.create(value);
+            QValue qvalue = qValueFactory.create(value);
             return new QValueValue(qvalue, resolver);
         } catch (IOException ex) {
             throw new RuntimeException(ex);
@@ -164,12 +164,12 @@ public class ValueFactoryQImpl implement
 
             if (type == PropertyType.NAME) {
                 Name name = resolver.getQName(value);
-                qvalue = qfactory.create(name);
+                qvalue = qValueFactory.create(name);
             } else if (type == PropertyType.PATH) {
                 Path path = resolver.getQPath(value, false);
-                qvalue = qfactory.create(path);
+                qvalue = qValueFactory.create(path);
             } else {
-                qvalue = qfactory.create(value, type);
+                qvalue = qValueFactory.create(value, type);
             }
 
             return new QValueValue(qvalue, resolver);
@@ -190,7 +190,7 @@ public class ValueFactoryQImpl implement
     public Binary createBinary(InputStream stream) throws RepositoryException {
         // TODO review/optimize/refactor
         try {
-            QValue qvalue = qfactory.create(stream);
+            QValue qvalue = qValueFactory.create(stream);
             return qvalue.getBinary();
         } catch (IOException ex) {
             throw new RuntimeException(ex);
@@ -215,7 +215,7 @@ public class ValueFactoryQImpl implement
     @Override
     public Value createValue(BigDecimal value) {
         try {
-            QValue qvalue = qfactory.create(value);
+            QValue qvalue = qValueFactory.create(value);
             return new QValueValue(qvalue, resolver);
         } catch (RepositoryException ex) {
             throw new RuntimeException(ex);
@@ -224,7 +224,7 @@ public class ValueFactoryQImpl implement
 
     @Override
     public Value createValue(Node value, boolean weak) throws RepositoryException {
-        QValue qvalue = qfactory.create(value.getUUID(), weak ? PropertyType.WEAKREFERENCE : PropertyType.REFERENCE);
+        QValue qvalue = qValueFactory.create(value.getUUID(), weak ? PropertyType.WEAKREFERENCE : PropertyType.REFERENCE);
         return new QValueValue(qvalue, resolver);
     }
 }