jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1299751 - in /jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query: ./ qom/tree/ reader/
Date Mon, 12 Mar 2012 17:36:24 GMT
Author: mduerig
Date: Mon Mar 12 17:36:23 2012
New Revision: 1299751

URL: http://svn.apache.org/viewvc?rev=1299751&view=rev
Log:
Microkernel based prototype of JCR implementation (WIP)
- use String.isEmpty()
- use character literals where possible
- make methods static where possible
- fix duplicate override annotation

Modified:
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/ParserSQL2.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/XPathToSQL2Converter.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/AndImpl.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/ComparisonImpl.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/JoinImpl.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/JoinType.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/Operator.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/SelectorImpl.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/reader/TraversingReader.java

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/ParserSQL2.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/ParserSQL2.java?rev=1299751&r1=1299750&r2=1299751&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/ParserSQL2.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/ParserSQL2.java
Mon Mar 12 17:36:23 2012
@@ -479,7 +479,7 @@ public class ParserSQL2 {
             read();
             String name = readName();
             if (readIf(":")) {
-                name = name + ":" + readName();
+                name = name + ':' + readName();
             }
             BindVariableValue var = bindVariables.get(name);
             if (var == null) {

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/XPathToSQL2Converter.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/XPathToSQL2Converter.java?rev=1299751&r1=1299750&r2=1299751&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/XPathToSQL2Converter.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/XPathToSQL2Converter.java
Mon Mar 12 17:36:23 2012
@@ -16,11 +16,12 @@
  */
 package org.apache.jackrabbit.query;
 
-import java.math.BigDecimal;
-import java.util.ArrayList;
+import org.apache.jackrabbit.mk.util.PathUtils;
+
 import javax.jcr.RepositoryException;
 import javax.jcr.query.InvalidQueryException;
-import org.apache.jackrabbit.mk.util.PathUtils;
+import java.math.BigDecimal;
+import java.util.ArrayList;
 
 /**
  * This class can can convert a XPATH query to a SQL2 query.
@@ -117,14 +118,14 @@ public class XPathToSQL2Converter {
                 break;
             }
         }
-        if (path.equals("")) {
+        if (path.isEmpty()) {
             // no condition
         } else if (path.equals("%")) {
             // ignore
         } else {
             Condition c = new Condition(new Property("jcr:path"), "like", Literal.newString(path));
             if (!includeChildren && path.endsWith("%")) {
-                Condition c2 = new Condition(new Property("jcr:path"), "like", Literal.newString(path
+ "/"));
+                Condition c2 = new Condition(new Property("jcr:path"), "like", Literal.newString(path
+ '/'));
                 c = new Condition(c, "and", new Condition(null, "not", c2));
             } else if (includeChildren && !path.endsWith("%")) {
                 Condition c2 = new Condition(new Property("jcr:path"), "like", Literal.newString(path
+ "/%"));
@@ -151,7 +152,7 @@ public class XPathToSQL2Converter {
         }
         StringBuilder buff = new StringBuilder("select ");
         if (columnList.size() == 0) {
-            buff.append("*");
+            buff.append('*');
         } else {
             for (int i = 0; i < columnList.size(); i++) {
                 if (i > 0) {
@@ -161,7 +162,7 @@ public class XPathToSQL2Converter {
             }
         }
         buff.append(" from ");
-        buff.append("[" + from + "]");
+        buff.append('[' + from + ']');
         if (condition != null) {
             buff.append(" where ").append(condition);
         }
@@ -269,7 +270,7 @@ public class XPathToSQL2Converter {
             if (currentTokenType != VALUE_NUMBER) {
                 throw getSyntaxError();
             }
-            Literal l = Literal.newNumber("-" + currentToken);
+            Literal l = Literal.newNumber('-' + currentToken);
             read();
             return l;
         } else if (readIf("+")) {
@@ -652,7 +653,7 @@ public class XPathToSQL2Converter {
             this.name = name;
         }
         public String toString() {
-            return "[" + name + "]";
+            return '[' + name + ']';
         }
     }
 
@@ -662,7 +663,7 @@ public class XPathToSQL2Converter {
             this.expr = expr;
         }
         public String toString() {
-            return "(" + expr + ")";
+            return "(" + expr + ')';
         }
     }
 

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/AndImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/AndImpl.java?rev=1299751&r1=1299750&r2=1299751&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/AndImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/AndImpl.java
Mon Mar 12 17:36:23 2012
@@ -33,13 +33,11 @@ public class AndImpl extends ConstraintI
     }
 
     @Override
-    @Override
     public ConstraintImpl getConstraint1() {
         return constraint1;
     }
 
     @Override
-    @Override
     public ConstraintImpl getConstraint2() {
         return constraint2;
     }

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/ComparisonImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/ComparisonImpl.java?rev=1299751&r1=1299750&r2=1299751&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/ComparisonImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/ComparisonImpl.java
Mon Mar 12 17:36:23 2012
@@ -18,10 +18,11 @@
  */
 package org.apache.jackrabbit.query.qom.tree;
 
+import org.h2.message.DbException;
+
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.query.qom.Comparison;
-import org.h2.message.DbException;
 
 /**
  * The implementation of the corresponding JCR interface.
@@ -83,7 +84,7 @@ public class ComparisonImpl extends Cons
         }
     }
 
-    private boolean evaluateLike(Value v1, Value v2) throws RepositoryException {
+    private static boolean evaluateLike(Value v1, Value v2) throws RepositoryException {
         LikePattern like = new LikePattern(v2.getString());
         return like.matches(v1.getString());
     }
@@ -124,7 +125,7 @@ public class ComparisonImpl extends Cons
             return compareAt(value, 0, 0, value.length(), patternChars, patternTypes);
         }
 
-        private boolean compare(char[] pattern, String s, int pi, int si) {
+        private static boolean compare(char[] pattern, String s, int pi, int si) {
             return pattern[pi] == s.charAt(si);
         }
 

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/JoinImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/JoinImpl.java?rev=1299751&r1=1299750&r2=1299751&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/JoinImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/JoinImpl.java
Mon Mar 12 17:36:23 2012
@@ -68,7 +68,7 @@ public class JoinImpl extends SourceImpl
 
     @Override
     public String getPlan() {
-        return left.getPlan() + " " + joinType.name() + " JOIN " + right.getPlan();
+        return left.getPlan() + ' ' + joinType.name() + " JOIN " + right.getPlan();
     }
 
     public String toString() {

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/JoinType.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/JoinType.java?rev=1299751&r1=1299750&r2=1299751&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/JoinType.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/JoinType.java
Mon Mar 12 17:36:23 2012
@@ -76,7 +76,7 @@ public enum JoinType {
      * @return SQL join, <code>left join right</code>
      */
     public String formatSql(Object left, Object right, Object condition) {
-        return left + " " + sql + " " + right + " ON " + condition;
+        return left + " " + sql + ' ' + right + " ON " + condition;
     }
 
     /**

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/Operator.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/Operator.java?rev=1299751&r1=1299750&r2=1299751&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/Operator.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/Operator.java
Mon Mar 12 17:36:23 2012
@@ -96,9 +96,9 @@ public enum Operator {
      */
     public String formatXpath(String a, String b) {
         if (this == LIKE) {
-            return "jcr:like(" + a + ", " + b + ")";
+            return "jcr:like(" + a + ", " + b + ')';
         } else {
-            return a + " " + xpath + " " + b;
+            return a + ' ' + xpath + ' ' + b;
         }
     }
 
@@ -111,7 +111,7 @@ public enum Operator {
      * @return SQL constraint, <code>a op b</code>
      */
     public String formatSql(String a, String b) {
-        return a + " " + sql + " " + b;
+        return a + ' ' + sql + ' ' + b;
     }
 
     /**

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/SelectorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/SelectorImpl.java?rev=1299751&r1=1299750&r2=1299751&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/SelectorImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/qom/tree/SelectorImpl.java
Mon Mar 12 17:36:23 2012
@@ -18,8 +18,6 @@
  */
 package org.apache.jackrabbit.query.qom.tree;
 
-import javax.jcr.Value;
-import javax.jcr.query.qom.Selector;
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.json.JsopTokenizer;
 import org.apache.jackrabbit.mk.simple.NodeImpl;
@@ -29,6 +27,9 @@ import org.apache.jackrabbit.query.reade
 import org.apache.jackrabbit.query.reader.NodeReader;
 import org.apache.jackrabbit.query.reader.TraversingReader;
 
+import javax.jcr.Value;
+import javax.jcr.query.qom.Selector;
+
 /**
  * The implementation of the corresponding JCR interface.
  */
@@ -81,7 +82,7 @@ public class SelectorImpl extends Source
         return  nodeTypeName + " AS " + getSelectorName() + " /* " + reader.getPlan(getFilter())
+ " */";
     }
 
-    private Filter getFilter() {
+    private static Filter getFilter() {
         return new Filter();
     }
 

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/reader/TraversingReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/reader/TraversingReader.java?rev=1299751&r1=1299750&r2=1299751&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/reader/TraversingReader.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/query/reader/TraversingReader.java
Mon Mar 12 17:36:23 2012
@@ -55,7 +55,7 @@ public class TraversingReader implements
 
     @Override
     public String getPlan(Filter filter) {
-        return "traverse \"" + filter.getPath() + "\"";
+        return "traverse \"" + filter.getPath() + '"';
     }
 
 }



Mime
View raw message