jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1166138 [11/12] - in /jackrabbit/sandbox/jackrabbit-mk: jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/ jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/batch/ jackrabbit-spi-commons/src/main/j...
Date Wed, 07 Sep 2011 12:00:20 GMT
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/SelectorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/SelectorImpl.java?rev=1166138&r1=1166137&r2=1166138&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/SelectorImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/SelectorImpl.java Wed Sep  7 12:00:14 2011
@@ -16,13 +16,13 @@
  */
 package org.apache.jackrabbit.spi.commons.query.qom;
 
-import javax.jcr.query.qom.Selector;
-
-import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+
+import javax.jcr.query.qom.Selector;
 
 /**
- * <code>SelectorImpl</code>...
+ * {@code SelectorImpl}...
  */
 public class SelectorImpl extends SourceImpl implements Selector {
 
@@ -67,9 +67,7 @@ public class SelectorImpl extends Source
 
     //---------------------------< SourceImpl >---------------------------------
 
-    /**
-     * {@inheritDoc}
-     */ 
+    @Override
     public SelectorImpl[] getSelectors() {
         return new SelectorImpl[]{this};
     }
@@ -81,6 +79,7 @@ public class SelectorImpl extends Source
      *
      * @return the node type name; non-null
      */
+    @Override
     public String getNodeTypeName() {
         return getJCRName(nodeTypeName);
     }
@@ -93,6 +92,7 @@ public class SelectorImpl extends Source
      *
      * @return the selector name; non-null
      */
+    @Override
     public String getSelectorName() {
         return getJCRName(selectorName);
     }
@@ -100,11 +100,12 @@ public class SelectorImpl extends Source
     //------------------------< AbstractQOMNode >-------------------------------
 
     /**
-     * Accepts a <code>visitor</code> and calls the appropriate visit method
+     * Accepts a {@code visitor} and calls the appropriate visit method
      * depending on the type of this QOM node.
      *
      * @param visitor the visitor.
      */
+    @Override
     public Object accept(QOMTreeVisitor visitor, Object data) throws Exception {
         return visitor.visit(this, data);
     }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/SourceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/SourceImpl.java?rev=1166138&r1=1166137&r2=1166138&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/SourceImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/SourceImpl.java Wed Sep  7 12:00:14 2011
@@ -16,12 +16,12 @@
  */
 package org.apache.jackrabbit.spi.commons.query.qom;
 
-import javax.jcr.query.qom.Source;
-
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 
+import javax.jcr.query.qom.Source;
+
 /**
- * <code>SourceImpl</code>...
+ * {@code SourceImpl}...
  */
 public abstract class SourceImpl extends AbstractQOMNode implements Source {
 

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/StaticOperandImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/StaticOperandImpl.java?rev=1166138&r1=1166137&r2=1166138&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/StaticOperandImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/StaticOperandImpl.java Wed Sep  7 12:00:14 2011
@@ -16,16 +16,14 @@
  */
 package org.apache.jackrabbit.spi.commons.query.qom;
 
-import javax.jcr.query.qom.StaticOperand;
-
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 
+import javax.jcr.query.qom.StaticOperand;
+
 /**
- * <code>StaticOperandImpl</code>...
+ * {@code StaticOperandImpl}...
  */
-public abstract class StaticOperandImpl
-        extends AbstractQOMNode
-        implements StaticOperand {
+public abstract class StaticOperandImpl extends AbstractQOMNode implements StaticOperand {
 
     public StaticOperandImpl(NamePathResolver resolver) {
         super(resolver);

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/UpperCaseImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/UpperCaseImpl.java?rev=1166138&r1=1166137&r2=1166138&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/UpperCaseImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/UpperCaseImpl.java Wed Sep  7 12:00:14 2011
@@ -16,13 +16,13 @@
  */
 package org.apache.jackrabbit.spi.commons.query.qom;
 
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+
 import javax.jcr.query.qom.DynamicOperand;
 import javax.jcr.query.qom.UpperCase;
 
-import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
-
 /**
- * <code>UpperCaseImpl</code>...
+ * {@code UpperCaseImpl}...
  */
 public class UpperCaseImpl extends DynamicOperandImpl implements UpperCase {
 
@@ -41,6 +41,7 @@ public class UpperCaseImpl extends Dynam
      *
      * @return the operand; non-null
      */
+    @Override
     public DynamicOperand getOperand() {
         return operand;
     }
@@ -48,11 +49,12 @@ public class UpperCaseImpl extends Dynam
     //------------------------< AbstractQOMNode >-------------------------------
 
     /**
-     * Accepts a <code>visitor</code> and calls the appropriate visit method
+     * Accepts a {@code visitor} and calls the appropriate visit method
      * depending on the type of this QOM node.
      *
      * @param visitor the visitor.
      */
+    @Override
     public Object accept(QOMTreeVisitor visitor, Object data) throws Exception {
         return visitor.visit(this, data);
     }
@@ -60,7 +62,7 @@ public class UpperCaseImpl extends Dynam
     //------------------------< Object >----------------------------------------
 
     public String toString() {
-        return "UPPER(" + operand + ")";
+        return "UPPER(" + operand + ')';
     }
 
 }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/ASTContainsExpression.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/ASTContainsExpression.java?rev=1166138&r1=1166137&r2=1166138&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/ASTContainsExpression.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/ASTContainsExpression.java Wed Sep  7 12:00:14 2011
@@ -51,6 +51,7 @@ public class ASTContainsExpression exten
     /**
      * Accept the visitor. *
      */
+    @Override
     public Object jjtAccept(JCRSQLParserVisitor visitor, Object data) {
         return visitor.visit(this, data);
     }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/ASTIdentifier.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/ASTIdentifier.java?rev=1166138&r1=1166137&r2=1166138&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/ASTIdentifier.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/ASTIdentifier.java Wed Sep  7 12:00:14 2011
@@ -39,6 +39,7 @@ public class ASTIdentifier extends Simpl
     }
 
   /** Accept the visitor. **/
+  @Override
   public Object jjtAccept(JCRSQLParserVisitor visitor, Object data) {
     return visitor.visit(this, data);
   }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/ASTLiteral.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/ASTLiteral.java?rev=1166138&r1=1166137&r2=1166138&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/ASTLiteral.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/ASTLiteral.java Wed Sep  7 12:00:14 2011
@@ -51,6 +51,7 @@ public class ASTLiteral extends SimpleNo
     /**
      * Accept the visitor. *
      */
+    @Override
     public Object jjtAccept(JCRSQLParserVisitor visitor, Object data) {
         return visitor.visit(this, data);
     }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/ASTPredicate.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/ASTPredicate.java?rev=1166138&r1=1166137&r2=1166138&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/ASTPredicate.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/ASTPredicate.java Wed Sep  7 12:00:14 2011
@@ -22,7 +22,7 @@ public class ASTPredicate extends Simple
 
     private int operationType;
 
-    private boolean negate = false;
+    private boolean negate;
 
     private Name identifier;
 
@@ -39,7 +39,7 @@ public class ASTPredicate extends Simple
   }
 
     public void setOperationType(int type) {
-        this.operationType = type;
+        operationType = type;
     }
 
     public int getOperationType() {
@@ -47,11 +47,11 @@ public class ASTPredicate extends Simple
     }
 
     public void setNegate(boolean b) {
-        this.negate = b;
+        negate = b;
     }
 
     public boolean isNegate() {
-        return this.negate;
+        return negate;
     }
 
     public void setIdentifier(Name identifier) {
@@ -63,7 +63,7 @@ public class ASTPredicate extends Simple
     }
 
     public void setIdentifierOperand(String identifier) {
-        this.identifierOperand = identifier;
+        identifierOperand = identifier;
     }
 
     public String getIdentifierOperand() {
@@ -71,7 +71,7 @@ public class ASTPredicate extends Simple
     }
 
     public void setEscapeString(String esc) {
-        this.escapeString = esc;
+        escapeString = esc;
     }
 
     public String getEscapeString() {
@@ -79,6 +79,7 @@ public class ASTPredicate extends Simple
     }
 
   /** Accept the visitor. **/
+  @Override
   public Object jjtAccept(JCRSQLParserVisitor visitor, Object data) {
     return visitor.visit(this, data);
   }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/DefaultParserVisitor.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/DefaultParserVisitor.java?rev=1166138&r1=1166137&r2=1166138&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/DefaultParserVisitor.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/DefaultParserVisitor.java Wed Sep  7 12:00:14 2011
@@ -18,86 +18,106 @@ package org.apache.jackrabbit.spi.common
 
 /**
  * Implements a {@link JCRSQLParserVisitor} with default method implementations.
- * All visit method simply return the <code>data</code> parameter.
+ * All visit method simply return the {@code data} parameter.
  */
 class DefaultParserVisitor implements JCRSQLParserVisitor {
 
+    @Override
     public Object visit(SimpleNode node, Object data) {
         return data;
     }
 
+    @Override
     public Object visit(ASTQuery node, Object data) {
         return data;
     }
 
+    @Override
     public Object visit(ASTSelectList node, Object data) {
         return data;
     }
 
+    @Override
     public Object visit(ASTFromClause node, Object data) {
         return data;
     }
 
+    @Override
     public Object visit(ASTWhereClause node, Object data) {
         return data;
     }
 
+    @Override
     public Object visit(ASTPredicate node, Object data) {
         return data;
     }
 
+    @Override
     public Object visit(ASTOrExpression node, Object data) {
         return data;
     }
 
+    @Override
     public Object visit(ASTAndExpression node, Object data) {
         return data;
     }
 
+    @Override
     public Object visit(ASTNotExpression node, Object data) {
         return data;
     }
 
+    @Override
     public Object visit(ASTBracketExpression node, Object data) {
         return data;
     }
 
+    @Override
     public Object visit(ASTLiteral node, Object data) {
         return data;
     }
 
+    @Override
     public Object visit(ASTIdentifier node, Object data) {
         return data;
     }
 
+    @Override
     public Object visit(ASTOrderByClause node, Object data) {
         return data;
     }
 
+    @Override
     public Object visit(ASTContainsExpression node, Object data) {
         return data;
     }
 
+    @Override
     public Object visit(ASTOrderSpec node, Object data) {
         return data;
     }
 
+    @Override
     public Object visit(ASTAscendingOrderSpec node, Object data) {
         return data;
     }
 
+    @Override
     public Object visit(ASTDescendingOrderSpec node, Object data) {
         return data;
     }
 
+    @Override
     public Object visit(ASTLowerFunction node, Object data) {
         return data;
     }
 
+    @Override
     public Object visit(ASTUpperFunction node, Object data) {
         return data;
     }
 
+    @Override
     public Object visit(ASTExcerptFunction node, Object data) {
         return data;
     }

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=1166138&r1=1166137&r2=1166138&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 12:00:14 2011
@@ -77,7 +77,7 @@ public class JCRSQLQueryBuilder implemen
     /**
      * Map of reusable JCRSQL parser instances indexed by NamespaceResolver.
      */
-    private static Map parsers = new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK);
+    private static final Map parsers = new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK);
 
     /**
      * The root node of the sql query syntax tree
@@ -92,7 +92,7 @@ public class JCRSQLQueryBuilder implemen
     /**
      * To resolve QNames
      */
-    private NameResolver resolver;
+    private final NameResolver resolver;
 
     /**
      * Query node to gather the constraints defined in the WHERE clause
@@ -115,30 +115,30 @@ public class JCRSQLQueryBuilder implemen
     private final QueryNodeFactory factory;
 
     /**
-     * Creates a new <code>JCRSQLQueryBuilder</code>.
+     * Creates a new {@code JCRSQLQueryBuilder}.
      *
      * @param statement the root node of the SQL syntax tree.
      * @param resolver  a namespace resolver to use for names in the
-     *                  <code>statement</code>.
+     *                  {@code statement}.
      * @param factory   the query node factory.
      */
     private JCRSQLQueryBuilder(ASTQuery statement,
                                NameResolver resolver,
                                QueryNodeFactory factory) {
-        this.stmt = statement;
+        stmt = statement;
         this.resolver = resolver;
         this.factory = factory;
-        this.constraintNode =  factory.createAndQueryNode(null);
+        constraintNode =  factory.createAndQueryNode(null);
     }
 
     /**
-     * Creates a <code>QueryNode</code> tree from a SQL <code>statement</code>
-     * using the passed query node <code>factory</code>.
+     * Creates a {@code QueryNode} tree from a SQL {@code statement}
+     * using the passed query node {@code factory}.
      *
      * @param statement the SQL statement.
      * @param resolver  the namespace resolver to use.
-     * @return the <code>QueryNode</code> tree.
-     * @throws InvalidQueryException if <code>statement</code> is malformed.
+     * @return the {@code QueryNode} tree.
+     * @throws InvalidQueryException if {@code statement} is malformed.
      */
     public static QueryRootNode createQuery(String statement,
                                             NameResolver resolver,
@@ -188,10 +188,10 @@ public class JCRSQLQueryBuilder implemen
     }
 
     /**
-     * Parses the statement and returns the root node of the <code>QueryNode</code>
+     * Parses the statement and returns the root node of the {@code QueryNode}
      * tree.
      *
-     * @return the root node of the <code>QueryNode</code> tree.
+     * @return the root node of the {@code QueryNode} tree.
      */
     private QueryRootNode getRootNode() {
         if (root == null) {
@@ -202,11 +202,13 @@ public class JCRSQLQueryBuilder implemen
 
     //----------------< JCRSQLParserVisitor >------------------------------------
 
+    @Override
     public Object visit(SimpleNode node, Object data) {
         // do nothing, should never be called actually
         return data;
     }
 
+    @Override
     public Object visit(ASTQuery node, Object data) {
         root = factory.createQueryRootNode();
         root.setLocationNode(factory.createPathQueryNode(root));
@@ -217,7 +219,7 @@ public class JCRSQLQueryBuilder implemen
         // use //* if no path has been set
         PathQueryNode pathNode = root.getLocationNode();
         pathNode.setAbsolute(true);
-        if (pathConstraints.size() == 0) {
+        if (pathConstraints.isEmpty()) {
             LocationStepQueryNode step = factory.createLocationStepQueryNode(pathNode);
             step.setNameTest(null);
             step.setIncludeDescendants(true);
@@ -227,8 +229,8 @@ public class JCRSQLQueryBuilder implemen
                 while (pathConstraints.size() > 1) {
                     // merge path nodes
                     MergingPathQueryNode path = null;
-                    for (Iterator it = pathConstraints.iterator(); it.hasNext();) {
-                        path = (MergingPathQueryNode) it.next();
+                    for (Object pathConstraint : pathConstraints) {
+                        path = (MergingPathQueryNode) pathConstraint;
                         if (path.needsMerge()) {
                             break;
                         } else {
@@ -250,11 +252,11 @@ public class JCRSQLQueryBuilder implemen
             }
             MergingPathQueryNode path = (MergingPathQueryNode) pathConstraints.get(0);
             LocationStepQueryNode[] steps = path.getPathSteps();
-            for (int i = 0; i < steps.length; i++) {
+            for (LocationStepQueryNode step1 : steps) {
                 LocationStepQueryNode step = factory.createLocationStepQueryNode(pathNode);
-                step.setNameTest(steps[i].getNameTest());
-                step.setIncludeDescendants(steps[i].getIncludeDescendants());
-                step.setIndex(steps[i].getIndex());
+                step.setNameTest(step1.getNameTest());
+                step.setIncludeDescendants(step1.getIncludeDescendants());
+                step.setIndex(step1.getIndex());
                 pathNode.addPathStep(step);
             }
         }
@@ -280,15 +282,18 @@ public class JCRSQLQueryBuilder implemen
         return root;
     }
 
+    @Override
     public Object visit(ASTSelectList node, Object data) {
         final QueryRootNode root = (QueryRootNode) data;
 
         node.childrenAccept(new DefaultParserVisitor() {
+            @Override
             public Object visit(ASTIdentifier node, Object data) {
                 root.addSelectProperty(node.getName());
                 return data;
             }
 
+            @Override
             public Object visit(ASTExcerptFunction node, Object data) {
                 root.addSelectProperty(NameFactoryImpl.getInstance().create(Name.NS_REP_URI, "excerpt(.)"));
                 return data;
@@ -298,10 +303,12 @@ public class JCRSQLQueryBuilder implemen
         return data;
     }
 
+    @Override
     public Object visit(ASTFromClause node, Object data) {
         QueryRootNode root = (QueryRootNode) data;
 
         return node.childrenAccept(new DefaultParserVisitor() {
+            @Override
             public Object visit(ASTIdentifier node, Object data) {
                 if (!node.getName().equals(NameConstants.NT_BASE)) {
                     // node is either primary or mixin node type
@@ -312,10 +319,12 @@ public class JCRSQLQueryBuilder implemen
         }, root);
     }
 
+    @Override
     public Object visit(ASTWhereClause node, Object data) {
         return node.childrenAccept(this, constraintNode);
     }
 
+    @Override
     public Object visit(ASTPredicate node, Object data) {
         NAryQueryNode parent = (NAryQueryNode) data;
 
@@ -326,6 +335,7 @@ public class JCRSQLQueryBuilder implemen
             final Name[] tmp = new Name[2];
             final ASTLiteral[] value = new ASTLiteral[1];
             node.childrenAccept(new DefaultParserVisitor() {
+                @Override
                 public Object visit(ASTIdentifier node, Object data) {
                     if (tmp[0] == null) {
                         tmp[0] = node.getName();
@@ -335,16 +345,19 @@ public class JCRSQLQueryBuilder implemen
                     return data;
                 }
 
+                @Override
                 public Object visit(ASTLiteral node, Object data) {
                     value[0] = node;
                     return data;
                 }
 
+                @Override
                 public Object visit(ASTLowerFunction node, Object data) {
                     getIdentifier(node);
                     return data;
                 }
 
+                @Override
                 public Object visit(ASTUpperFunction node, Object data) {
                     getIdentifier(node);
                     return data;
@@ -403,7 +416,8 @@ public class JCRSQLQueryBuilder implemen
                         // backslash is the escape character we use internally
                         pattern.setValue(translateEscaping(pattern.getValue(), node.getEscapeString().charAt(0), '\\'));
                     } else {
-                        throw new IllegalArgumentException("ESCAPE string value must have length 1: '" + node.getEscapeString() + "'");
+                        throw new IllegalArgumentException("ESCAPE string value must have length 1: '" +
+                                node.getEscapeString() + '\'');
                     }
                 } else {
                     // no escape character specified.
@@ -453,6 +467,7 @@ public class JCRSQLQueryBuilder implemen
         return data;
     }
 
+    @Override
     public Object visit(ASTOrExpression node, Object data) {
         NAryQueryNode parent = (NAryQueryNode) data;
         OrQueryNode orQuery = factory.createOrQueryNode(parent);
@@ -465,6 +480,7 @@ public class JCRSQLQueryBuilder implemen
         return parent;
     }
 
+    @Override
     public Object visit(ASTAndExpression node, Object data) {
         NAryQueryNode parent = (NAryQueryNode) data;
         AndQueryNode andQuery = factory.createAndQueryNode(parent);
@@ -477,6 +493,7 @@ public class JCRSQLQueryBuilder implemen
         return parent;
     }
 
+    @Override
     public Object visit(ASTNotExpression node, Object data) {
         NAryQueryNode parent = (NAryQueryNode) data;
         NotQueryNode notQuery = factory.createNotQueryNode(parent);
@@ -489,6 +506,7 @@ public class JCRSQLQueryBuilder implemen
         return parent;
     }
 
+    @Override
     public Object visit(ASTBracketExpression node, Object data) {
         // bracket expression only has influence on how the syntax tree
         // is created.
@@ -496,16 +514,19 @@ public class JCRSQLQueryBuilder implemen
         return node.childrenAccept(this, data);
     }
 
+    @Override
     public Object visit(ASTLiteral node, Object data) {
         // do nothing
         return data;
     }
 
+    @Override
     public Object visit(ASTIdentifier node, Object data) {
         // do nothing
         return data;
     }
 
+    @Override
     public Object visit(ASTOrderByClause node, Object data) {
         QueryRootNode root = (QueryRootNode) data;
 
@@ -515,6 +536,7 @@ public class JCRSQLQueryBuilder implemen
         return root;
     }
 
+    @Override
     public Object visit(ASTOrderSpec node, Object data) {
         OrderQueryNode order = (OrderQueryNode) data;
 
@@ -522,6 +544,7 @@ public class JCRSQLQueryBuilder implemen
 
         // collect identifier
         node.childrenAccept(new DefaultParserVisitor() {
+            @Override
             public Object visit(ASTIdentifier node, Object data) {
                 identifier[0] = node.getName();
                 return data;
@@ -543,17 +566,20 @@ public class JCRSQLQueryBuilder implemen
         return data;
     }
 
+    @Override
     public Object visit(ASTAscendingOrderSpec node, Object data) {
         // do nothing ascending is default anyway
         return data;
     }
 
+    @Override
     public Object visit(ASTDescendingOrderSpec node, Object data) {
         OrderQueryNode.OrderSpec spec = (OrderQueryNode.OrderSpec) data;
         spec.setAscending(false);
         return data;
     }
 
+    @Override
     public Object visit(ASTContainsExpression node, Object data) {
         NAryQueryNode parent = (NAryQueryNode) data;
         try {
@@ -573,6 +599,7 @@ public class JCRSQLQueryBuilder implemen
         return parent;
     }
 
+    @Override
     public Object visit(ASTLowerFunction node, Object data) {
         RelationQueryNode parent = (RelationQueryNode) data;
         if (parent.getValueType() != QueryConstants.TYPE_STRING) {
@@ -583,6 +610,7 @@ public class JCRSQLQueryBuilder implemen
         return parent;
     }
 
+    @Override
     public Object visit(ASTUpperFunction node, Object data) {
         RelationQueryNode parent = (RelationQueryNode) data;
         if (parent.getValueType() != QueryConstants.TYPE_STRING) {
@@ -593,6 +621,7 @@ public class JCRSQLQueryBuilder implemen
         return parent;
     }
 
+    @Override
     public Object visit(ASTExcerptFunction node, Object data) {
         // do nothing
         return data;
@@ -603,13 +632,13 @@ public class JCRSQLQueryBuilder implemen
     /**
      * Creates a new {@link org.apache.jackrabbit.spi.commons.query.RelationQueryNode}.
      *
-     * @param parent        the parent node for the created <code>RelationQueryNode</code>.
+     * @param parent        the parent node for the created {@code RelationQueryNode}.
      * @param propertyName  the property name for the relation.
      * @param operationType the operation type.
      * @param literal       the literal value for the relation or
-     *                      <code>null</code> if the relation does not have a
+     *                      {@code null} if the relation does not have a
      *                      literal (e.g. IS NULL).
-     * @return a <code>RelationQueryNode</code>.
+     * @return a {@code RelationQueryNode}.
      * @throws IllegalArgumentException if the literal value does not conform
      *                                  to its type. E.g. a malformed String representation of a date.
      */
@@ -673,7 +702,7 @@ public class JCRSQLQueryBuilder implemen
     }
 
     /**
-     * Creates <code>LocationStepQueryNode</code>s from a <code>path</code>.
+     * Creates {@code LocationStepQueryNode}s from a {@code path}.
      *
      * @param path      the path pattern
      * @param operation the type of the parent node
@@ -691,26 +720,17 @@ public class JCRSQLQueryBuilder implemen
 
         String[] names = path.split("/");
 
-        for (int i = 0; i < names.length; i++) {
-            if (names[i].length() == 0) {
-                if (i == 0) {
-                    // root
-                    pathNode.addPathStep(factory.createLocationStepQueryNode(pathNode));
-                } else {
-                    // descendant '//' -> invalid path
-                    // todo throw or ignore?
-                    // we currently do not throw and add location step for an
-                    // empty name (which is basically the root node)
-                    pathNode.addPathStep(factory.createLocationStepQueryNode(pathNode));
-                }
+        for (String name1 : names) {
+            if (name1.length() == 0) {
+                pathNode.addPathStep(factory.createLocationStepQueryNode(pathNode));
             } else {
-                int idx = names[i].indexOf('[');
+                int idx = name1.indexOf('[');
                 String name;
                 int index = LocationStepQueryNode.NONE;
                 if (idx > -1) {
                     // contains index
-                    name = names[i].substring(0, idx);
-                    String suffix = names[i].substring(idx);
+                    name = name1.substring(0, idx);
+                    String suffix = name1.substring(idx);
                     String indexStr = suffix.substring(1, suffix.length() - 1);
                     if (indexStr.equals("%")) {
                         // select all same name siblings
@@ -718,8 +738,9 @@ public class JCRSQLQueryBuilder implemen
                     } else {
                         try {
                             index = Integer.parseInt(indexStr);
-                        } catch (NumberFormatException e) {
-                            log.warn("Unable to parse index for path element: " + names[i]);
+                        }
+                        catch (NumberFormatException e) {
+                            log.warn("Unable to parse index for path element: " + name1);
                         }
                     }
                     if (name.equals("%")) {
@@ -729,7 +750,7 @@ public class JCRSQLQueryBuilder implemen
                     // no index specified
                     // - index defaults to 1 if there is an explicit name test
                     // - index defaults to NONE if name test is %
-                    name = names[i];
+                    name = name1;
                     if (name.equals("%")) {
                         name = null;
                     } else {
@@ -740,9 +761,11 @@ public class JCRSQLQueryBuilder implemen
                 if (name != null) {
                     try {
                         qName = resolver.getQName(name);
-                    } catch (NamespaceException e) {
+                    }
+                    catch (NamespaceException e) {
                         throw new IllegalArgumentException("Illegal name: " + name);
-                    } catch (NameException e) {
+                    }
+                    catch (NameException e) {
                         throw new IllegalArgumentException("Illegal name: " + name);
                     }
                 }
@@ -761,21 +784,21 @@ public class JCRSQLQueryBuilder implemen
     }
 
     /**
-     * Translates a pattern using the escape character <code>from</code> into
-     * a pattern using the escape character <code>to</code>.
+     * Translates a pattern using the escape character {@code from} into
+     * a pattern using the escape character {@code to}.
      *
      * @param pattern the pattern to translate
      * @param from    the currently used escape character.
      * @param to      the new escape character to use.
-     * @return the new pattern using the escape character <code>to</code>.
+     * @return the new pattern using the escape character {@code to}.
      */
     private static String translateEscaping(String pattern, char from, char to) {
         // if escape characters are the same OR pattern does not contain any
         // escape characters -> simply return pattern as is.
-        if (from == to || (pattern.indexOf(from) < 0 && pattern.indexOf(to) < 0)) {
+        if (from == to || pattern.indexOf(from) < 0 && pattern.indexOf(to) < 0) {
             return pattern;
         }
-        StringBuffer translated = new StringBuffer(pattern.length());
+        StringBuilder translated = new StringBuilder(pattern.length());
         boolean escaped = false;
         for (int i = 0; i < pattern.length(); i++) {
             if (pattern.charAt(i) == from) {
@@ -804,40 +827,40 @@ public class JCRSQLQueryBuilder implemen
     }
 
     /**
-     * Extends the <code>PathQueryNode</code> with merging capability. A
-     * <code>PathQueryNode</code> <code>n1</code> can be merged with another
-     * node <code>n2</code> in the following case:
+     * Extends the {@code PathQueryNode} with merging capability. A
+     * {@code PathQueryNode} {@code n1} can be merged with another
+     * node {@code n2} in the following case:
      * <p/>
-     * <code>n1</code> contains a location step at position <code>X</code> with
+     * {@code n1} contains a location step at position {@code X} with
      * a name test that matches any node and has the descending flag set. Where
-     * <code>X</code> &lt; number of location steps.
-     * <code>n2</code> contains no location step to match any node name and
+     * {@code X} &lt; number of location steps.
+     * {@code n2} contains no location step to match any node name and
      * the sequence of name tests is the same as the sequence of name tests
-     * of <code>n1</code>.
-     * The merged node then contains a location step at position <code>X</code>
-     * with the name test of the location step at position <code>X+1</code> and
+     * of {@code n1}.
+     * The merged node then contains a location step at position {@code X}
+     * with the name test of the location step at position {@code X+1} and
      * the descending flag set.
      * <p/>
      * The following path patterns:<br/>
-     * <code>/foo/%/bar</code> OR <code>/foo/bar</code><br/>
+     * {@code /foo/%/bar} OR {@code /foo/bar}<br/>
      * are merged into:<br/>
-     * <code>/foo//bar</code>.
+     * {@code /foo//bar}.
      * <p/>
      * The path patterns:<br/>
-     * <code>/foo/%</code> AND NOT <code>/foo/%/%</code><br/>
+     * {@code /foo/%} AND NOT {@code /foo/%/%}<br/>
      * are merged into:<br/>
-     * <code>/foo/*</code>
+     * {@code /foo/*}
      */
     private static class MergingPathQueryNode extends PathQueryNode {
 
         /**
          * The operation type of the parent node
          */
-        private int operation;
+        private final int operation;
 
         /**
-         * Creates a new <code>MergingPathQueryNode</code> with the operation
-         * tpye of a parent node. <code>operation</code> must be one of:
+         * Creates a new {@code MergingPathQueryNode} with the operation
+         * tpye 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}.
@@ -856,7 +879,7 @@ public class JCRSQLQueryBuilder implemen
         }
 
         /**
-         * Merges this node with a node from <code>nodes</code>. If a merge
+         * Merges this node with a node from {@code nodes}. If a merge
          * is not possible an NoSuchElementException is thrown.
          *
          * @param nodes the nodes to try to merge with.
@@ -876,9 +899,9 @@ public class JCRSQLQueryBuilder implemen
          * <p/>
          * Example:<br/>
          * The path patterns:<br/>
-         * <code>/foo/%</code> AND NOT <code>/foo/%/%</code><br/>
+         * {@code /foo/%} AND NOT {@code /foo/%/%}<br/>
          * are merged into:<br/>
-         * <code>/foo/*</code>
+         * {@code /foo/*}
          *
          * @param nodes the nodes to merge with.
          * @return the merged nodes.
@@ -904,24 +927,26 @@ public class JCRSQLQueryBuilder implemen
                 throw new NoSuchElementException("Merging not possible");
             }
             int size = operands.size();
-            LocationStepQueryNode n1 = (LocationStepQueryNode) operands.get(size - 1);
-            LocationStepQueryNode n2 = (LocationStepQueryNode) operands.get(size - 2);
+            LocationStepQueryNode n1 = operands.get(size - 1);
+            LocationStepQueryNode n2 = operands.get(size - 2);
             if (n1.getNameTest() != null || n2.getNameTest() != null
                     || !n1.getIncludeDescendants() || !n2.getIncludeDescendants()) {
                 throw new NoSuchElementException("Merging not possible");
             }
             // find a node to merge with
             MergingPathQueryNode matchedNode = null;
-            for (int i = 0; i < nodes.length; i++) {
-                if (nodes[i].operands.size() == operands.size() - 1) {
+            for (MergingPathQueryNode node : nodes) {
+                if (node.operands.size() == operands.size() - 1) {
                     boolean match = true;
                     for (int j = 0; j < operands.size() - 1 && match; j++) {
-                        LocationStepQueryNode step = (LocationStepQueryNode) operands.get(j);
-                        LocationStepQueryNode other = (LocationStepQueryNode) nodes[i].operands.get(j);
-                        match &= (step.getNameTest() == null) ? other.getNameTest() == null : step.getNameTest().equals(other.getNameTest());
+                        LocationStepQueryNode step = operands.get(j);
+                        LocationStepQueryNode other = node.operands.get(j);
+                        match &= step.getNameTest() == null
+                            ? other.getNameTest() == null
+                            : step.getNameTest().equals(other.getNameTest());
                     }
                     if (match) {
-                        matchedNode = nodes[i];
+                        matchedNode = node;
                         break;
                     }
                 }
@@ -931,7 +956,7 @@ public class JCRSQLQueryBuilder implemen
             }
             // change descendants flag to only match child nodes
             // that's the result of the merge.
-            ((LocationStepQueryNode) matchedNode.operands.get(matchedNode.operands.size() - 1)).setIncludeDescendants(false);
+            matchedNode.operands.get(matchedNode.operands.size() - 1).setIncludeDescendants(false);
             return nodes;
         }
 
@@ -941,9 +966,9 @@ public class JCRSQLQueryBuilder implemen
          * <p/>
          * Example:<br/>
          * The following path patterns:<br/>
-         * <code>/foo/%/bar</code> OR <code>/foo/bar</code><br/>
+         * {@code /foo/%/bar} OR {@code /foo/bar}<br/>
          * are merged into:<br/>
-         * <code>/foo//bar</code>.
+         * {@code /foo//bar}.
          *
          * @param nodes the node to merge.
          * @return the merged nodes.
@@ -969,19 +994,19 @@ public class JCRSQLQueryBuilder implemen
             }
 
             MergingPathQueryNode matchedNode = null;
-            for (int i = 0; i < nodes.length; i++) {
+            for (MergingPathQueryNode node : nodes) {
                 // loop over the steps and compare the names
-                if (nodes[i].operands.size() == compacted.operands.size()) {
+                if (node.operands.size() == compacted.operands.size()) {
                     boolean match = true;
                     Iterator compactedSteps = compacted.operands.iterator();
-                    Iterator otherSteps = nodes[i].operands.iterator();
+                    Iterator otherSteps = node.operands.iterator();
                     while (match && compactedSteps.hasNext()) {
                         LocationStepQueryNode n1 = (LocationStepQueryNode) compactedSteps.next();
                         LocationStepQueryNode n2 = (LocationStepQueryNode) otherSteps.next();
-                        match &= (n1.getNameTest() == null) ? n2.getNameTest() == null : n1.getNameTest().equals(n2.getNameTest());
+                        match &= n1.getNameTest() == null ? n2.getNameTest() == null : n1.getNameTest().equals(n2.getNameTest());
                     }
                     if (match) {
-                        matchedNode = nodes[i];
+                        matchedNode = node;
                         break;
                     }
                 }
@@ -997,15 +1022,14 @@ public class JCRSQLQueryBuilder implemen
         }
 
         /**
-         * Returns <code>true</code> if this node needs merging; <code>false</code>
+         * Returns {@code true} if this node needs merging; {@code false}
          * otherwise.
          *
-         * @return <code>true</code> if this node needs merging; <code>false</code>
+         * @return {@code true} if this node needs merging; {@code false}
          *         otherwise.
          */
         boolean needsMerge() {
-            for (Iterator it = operands.iterator(); it.hasNext();) {
-                LocationStepQueryNode step = (LocationStepQueryNode) it.next();
+            for (LocationStepQueryNode step : operands) {
                 if (step.getIncludeDescendants() && step.getNameTest() == null) {
                     return true;
                 }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/QueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/QueryBuilder.java?rev=1166138&r1=1166137&r2=1166138&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/QueryBuilder.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/QueryBuilder.java Wed Sep  7 12:00:14 2011
@@ -32,16 +32,17 @@ public class QueryBuilder implements Que
     /**
      * @inheritDoc
      */
-    public QueryRootNode createQueryTree(String statement,
-                                         NameResolver resolver,
-                                         QueryNodeFactory factory)
+    @Override
+    public QueryRootNode createQueryTree(String statement, NameResolver resolver, QueryNodeFactory factory)
             throws InvalidQueryException {
+
         return JCRSQLQueryBuilder.createQuery(statement, resolver, factory);
     }
 
     /**
      * @inheritDoc
      */
+    @Override
     public boolean canHandle(String language) {
         return Query.SQL.equals(language);
     }
@@ -50,6 +51,7 @@ public class QueryBuilder implements Que
      * This builder supports {@link Query#SQL}.
      * @inheritDoc
      */
+    @Override
     public String[] getSupportedLanguages() {
         return new String[]{Query.SQL};
     }
@@ -57,8 +59,8 @@ public class QueryBuilder implements Que
     /**
      * @inheritDoc
      */
-    public String toString(QueryRootNode root, NameResolver resolver)
-            throws InvalidQueryException {
+    @Override
+    public String toString(QueryRootNode root, NameResolver resolver) throws InvalidQueryException {
         return JCRSQLQueryBuilder.toString(root, resolver);
     }
 }

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=1166138&r1=1166137&r2=1166138&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 12:00:14 2011
@@ -16,16 +16,6 @@
  */
 package org.apache.jackrabbit.spi.commons.query.sql;
 
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Iterator;
-import java.util.List;
-import java.util.TimeZone;
-
-import javax.jcr.NamespaceException;
-import javax.jcr.RepositoryException;
-import javax.jcr.query.InvalidQueryException;
-
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.commons.conversion.NameResolver;
@@ -38,6 +28,7 @@ import org.apache.jackrabbit.spi.commons
 import org.apache.jackrabbit.spi.commons.query.NotQueryNode;
 import org.apache.jackrabbit.spi.commons.query.OrQueryNode;
 import org.apache.jackrabbit.spi.commons.query.OrderQueryNode;
+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;
@@ -48,6 +39,15 @@ import org.apache.jackrabbit.spi.commons
 import org.apache.jackrabbit.spi.commons.query.TextsearchQueryNode;
 import org.apache.jackrabbit.util.ISO8601;
 
+import javax.jcr.NamespaceException;
+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;
+
 /**
  * Implements the query node tree serialization into a String.
  */
@@ -77,21 +77,21 @@ class QueryFormat implements QueryNodeVi
             throws RepositoryException {
         this.resolver = resolver;
         statement = root.accept(this, new StringBuffer()).toString();
-        if (exceptions.size() > 0) {
+        if (!exceptions.isEmpty()) {
             Exception e = (Exception) exceptions.get(0);
             throw new InvalidQueryException(e.getMessage(), e);
         }
     }
 
     /**
-     * Creates a SQL <code>String</code> representation of the QueryNode tree
-     * argument <code>root</code>.
+     * Creates a SQL {@code String} representation of the QueryNode tree
+     * argument {@code root}.
      *
      * @param root     the query node tree.
      * @param resolver to resolve QNames.
      * @return the SQL string representation of the QueryNode tree.
      * @throws InvalidQueryException the query node tree cannot be represented
-     *                               as a SQL <code>String</code>.
+     *                               as a SQL {@code String}.
      */
     public static String toString(QueryRootNode root, NameResolver resolver)
             throws InvalidQueryException {
@@ -114,6 +114,7 @@ class QueryFormat implements QueryNodeVi
 
     //-------------< QueryNodeVisitor interface >-------------------------------
 
+    @Override
     public Object visit(QueryRootNode node, Object data) throws RepositoryException {
         StringBuffer sb = (StringBuffer) data;
         try {
@@ -124,9 +125,9 @@ class QueryFormat implements QueryNodeVi
                 sb.append(" *");
             } else {
                 String comma = "";
-                for (int i = 0; i < selectProps.length; i++) {
-                    sb.append(comma).append(" ");
-                    appendName(selectProps[i], resolver, sb);
+                for (Name selectProp : selectProps) {
+                    sb.append(comma).append(' ');
+                    appendName(selectProp, resolver, sb);
                     comma = ",";
                 }
             }
@@ -140,18 +141,18 @@ class QueryFormat implements QueryNodeVi
             LocationStepQueryNode[] steps = node.getLocationNode().getPathSteps();
             QueryNode[] predicates = steps[steps.length - 1].getPredicates();
             // are there any relevant predicates?
-            for (int i = 0; i < predicates.length; i++) {
-                if (predicates[i].getType() != QueryNode.TYPE_NODETYPE) {
+            for (QueryNode predicate : predicates) {
+                if (predicate.getType() != QueryNode.TYPE_NODETYPE) {
                     tmp.append(" WHERE ");
                 }
             }
             String and = "";
-            for (int i = 0; i < predicates.length; i++) {
-                if (predicates[i].getType() != QueryNode.TYPE_NODETYPE) {
+            for (QueryNode predicate : predicates) {
+                if (predicate.getType() != QueryNode.TYPE_NODETYPE) {
                     tmp.append(and);
                     and = " AND ";
                 }
-                predicates[i].accept(this, tmp);
+                predicate.accept(this, tmp);
             }
 
             // node types have been collected by now
@@ -159,13 +160,13 @@ class QueryFormat implements QueryNodeVi
             int ntCount = 0;
             for (Iterator it = nodeTypes.iterator(); it.hasNext(); ntCount++) {
                 Name nt = (Name) it.next();
-                sb.append(comma).append(" ");
+                sb.append(comma).append(' ');
                 appendName(nt, resolver, sb);
                 comma = ",";
             }
 
             if (ntCount == 0) {
-                sb.append(" ");
+                sb.append(' ');
                 sb.append(resolver.getJCRName(NameConstants.NT_BASE));
             }
 
@@ -199,6 +200,7 @@ class QueryFormat implements QueryNodeVi
         return sb;
     }
 
+    @Override
     public Object visit(OrQueryNode node, Object data) throws RepositoryException {
         StringBuffer sb = (StringBuffer) data;
         boolean bracket = false;
@@ -208,21 +210,22 @@ class QueryFormat implements QueryNodeVi
             bracket = true;
         }
         if (bracket) {
-            sb.append("(");
+            sb.append('(');
         }
         String or = "";
         QueryNode[] operands = node.getOperands();
-        for (int i = 0; i < operands.length; i++) {
+        for (QueryNode operand : operands) {
             sb.append(or);
-            operands[i].accept(this, sb);
+            operand.accept(this, sb);
             or = " OR ";
         }
         if (bracket) {
-            sb.append(")");
+            sb.append(')');
         }
         return sb;
     }
 
+    @Override
     public Object visit(AndQueryNode node, Object data) throws RepositoryException {
         StringBuffer sb = (StringBuffer) data;
         boolean bracket = false;
@@ -230,14 +233,14 @@ class QueryFormat implements QueryNodeVi
             bracket = true;
         }
         if (bracket) {
-            sb.append("(");
+            sb.append('(');
         }
         String and = "";
         QueryNode[] operands = node.getOperands();
-        for (int i = 0; i < operands.length; i++) {
+        for (QueryNode operand : operands) {
             sb.append(and);
             int len = sb.length();
-            operands[i].accept(this, sb);
+            operand.accept(this, sb);
             // check if something has been written at all
             // might have been a node type query node
             if (sb.length() - len > 0) {
@@ -247,11 +250,12 @@ class QueryFormat implements QueryNodeVi
             }
         }
         if (bracket) {
-            sb.append(")");
+            sb.append(')');
         }
         return sb;
     }
 
+    @Override
     public Object visit(NotQueryNode node, Object data) throws RepositoryException {
         StringBuffer sb = (StringBuffer) data;
         QueryNode[] operands = node.getOperands();
@@ -262,6 +266,7 @@ class QueryFormat implements QueryNodeVi
         return sb;
     }
 
+    @Override
     public Object visit(ExactQueryNode node, Object data) {
         StringBuffer sb = (StringBuffer) data;
         try {
@@ -269,22 +274,24 @@ class QueryFormat implements QueryNodeVi
         } catch (NamespaceException e) {
             exceptions.add(e);
         }
-        sb.append("='").append(node.getValue()).append("'");
+        sb.append("='").append(node.getValue()).append('\'');
         return sb;
     }
 
+    @Override
     public Object visit(NodeTypeQueryNode node, Object data) {
         nodeTypes.add(node.getValue());
         return data;
     }
 
+    @Override
     public Object visit(TextsearchQueryNode node, Object data) {
         StringBuffer sb = (StringBuffer) data;
         // escape quote
         String query = node.getQuery().replaceAll("'", "''");
         sb.append("CONTAINS(");
         if (node.getRelativePath() == null) {
-            sb.append("*");
+            sb.append('*');
         } else {
             if (node.getRelativePath().getLength() > 1
                     || !node.getReferencesProperty()) {
@@ -302,35 +309,36 @@ class QueryFormat implements QueryNodeVi
         return sb;
     }
 
+    @Override
     public Object visit(PathQueryNode node, Object data) throws RepositoryException {
         StringBuffer sb = (StringBuffer) data;
         try {
             if (containsDescendantOrSelf(node)) {
-                sb.append("(");
+                sb.append('(');
                 sb.append(resolver.getJCRName(NameConstants.JCR_PATH));
                 sb.append(" LIKE '");
                 LocationStepQueryNode[] steps = node.getPathSteps();
-                for (int i = 0; i < steps.length; i++) {
-                    if (steps[i].getNameTest() == null
-                            || steps[i].getNameTest().getLocalName().length() > 0) {
+                for (LocationStepQueryNode step : steps) {
+                    if (step.getNameTest() == null
+                            || step.getNameTest().getLocalName().length() > 0) {
                         sb.append('/');
                     }
-                    if (steps[i].getIncludeDescendants()) {
+                    if (step.getIncludeDescendants()) {
                         sb.append("%/");
                     }
-                    steps[i].accept(this, sb);
+                    step.accept(this, sb);
                 }
                 sb.append('\'');
                 sb.append(" OR ");
                 sb.append(resolver.getJCRName(NameConstants.JCR_PATH));
                 sb.append(" LIKE '");
-                for (int i = 0; i < steps.length; i++) {
-                    if (steps[i].getNameTest() == null
-                            || steps[i].getNameTest().getLocalName().length() > 0) {
+                for (LocationStepQueryNode step : steps) {
+                    if (step.getNameTest() == null
+                            || step.getNameTest().getLocalName().length() > 0) {
                         sb.append('/');
                     }
-                    if (steps[i].getNameTest() != null) {
-                        steps[i].accept(this, sb);
+                    if (step.getNameTest() != null) {
+                        step.accept(this, sb);
                     }
                 }
                 sb.append("')");
@@ -339,12 +347,12 @@ class QueryFormat implements QueryNodeVi
                 sb.append(" LIKE '");
                 StringBuffer path = new StringBuffer();
                 LocationStepQueryNode[] steps = node.getPathSteps();
-                for (int i = 0; i < steps.length; i++) {
-                    if (steps[i].getNameTest() == null
-                            || steps[i].getNameTest().getLocalName().length() > 0) {
+                for (LocationStepQueryNode step : steps) {
+                    if (step.getNameTest() == null
+                            || step.getNameTest().getLocalName().length() > 0) {
                         path.append('/');
                     }
-                    steps[i].accept(this, path);
+                    step.accept(this, path);
                 }
                 sb.append(path);
                 sb.append('\'');
@@ -357,12 +365,12 @@ class QueryFormat implements QueryNodeVi
                 sb.append(resolver.getJCRName(NameConstants.JCR_PATH));
                 sb.append(" LIKE '");
                 LocationStepQueryNode[] steps = node.getPathSteps();
-                for (int i = 0; i < steps.length; i++) {
-                    if (steps[i].getNameTest() == null
-                            || steps[i].getNameTest().getLocalName().length() > 0) {
+                for (LocationStepQueryNode step : steps) {
+                    if (step.getNameTest() == null
+                            || step.getNameTest().getLocalName().length() > 0) {
                         sb.append('/');
                     }
-                    steps[i].accept(this, sb);
+                    step.accept(this, sb);
                 }
                 sb.append('\'');
             }
@@ -372,10 +380,11 @@ class QueryFormat implements QueryNodeVi
         return sb;
     }
 
+    @Override
     public Object visit(LocationStepQueryNode node, Object data) {
         StringBuffer sb = (StringBuffer) data;
         if (node.getNameTest() == null) {
-            sb.append("%");
+            sb.append('%');
         } else {
             if (node.getNameTest().getLocalName().length() > 0) {
                 try {
@@ -397,18 +406,20 @@ class QueryFormat implements QueryNodeVi
         return sb;
     }
 
+    @Override
     public Object visit(DerefQueryNode node, Object data) {
         exceptions.add(new InvalidQueryException("jcr:deref() function not supported in SQL"));
         return data;
     }
 
+    @Override
     public Object visit(RelationQueryNode node, Object data) throws RepositoryException {
         StringBuffer sb = (StringBuffer) data;
         try {
             StringBuffer propName = new StringBuffer();
             PathQueryNode relPath = node.getRelativePath();
             if (relPath == null) {
-                propName.append(".");
+                propName.append('.');
             } else if (relPath.getPathSteps().length > 1) {
                 exceptions.add(new InvalidQueryException("Child axis not supported in SQL"));
                 return data;
@@ -457,11 +468,11 @@ class QueryFormat implements QueryNodeVi
                 sb.append(propName);
                 sb.append(", ");
                 appendValue(node, sb);
-                sb.append(")");
+                sb.append(')');
             } else if (node.getOperation() == OPERATION_SPELLCHECK) {
                 sb.append("SPELLCHECK(");
                 appendValue(node, sb);
-                sb.append(")");
+                sb.append(')');
             } else {
                 exceptions.add(new InvalidQueryException("Invalid operation: " + node.getOperation()));
             }
@@ -475,6 +486,7 @@ class QueryFormat implements QueryNodeVi
         return sb;
     }
 
+    @Override
     public Object visit(OrderQueryNode node, Object data) {
         StringBuffer sb = (StringBuffer) data;
         sb.append(" ORDER BY");
@@ -482,15 +494,15 @@ class QueryFormat implements QueryNodeVi
         if (specs.length > 0) {
             try {
                 String comma = "";
-                for (int i = 0; i < specs.length; i++) {
-                    sb.append(comma).append(" ");
-                    Path propPath = specs[i].getPropertyPath();
+                for (OrderSpec spec : specs) {
+                    sb.append(comma).append(' ');
+                    Path propPath = spec.getPropertyPath();
                     if (propPath.getLength() > 1) {
                         exceptions.add(new InvalidQueryException("SQL does not support relative paths in order by clause"));
                         return sb;
                     }
                     appendName(propPath.getName(), resolver, sb);
-                    if (!specs[i].isAscending()) {
+                    if (!spec.isAscending()) {
                         sb.append(" DESC");
                     }
                     comma = ",";
@@ -504,13 +516,14 @@ class QueryFormat implements QueryNodeVi
         return sb;
     }
 
+    @Override
     public Object visit(PropertyFunctionQueryNode node, Object data) {
         StringBuffer sb = (StringBuffer) data;
         String functionName = node.getFunctionName();
         if (functionName.equals(PropertyFunctionQueryNode.LOWER_CASE)) {
-            sb.insert(0, "LOWER(").append(")");
+            sb.insert(0, "LOWER(").append(')');
         } else if (functionName.equals(PropertyFunctionQueryNode.UPPER_CASE)) {
-            sb.insert(0, "UPPER(").append(")");
+            sb.insert(0, "UPPER(").append(')');
         } else {
             exceptions.add(new InvalidQueryException("Unsupported function: " + functionName));
         }
@@ -520,16 +533,16 @@ class QueryFormat implements QueryNodeVi
     //------------------------< internal >--------------------------------------
 
     /**
-     * Appends the <code>name</code> to the <code>StringBuffer</code>
-     * <code>b</code> using the <code>NamespaceResolver</code>
-     * <code>resolver</code>. The <code>name</code> is put in double quotes
-     * if the local part of <code>name</code> contains a space character.
+     * Appends the {@code name} to the {@code StringBuffer}
+     * {@code b} using the {@code NamespaceResolver}
+     * {@code resolver}. The {@code name} is put in double quotes
+     * if the local part of {@code name} contains a space character.
      *
-     * @param name     the <code>Name</code> to print.
-     * @param resolver to resolve <code>name</code>.
-     * @param b        where to output the <code>name</code>.
-     * @throws NamespaceException if <code>name</code> contains a uri
-     *                                   that is not declared in <code>resolver</code>.
+     * @param name     the {@code Name} to print.
+     * @param resolver to resolve {@code name}.
+     * @param b        where to output the {@code name}.
+     * @throws NamespaceException if {@code name} contains a uri
+     *                                   that is not declared in {@code resolver}.
      */
     private static void appendName(Name name,
                                    NameResolver resolver,
@@ -551,11 +564,11 @@ class QueryFormat implements QueryNodeVi
         } else if (node.getValueType() == TYPE_DOUBLE) {
             b.append(node.getDoubleValue());
         } else if (node.getValueType() == TYPE_STRING) {
-            b.append("'").append(node.getStringValue().replaceAll("'", "''")).append("'");
+            b.append('\'').append(node.getStringValue().replaceAll("'", "''")).append('\'');
         } else if (node.getValueType() == TYPE_DATE || node.getValueType() == TYPE_TIMESTAMP) {
             Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
             cal.setTime(node.getDateValue());
-            b.append("TIMESTAMP '").append(ISO8601.format(cal)).append("'");
+            b.append("TIMESTAMP '").append(ISO8601.format(cal)).append('\'');
         } else {
             exceptions.add(new InvalidQueryException("Invalid type: " + node.getValueType()));
         }
@@ -563,19 +576,19 @@ class QueryFormat implements QueryNodeVi
     }
 
     /**
-     * Returns <code>true</code> if <code>path</code> contains exactly one
+     * Returns {@code true} if {@code path} contains exactly one
      * step with a descendant-or-self axis and an explicit name test; returns
-     * <code>false</code> otherwise.
+     * {@code false} otherwise.
      *
      * @param path the path node.
-     * @return <code>true</code> if <code>path</code> contains exactly one
+     * @return {@code true} if {@code path} contains exactly one
      *         step with a descendant-or-self axis.
      */
     private static boolean containsDescendantOrSelf(PathQueryNode path) {
         LocationStepQueryNode[] steps = path.getPathSteps();
         int count = 0;
-        for (int i = 0; i < steps.length; i++) {
-            if (steps[i].getNameTest() != null && steps[i].getIncludeDescendants()) {
+        for (LocationStepQueryNode step : steps) {
+            if (step.getNameTest() != null && step.getIncludeDescendants()) {
                 count++;
             }
         }
@@ -583,13 +596,13 @@ class QueryFormat implements QueryNodeVi
     }
 
     /**
-     * Returns <code>true</code> if <code>path</code> contains exactly one
+     * Returns {@code true} if {@code path} contains exactly one
      * location step which matches all node names. That is, matches any children
      * of a given node. That location step must be the last one in the sequence
      * of location steps.
      *
      * @param path the path node.
-     * @return <code>true</code> if the last step matches any node name.
+     * @return {@code true} if the last step matches any node name.
      */
     private static boolean containsAllChildrenMatch(PathQueryNode path) {
         LocationStepQueryNode[] steps = path.getPathSteps();

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryBuilder.java?rev=1166138&r1=1166137&r2=1166138&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryBuilder.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryBuilder.java Wed Sep  7 12:00:14 2011
@@ -32,16 +32,17 @@ public class QueryBuilder implements Que
     /**
      * @inheritDoc
      */
-    public QueryRootNode createQueryTree(String statement,
-                                         NameResolver resolver,
-                                         QueryNodeFactory factory)
+    @Override
+    public QueryRootNode createQueryTree(String statement, NameResolver resolver, QueryNodeFactory factory)
             throws InvalidQueryException {
+
         return XPathQueryBuilder.createQuery(statement, resolver, factory);
     }
 
     /**
      * @inheritDoc
      */
+    @Override
     public boolean canHandle(String language) {
         return Query.XPATH.equals(language);
     }
@@ -50,6 +51,7 @@ public class QueryBuilder implements Que
      * This builder supports {@link Query#XPATH}.
      * @inheritDoc
      */
+    @Override
     public String[] getSupportedLanguages() {
         return new String[]{Query.XPATH};
     }
@@ -57,8 +59,8 @@ public class QueryBuilder implements Que
     /**
      * @inheritDoc
      */
-    public String toString(QueryRootNode root, NameResolver resolver)
-            throws InvalidQueryException {
+    @Override
+    public String toString(QueryRootNode root, NameResolver resolver) throws InvalidQueryException {
         return XPathQueryBuilder.toString(root, resolver);
     }
 }

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=1166138&r1=1166137&r2=1166138&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 12:00:14 2011
@@ -16,17 +16,9 @@
  */
 package org.apache.jackrabbit.spi.commons.query.xpath;
 
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-import java.util.TimeZone;
-
-import javax.jcr.NamespaceException;
-import javax.jcr.RepositoryException;
-import javax.jcr.query.InvalidQueryException;
-
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.Path.Element;
 import org.apache.jackrabbit.spi.commons.conversion.NameResolver;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
 import org.apache.jackrabbit.spi.commons.query.AndQueryNode;
@@ -38,6 +30,7 @@ import org.apache.jackrabbit.spi.commons
 import org.apache.jackrabbit.spi.commons.query.NotQueryNode;
 import org.apache.jackrabbit.spi.commons.query.OrQueryNode;
 import org.apache.jackrabbit.spi.commons.query.OrderQueryNode;
+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;
@@ -49,6 +42,14 @@ import org.apache.jackrabbit.spi.commons
 import org.apache.jackrabbit.util.ISO8601;
 import org.apache.jackrabbit.util.ISO9075;
 
+import javax.jcr.NamespaceException;
+import javax.jcr.RepositoryException;
+import javax.jcr.query.InvalidQueryException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+import java.util.TimeZone;
+
 /**
  * Implements the query node tree serialization into a String.
  */
@@ -73,21 +74,21 @@ class QueryFormat implements QueryNodeVi
             throws RepositoryException {
         this.resolver = resolver;
         statement = root.accept(this, new StringBuffer()).toString();
-        if (exceptions.size() > 0) {
+        if (!exceptions.isEmpty()) {
             Exception e = (Exception) exceptions.get(0);
             throw new InvalidQueryException(e.getMessage(), e);
         }
     }
 
     /**
-     * Creates a XPath <code>String</code> representation of the QueryNode tree
-     * argument <code>root</code>.
+     * Creates a XPath {@code String} representation of the QueryNode tree
+     * argument {@code root}.
      *
      * @param root     the query node tree.
      * @param resolver to resolve QNames.
      * @return the XPath string representation of the QueryNode tree.
      * @throws InvalidQueryException the query node tree cannot be represented
-     *                               as a XPath <code>String</code>.
+     *                               as a XPath {@code String}.
      */
     public static String toString(QueryRootNode root, NameResolver resolver)
             throws InvalidQueryException {
@@ -110,6 +111,7 @@ class QueryFormat implements QueryNodeVi
 
     //-------------< QueryNodeVisitor interface >-------------------------------
 
+    @Override
     public Object visit(QueryRootNode node, Object data) throws RepositoryException {
         StringBuffer sb = (StringBuffer) data;
         node.getLocationNode().accept(this, data);
@@ -121,13 +123,14 @@ class QueryFormat implements QueryNodeVi
                 sb.append('(');
             }
             String pipe = "";
-            for (int i = 0; i < selectProps.length; i++) {
+            for (Name selectProp : selectProps) {
                 try {
                     sb.append(pipe);
                     sb.append('@');
-                    sb.append(resolver.getJCRName(encode(selectProps[i])));
+                    sb.append(resolver.getJCRName(encode(selectProp)));
                     pipe = "|";
-                } catch (NamespaceException e) {
+                }
+                catch (NamespaceException e) {
                     exceptions.add(e);
                 }
             }
@@ -141,6 +144,7 @@ class QueryFormat implements QueryNodeVi
         return data;
     }
 
+    @Override
     public Object visit(OrQueryNode node, Object data) throws RepositoryException {
         StringBuffer sb = (StringBuffer) data;
         boolean bracket = false;
@@ -148,42 +152,44 @@ class QueryFormat implements QueryNodeVi
             bracket = true;
         }
         if (bracket) {
-            sb.append("(");
+            sb.append('(');
         }
         String or = "";
         QueryNode[] operands = node.getOperands();
-        for (int i = 0; i < operands.length; i++) {
+        for (QueryNode operand : operands) {
             sb.append(or);
-            operands[i].accept(this, sb);
+            operand.accept(this, sb);
             or = " or ";
         }
         if (bracket) {
-            sb.append(")");
+            sb.append(')');
         }
         return sb;
     }
 
+    @Override
     public Object visit(AndQueryNode node, Object data) throws RepositoryException {
         StringBuffer sb = (StringBuffer) data;
         String and = "";
         QueryNode[] operands = node.getOperands();
-        for (int i = 0; i < operands.length; i++) {
+        for (QueryNode operand : operands) {
             sb.append(and);
-            operands[i].accept(this, sb);
+            operand.accept(this, sb);
             and = " and ";
         }
         return sb;
     }
 
+    @Override
     public Object visit(NotQueryNode node, Object data) throws RepositoryException {
         StringBuffer sb = (StringBuffer) data;
         QueryNode[] operands = node.getOperands();
         if (operands.length > 0) {
             try {
                 sb.append(resolver.getJCRName(XPathQueryBuilder.FN_NOT_10));
-                sb.append("(");
+                sb.append('(');
                 operands[0].accept(this, sb);
-                sb.append(")");
+                sb.append(')');
             } catch (NamespaceException e) {
                 exceptions.add(e);
             }
@@ -191,9 +197,10 @@ class QueryFormat implements QueryNodeVi
         return sb;
     }
 
+    @Override
     public Object visit(ExactQueryNode node, Object data) {
         StringBuffer sb = (StringBuffer) data;
-        sb.append("@");
+        sb.append('@');
         try {
             Name name = encode(node.getPropertyName());
             sb.append(resolver.getJCRName(name));
@@ -202,23 +209,25 @@ class QueryFormat implements QueryNodeVi
         } catch (NamespaceException e) {
             exceptions.add(e);
         }
-        sb.append("'");
+        sb.append('\'');
         return sb;
     }
 
+    @Override
     public Object visit(NodeTypeQueryNode node, Object data) {
         // handled in location step visit
         return data;
     }
 
+    @Override
     public Object visit(TextsearchQueryNode node, Object data) {
         StringBuffer sb = (StringBuffer) data;
         try {
             sb.append(resolver.getJCRName(XPathQueryBuilder.JCR_CONTAINS));
-            sb.append("(");
+            sb.append('(');
             Path relPath = node.getRelativePath();
             if (relPath == null) {
-                sb.append(".");
+                sb.append('.');
             } else {
                 Path.Element[] elements = relPath.getElements();
                 String slash = "";
@@ -226,16 +235,16 @@ class QueryFormat implements QueryNodeVi
                     sb.append(slash);
                     slash = "/";
                     if (node.getReferencesProperty() && i == elements.length - 1) {
-                        sb.append("@");
+                        sb.append('@');
                     }
                     if (elements[i].getName().equals(RelationQueryNode.STAR_NAME_TEST)) {
-                        sb.append("*");
+                        sb.append('*');
                     } else {
                         Name n = encode(elements[i].getName());
                         sb.append(resolver.getJCRName(n));
                     }
                     if (elements[i].getIndex() != 0) {
-                        sb.append("[").append(elements[i].getIndex()).append("]");
+                        sb.append('[').append(elements[i].getIndex()).append(']');
                     }
                 }
             }
@@ -248,21 +257,23 @@ class QueryFormat implements QueryNodeVi
         return sb;
     }
 
+    @Override
     public Object visit(PathQueryNode node, Object data) throws RepositoryException {
         StringBuffer sb = (StringBuffer) data;
         if (node.isAbsolute()) {
-            sb.append("/");
+            sb.append('/');
         }
         LocationStepQueryNode[] steps = node.getPathSteps();
         String slash = "";
-        for (int i = 0; i < steps.length; i++) {
+        for (LocationStepQueryNode step : steps) {
             sb.append(slash);
-            steps[i].accept(this, sb);
+            step.accept(this, sb);
             slash = "/";
         }
         return sb;
     }
 
+    @Override
     public Object visit(LocationStepQueryNode node, Object data) throws RepositoryException {
         StringBuffer sb = (StringBuffer) data;
         if (node.getIncludeDescendants()) {
@@ -270,6 +281,7 @@ class QueryFormat implements QueryNodeVi
         }
         final Name[] nodeType = new Name[1];
         node.acceptOperands(new DefaultQueryNodeVisitor() {
+            @Override
             public Object visit(NodeTypeQueryNode node, Object data) {
                 nodeType[0] = node.getValue();
                 return data;
@@ -281,7 +293,7 @@ class QueryFormat implements QueryNodeVi
         }
 
         if (node.getNameTest() == null) {
-            sb.append("*");
+            sb.append('*');
         } else {
             try {
                 if (node.getNameTest().getLocalName().length() == 0) {
@@ -301,25 +313,26 @@ class QueryFormat implements QueryNodeVi
             } catch (NamespaceException e) {
                 exceptions.add(e);
             }
-            sb.append(")");
+            sb.append(')');
         }
 
         if (node.getIndex() != LocationStepQueryNode.NONE) {
             sb.append('[').append(node.getIndex()).append(']');
         }
         QueryNode[] predicates = node.getPredicates();
-        for (int i = 0; i < predicates.length; i++) {
+        for (QueryNode predicate : predicates) {
             // ignore node type query nodes
-            if (predicates[i].getType() == QueryNode.TYPE_NODETYPE) {
+            if (predicate.getType() == QueryNode.TYPE_NODETYPE) {
                 continue;
             }
             sb.append('[');
-            predicates[i].accept(this, sb);
+            predicate.accept(this, sb);
             sb.append(']');
         }
         return sb;
     }
 
+    @Override
     public Object visit(DerefQueryNode node, Object data) {
         StringBuffer sb = (StringBuffer) data;
         try {
@@ -328,7 +341,7 @@ class QueryFormat implements QueryNodeVi
             sb.append(resolver.getJCRName(encode(node.getRefProperty())));
             sb.append(", '");
             if (node.getNameTest() == null) {
-                sb.append("*");
+                sb.append('*');
             } else {
                 sb.append(resolver.getJCRName(encode(node.getNameTest())));
             }
@@ -339,6 +352,7 @@ class QueryFormat implements QueryNodeVi
         return sb;
     }
 
+    @Override
     public Object visit(RelationQueryNode node, Object data) throws RepositoryException {
         StringBuffer sb = (StringBuffer) data;
         try {
@@ -347,7 +361,7 @@ class QueryFormat implements QueryNodeVi
             // only encode if not position function
             PathQueryNode relPath = node.getRelativePath();
             if (relPath == null) {
-                propPath.append(".");
+                propPath.append('.');
             } else if (relPath.getNumOperands() > 0 && relPath.getPathSteps()[0].getNameTest().equals(XPathQueryBuilder.FN_POSITION_FULL)) {
                 propPath.append(resolver.getJCRName(XPathQueryBuilder.FN_POSITION_FULL));
             } else {
@@ -358,7 +372,7 @@ class QueryFormat implements QueryNodeVi
                     slash = "/";
                     if (i == steps.length - 1 && node.getOperation() != OPERATION_SIMILAR) {
                         // last step
-                        propPath.append("@");
+                        propPath.append('@');
                     }
                     visit(steps[i], propPath);
                 }
@@ -393,9 +407,9 @@ class QueryFormat implements QueryNodeVi
                 appendValue(node, sb);
             } else if (node.getOperation() == OPERATION_LIKE) {
                 sb.append(resolver.getJCRName(XPathQueryBuilder.JCR_LIKE));
-                sb.append("(").append(propPath).append(", ");
+                sb.append('(').append(propPath).append(", ");
                 appendValue(node, sb);
-                sb.append(")");
+                sb.append(')');
             } else if (node.getOperation() == OPERATION_LT_GENERAL) {
                 sb.append(propPath).append(" < ");
                 appendValue(node, sb);
@@ -410,19 +424,19 @@ class QueryFormat implements QueryNodeVi
                 appendValue(node, sb);
             } else if (node.getOperation() == OPERATION_NULL) {
                 sb.append(resolver.getJCRName(XPathQueryBuilder.FN_NOT));
-                sb.append("(").append(propPath).append(")");
+                sb.append('(').append(propPath).append(')');
             } else if (node.getOperation() == OPERATION_NOT_NULL) {
                 sb.append(propPath);
             } else if (node.getOperation() == OPERATION_SIMILAR) {
                 sb.append(resolver.getJCRName(XPathQueryBuilder.REP_SIMILAR));
-                sb.append("(").append(propPath).append(", ");
+                sb.append('(').append(propPath).append(", ");
                 appendValue(node, sb);
-                sb.append(")");
+                sb.append(')');
             } else if (node.getOperation() == OPERATION_SPELLCHECK) {
                 sb.append(resolver.getJCRName(XPathQueryBuilder.REP_SPELLCHECK));
-                sb.append("(");
+                sb.append('(');
                 appendValue(node, sb);
-                sb.append(")");
+                sb.append(')');
             } else {
                 exceptions.add(new InvalidQueryException("Invalid operation: " + node.getOperation()));
             }
@@ -432,30 +446,31 @@ class QueryFormat implements QueryNodeVi
         return sb;
     }
 
+    @Override
     public Object visit(OrderQueryNode node, Object data) {
         StringBuffer sb = (StringBuffer) data;
         sb.append(" order by");
         OrderQueryNode.OrderSpec[] specs = node.getOrderSpecs();
         String comma = "";
         try {
-            for (int i = 0; i < specs.length; i++) {
+            for (OrderSpec spec : specs) {
                 sb.append(comma);
-                Path propPath = specs[i].getPropertyPath();
-                Path.Element[] elements = propPath.getElements();
-                sb.append(" ");
+                Path propPath = spec.getPropertyPath();
+                Element[] elements = propPath.getElements();
+                sb.append(' ');
                 String slash = "";
                 for (int j = 0; j < elements.length; j++) {
                     sb.append(slash);
                     slash = "/";
-                    Path.Element element = elements[j];
+                    Element element = elements[j];
                     Name name = encode(element.getName());
                     if (j == elements.length - 1) {
                         // last
-                        sb.append("@");
+                        sb.append('@');
                     }
                     sb.append(resolver.getJCRName(name));
                 }
-                if (!specs[i].isAscending()) {
+                if (!spec.isAscending()) {
                     sb.append(" descending");
                 }
                 comma = ",";
@@ -466,16 +481,17 @@ class QueryFormat implements QueryNodeVi
         return data;
     }
 
+    @Override
     public Object visit(PropertyFunctionQueryNode node, Object data) {
         StringBuffer sb = (StringBuffer) data;
         String functionName = node.getFunctionName();
         try {
             if (functionName.equals(PropertyFunctionQueryNode.LOWER_CASE)) {
-                sb.insert(0, resolver.getJCRName(XPathQueryBuilder.FN_LOWER_CASE) + "(");
-                sb.append(")");
+                sb.insert(0, resolver.getJCRName(XPathQueryBuilder.FN_LOWER_CASE) + '(');
+                sb.append(')');
             } else if (functionName.equals(PropertyFunctionQueryNode.UPPER_CASE)) {
-                sb.insert(0, resolver.getJCRName(XPathQueryBuilder.FN_UPPER_CASE) + "(");
-                sb.append(")");
+                sb.insert(0, resolver.getJCRName(XPathQueryBuilder.FN_UPPER_CASE) + '(');
+                sb.append(')');
             } else {
                 exceptions.add(new InvalidQueryException("Unsupported function: " + functionName));
             }
@@ -488,8 +504,8 @@ class QueryFormat implements QueryNodeVi
     //----------------------------< internal >----------------------------------
 
     /**
-     * Appends the value of a relation node to the <code>StringBuffer</code>
-     * <code>sb</code>.
+     * Appends the value of a relation node to the {@code StringBuffer}
+     * {@code sb}.
      *
      * @param node the relation node.
      * @param b    where to append the value.
@@ -503,7 +519,7 @@ class QueryFormat implements QueryNodeVi
         } else if (node.getValueType() == TYPE_DOUBLE) {
             b.append(node.getDoubleValue());
         } else if (node.getValueType() == TYPE_STRING) {
-            b.append("'").append(node.getStringValue().replaceAll("'", "''")).append("'");
+            b.append('\'').append(node.getStringValue().replaceAll("'", "''")).append('\'');
         } else if (node.getValueType() == TYPE_DATE || node.getValueType() == TYPE_TIMESTAMP) {
             Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
             cal.setTime(node.getDateValue());



Mime
View raw message