jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1329612 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/api/ oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/query/ oak-core/src/main/java/org/apache/jack...
Date Tue, 24 Apr 2012 09:50:27 GMT
Author: angela
Date: Tue Apr 24 09:50:25 2012
New Revision: 1329612

URL: http://svn.apache.org/viewvc?rev=1329612&view=rev
Log:
OAK-16 : Proper ValueFactory implementation and Value handling (WIP)
OAK-33 : Values in oak-core (WIP)

- replacing query/CoreValue and query/CoreValueFactory by oak-api

Added:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/CoreValue.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/CoreValueFactory.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/ValueConverter.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/CoreValue.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/QueryEngine.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/ResultRow.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/CoreValueFactoryImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/CoreValueImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/KernelContentRepository.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultRowImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AstElementFactory.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/BindVariableValueImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ColumnImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ComparisonImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/DynamicOperandImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/EquiJoinConditionImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchScoreImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LengthImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LiteralImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LowerCaseImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeLocalNameImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeNameImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyExistenceImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/StaticOperandImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/UpperCaseImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/Filter.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/FilterTest.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ValueFactoryImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ValueImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/RowImpl.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/CoreValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/CoreValue.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/CoreValue.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/CoreValue.java Tue Apr 24 09:50:25 2012
@@ -22,7 +22,7 @@ import java.math.BigDecimal;
 /**
  * CoreValue... TODO: add description and javadoc for methods
  */
-public interface CoreValue {
+public interface CoreValue extends Comparable<CoreValue> {
 
     int getType();
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/QueryEngine.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/QueryEngine.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/QueryEngine.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/QueryEngine.java Tue Apr 24 09:50:25 2012
@@ -19,7 +19,6 @@ package org.apache.jackrabbit.oak.api;
 import java.text.ParseException;
 import java.util.List;
 import java.util.Map;
-import org.apache.jackrabbit.oak.query.CoreValue;
 
 /**
  * The query engine allows to parse and execute queries.

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/ResultRow.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/ResultRow.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/ResultRow.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/ResultRow.java Tue Apr 24 09:50:25 2012
@@ -1,7 +1,5 @@
 package org.apache.jackrabbit.oak.api;
 
-import org.apache.jackrabbit.oak.query.CoreValue;
-
 /**
  * A query result row.
  */

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/CoreValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/CoreValueFactoryImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/CoreValueFactoryImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/CoreValueFactoryImpl.java Tue Apr 24 09:50:25 2012
@@ -38,7 +38,8 @@ public class CoreValueFactoryImpl implem
 
     private final MicroKernel mk;
 
-    CoreValueFactoryImpl(MicroKernel mk) {
+    // TODO: currently public for query tests -> see todo there...
+    public CoreValueFactoryImpl(MicroKernel mk) {
         this.mk = mk;
     }
 
@@ -76,8 +77,12 @@ public class CoreValueFactoryImpl implem
 
     @Override
     public CoreValue createValue(String value, int type) {
-        return new CoreValueImpl(value, type);
+        // TODO check again...
+        if (type == PropertyType.BINARY) {
+            BinaryValue bv = new BinaryValue(value, mk);
+            return new CoreValueImpl(bv);
+        } else {
+            return new CoreValueImpl(value, type);
+        }
     }
-
-
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/CoreValueImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/CoreValueImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/CoreValueImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/CoreValueImpl.java Tue Apr 24 09:50:25 2012
@@ -29,7 +29,7 @@ import java.math.BigDecimal;
 /**
  * CoreValueImpl... TODO: javadoc
  */
-class CoreValueImpl implements CoreValue, Comparable<CoreValue>{
+class CoreValueImpl implements CoreValue {
 
     /**
      * logger instance

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/KernelContentRepository.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/KernelContentRepository.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/KernelContentRepository.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/KernelContentRepository.java Tue Apr 24 09:50:25 2012
@@ -87,15 +87,15 @@ public class KernelContentRepository imp
             throw new LoginException("login failed");
         }
 
-        QueryEngine queryEngine = new QueryEngineImpl(microKernel);
+        CoreValueFactory valueFactory = new CoreValueFactoryImpl(microKernel);
+
+        QueryEngine queryEngine = new QueryEngineImpl(microKernel, valueFactory);
         // TODO set revision!?
         NodeState wspRoot = nodeStore.getRoot().getChildNode(workspaceName);
         if (wspRoot == null) {
             throw new NoSuchWorkspaceException(workspaceName);
         }
 
-        CoreValueFactory valueFactory = new CoreValueFactoryImpl(microKernel);
-
         return new KernelContentSession(
                 sc, workspaceName, nodeStore, wspRoot, queryEngine, valueFactory);
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java Tue Apr 24 09:50:25 2012
@@ -20,6 +20,8 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.oak.api.CoreValue;
+import org.apache.jackrabbit.oak.api.CoreValueFactory;
 import org.apache.jackrabbit.oak.query.ast.AstVisitorBase;
 import org.apache.jackrabbit.oak.query.ast.BindVariableValueImpl;
 import org.apache.jackrabbit.oak.query.ast.ChildNodeImpl;
@@ -63,14 +65,15 @@ public class Query {
     private long limit;
     private long offset;
     private boolean prepared;
-    private final CoreValueFactory valueFactory = new CoreValueFactory();
+    private final CoreValueFactory valueFactory;
 
     Query(SourceImpl source, ConstraintImpl constraint, OrderingImpl[] orderings,
-            ColumnImpl[] columns) {
+          ColumnImpl[] columns, CoreValueFactory valueFactory) {
         this.source = source;
         this.constraint = constraint;
         this.orderings = orderings;
         this.columns = columns;
+        this.valueFactory = valueFactory;
     }
 
     public void init() {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java Tue Apr 24 09:50:25 2012
@@ -21,6 +21,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.oak.api.CoreValue;
+import org.apache.jackrabbit.oak.api.CoreValueFactory;
 import org.apache.jackrabbit.oak.api.QueryEngine;
 
 public class QueryEngineImpl implements QueryEngine {
@@ -29,11 +31,12 @@ public class QueryEngineImpl implements 
     private static final String XPATH = "xpath";
 
     private final MicroKernel mk;
-    private final CoreValueFactory vf = new CoreValueFactory();
+    private final CoreValueFactory vf;
     private final SQL2Parser parserSQL2;
 
-    public QueryEngineImpl(MicroKernel mk) {
+    public QueryEngineImpl(MicroKernel mk, CoreValueFactory valueFactory) {
         this.mk = mk;
+        this.vf = valueFactory;
         parserSQL2 = new SQL2Parser(vf);
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultRowImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultRowImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultRowImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultRowImpl.java Tue Apr 24 09:50:25 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.oak.query;
 
+import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.ResultRow;
 import org.apache.jackrabbit.oak.query.ast.ColumnImpl;
 import org.apache.jackrabbit.oak.query.ast.SelectorImpl;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java Tue Apr 24 09:50:25 2012
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.oak.query;
 
+import org.apache.jackrabbit.oak.api.CoreValue;
+import org.apache.jackrabbit.oak.api.CoreValueFactory;
 import org.apache.jackrabbit.oak.query.ast.AstElementFactory;
 import org.apache.jackrabbit.oak.query.ast.Operator;
 import org.apache.jackrabbit.oak.query.ast.BindVariableValueImpl;
@@ -32,6 +34,7 @@ import org.apache.jackrabbit.oak.query.a
 import org.apache.jackrabbit.oak.query.ast.SourceImpl;
 import org.apache.jackrabbit.oak.query.ast.StaticOperandImpl;
 
+import javax.jcr.PropertyType;
 import java.math.BigDecimal;
 import java.text.ParseException;
 import java.util.ArrayList;
@@ -117,7 +120,7 @@ public class SQL2Parser {
         if (!currentToken.isEmpty()) {
             throw getSyntaxError("<end>");
         }
-        Query q = new Query(source, constraint, orderings, columnArray);
+        Query q = new Query(source, constraint, orderings, columnArray, valueFactory);
         q.setExplain(explain);
         q.init();
         return q;
@@ -442,16 +445,16 @@ public class SQL2Parser {
             }
             int valueType = currentValue.getType();
             switch (valueType) {
-            case CoreValue.LONG:
+            case PropertyType.LONG:
                 currentValue = valueFactory.createValue(-currentValue.getLong());
                 break;
-            case CoreValue.DOUBLE:
+            case PropertyType.DOUBLE:
                 currentValue = valueFactory.createValue(-currentValue.getDouble());
                 break;
-            case CoreValue.BOOLEAN:
+            case PropertyType.BOOLEAN:
                 currentValue = valueFactory.createValue(!currentValue.getBoolean());
                 break;
-            case CoreValue.DECIMAL:
+            case PropertyType.DECIMAL:
                 currentValue = valueFactory.createValue(currentValue.getDecimal().negate());
                 break;
             default:
@@ -505,35 +508,35 @@ public class SQL2Parser {
      * @param value the original value
      * @return the literal
      */
-    private LiteralImpl getUncastLiteral(CoreValue value) throws ParseException {
+    private LiteralImpl getUncastLiteral(CoreValue value) {
         return factory.literal(value);
     }
 
     private CoreValue parseCastAs(CoreValue value) throws ParseException {
-        if (readIf("STRING")) {
+        if (readIfPropertyType(PropertyType.STRING)) {
             return valueFactory.createValue(value.getString());
-        } else if (readIf("BINARY")) {
-            return valueFactory.createValue(value.getBinary());
-        } else if (readIf("DATE")) {
-            return valueFactory.createValue(value.getDate());
-        } else if (readIf("LONG")) {
+        } else if (readIfPropertyType(PropertyType.BINARY)) {
+            return valueFactory.createValue(value.getString(), PropertyType.BINARY);
+        } else if (readIfPropertyType(PropertyType.DATE)) {
+            return valueFactory.createValue(value.getString(), PropertyType.DATE);
+        } else if (readIfPropertyType(PropertyType.LONG)) {
             return valueFactory.createValue(value.getLong());
-        } else if (readIf("DOUBLE")) {
+        } else if (readIfPropertyType(PropertyType.DOUBLE)) {
             return valueFactory.createValue(value.getDouble());
-        } else if (readIf("DECIMAL")) {
+        } else if (readIfPropertyType(PropertyType.DECIMAL)) {
             return valueFactory.createValue(value.getDecimal());
-        } else if (readIf("BOOLEAN")) {
+        } else if (readIfPropertyType(PropertyType.BOOLEAN)) {
             return valueFactory.createValue(value.getBoolean());
-        } else if (readIf("NAME")) {
-            return valueFactory.createValue(value.getString(), CoreValue.NAME);
-        } else if (readIf("PATH")) {
-            return valueFactory.createValue(value.getString(), CoreValue.PATH);
-        } else if (readIf("REFERENCE")) {
-            return valueFactory.createValue(value.getString(), CoreValue.REFERENCE);
-        } else if (readIf("WEAKREFERENCE")) {
-            return valueFactory.createValue(value.getString(), CoreValue.WEAKREFERENCE);
-        } else if (readIf("URI")) {
-            return valueFactory.createValue(value.getString(), CoreValue.URI);
+        } else if (readIfPropertyType(PropertyType.NAME)) {
+            return valueFactory.createValue(value.getString(), PropertyType.NAME);
+        } else if (readIfPropertyType(PropertyType.PATH)) {
+            return valueFactory.createValue(value.getString(), PropertyType.PATH);
+        } else if (readIfPropertyType(PropertyType.REFERENCE)) {
+            return valueFactory.createValue(value.getString(), PropertyType.REFERENCE);
+        } else if (readIfPropertyType(PropertyType.WEAKREFERENCE)) {
+            return valueFactory.createValue(value.getString(), PropertyType.WEAKREFERENCE);
+        } else if (readIfPropertyType(PropertyType.URI)) {
+            return valueFactory.createValue(value.getString(), PropertyType.URI);
         } else {
             throw getSyntaxError("data type (STRING|BINARY|...)");
         }
@@ -616,6 +619,11 @@ public class SQL2Parser {
         return array;
     }
 
+    private boolean readIfPropertyType(int propertyType) throws ParseException {
+        String propertyName = PropertyType.nameFromValue(propertyType);
+        return readIf(propertyName);
+    }
+
     private boolean readIf(String token) throws ParseException {
         if (isToken(token)) {
             read();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AstElementFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AstElementFactory.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AstElementFactory.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AstElementFactory.java Tue Apr 24 09:50:25 2012
@@ -13,7 +13,7 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
-import org.apache.jackrabbit.oak.query.CoreValue;
+import org.apache.jackrabbit.oak.api.CoreValue;
 
 /**
  * A factory for syntax tree elements.
@@ -59,7 +59,7 @@ public class AstElementFactory {
     }
 
     public OrderingImpl descending(DynamicOperandImpl operand) {
-        return new OrderingImpl((DynamicOperandImpl) operand, Order.DESCENDING);
+        return new OrderingImpl(operand, Order.DESCENDING);
     }
 
     public EquiJoinConditionImpl equiJoinCondition(String selector1Name, String property1Name, String selector2Name,
@@ -129,7 +129,7 @@ public class AstElementFactory {
     }
 
     public UpperCaseImpl upperCase(DynamicOperandImpl operand) {
-        return new UpperCaseImpl((DynamicOperandImpl) operand);
+        return new UpperCaseImpl(operand);
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/BindVariableValueImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/BindVariableValueImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/BindVariableValueImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/BindVariableValueImpl.java Tue Apr 24 09:50:25 2012
@@ -18,7 +18,7 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
-import org.apache.jackrabbit.oak.query.CoreValue;
+import org.apache.jackrabbit.oak.api.CoreValue;
 
 public class BindVariableValueImpl extends StaticOperandImpl {
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ColumnImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ColumnImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ColumnImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ColumnImpl.java Tue Apr 24 09:50:25 2012
@@ -18,7 +18,7 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
-import org.apache.jackrabbit.oak.query.CoreValue;
+import org.apache.jackrabbit.oak.api.CoreValue;
 
 public class ColumnImpl extends AstElement {
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ComparisonImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ComparisonImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ComparisonImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ComparisonImpl.java Tue Apr 24 09:50:25 2012
@@ -18,8 +18,8 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
-import org.apache.jackrabbit.oak.query.CoreValue;
-import org.apache.jackrabbit.oak.query.CoreValueFactory;
+import org.apache.jackrabbit.oak.api.CoreValue;
+import org.apache.jackrabbit.oak.api.CoreValueFactory;
 import org.apache.jackrabbit.oak.query.index.Filter;
 
 public class ComparisonImpl extends ConstraintImpl {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/DynamicOperandImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/DynamicOperandImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/DynamicOperandImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/DynamicOperandImpl.java Tue Apr 24 09:50:25 2012
@@ -16,7 +16,7 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
-import org.apache.jackrabbit.oak.query.CoreValue;
+import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.query.index.Filter;
 
 public abstract class DynamicOperandImpl extends AstElement {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/EquiJoinConditionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/EquiJoinConditionImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/EquiJoinConditionImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/EquiJoinConditionImpl.java Tue Apr 24 09:50:25 2012
@@ -18,7 +18,7 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
-import org.apache.jackrabbit.oak.query.CoreValue;
+import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.query.index.Filter;
 
 public class EquiJoinConditionImpl extends JoinConditionImpl {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchScoreImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchScoreImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchScoreImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchScoreImpl.java Tue Apr 24 09:50:25 2012
@@ -18,7 +18,7 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
-import org.apache.jackrabbit.oak.query.CoreValue;
+import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.query.index.Filter;
 
 public class FullTextSearchScoreImpl extends DynamicOperandImpl {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LengthImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LengthImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LengthImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LengthImpl.java Tue Apr 24 09:50:25 2012
@@ -18,7 +18,7 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
-import org.apache.jackrabbit.oak.query.CoreValue;
+import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.query.index.Filter;
 
 public class LengthImpl extends DynamicOperandImpl {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LiteralImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LiteralImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LiteralImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LiteralImpl.java Tue Apr 24 09:50:25 2012
@@ -18,8 +18,10 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
+import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.query.SQL2Parser;
-import org.apache.jackrabbit.oak.query.CoreValue;
+
+import javax.jcr.PropertyType;
 
 public class LiteralImpl extends StaticOperandImpl {
 
@@ -40,33 +42,7 @@ public class LiteralImpl extends StaticO
 
     @Override
     public String toString() {
-        switch (value.getType()) {
-        case CoreValue.BINARY:
-            return cast("BINARY");
-        case CoreValue.BOOLEAN:
-            return cast("BOOLEAN");
-        case CoreValue.DATE:
-            return cast("DATE");
-        case CoreValue.DECIMAL:
-            return cast("DECIMAL");
-        case CoreValue.DOUBLE:
-        case CoreValue.LONG:
-            return value.getString();
-        case CoreValue.NAME:
-            return cast("NAME");
-        case CoreValue.PATH:
-            return cast("PATH");
-        case CoreValue.REFERENCE:
-            return cast("REFERENCE");
-        case CoreValue.STRING:
-            return escape();
-        case CoreValue.URI:
-            return cast("URI");
-        case CoreValue.WEAKREFERENCE:
-            return cast("WEAKREFERENCE");
-        default:
-            return escape();
-        }
+        return PropertyType.nameFromValue(value.getType()).toUpperCase();
     }
 
     private String cast(String type) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LowerCaseImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LowerCaseImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LowerCaseImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LowerCaseImpl.java Tue Apr 24 09:50:25 2012
@@ -18,7 +18,7 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
-import org.apache.jackrabbit.oak.query.CoreValue;
+import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.query.index.Filter;
 
 public class LowerCaseImpl extends DynamicOperandImpl {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeLocalNameImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeLocalNameImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeLocalNameImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeLocalNameImpl.java Tue Apr 24 09:50:25 2012
@@ -19,7 +19,7 @@
 package org.apache.jackrabbit.oak.query.ast;
 
 import org.apache.jackrabbit.mk.util.PathUtils;
-import org.apache.jackrabbit.oak.query.CoreValue;
+import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.query.index.Filter;
 
 public class NodeLocalNameImpl extends DynamicOperandImpl {
@@ -53,7 +53,7 @@ public class NodeLocalNameImpl extends D
     }
 
     @Override
-    public  CoreValue currentValue() {
+    public CoreValue currentValue() {
         String name = PathUtils.getName(selector.currentPath());
         int colon = name.indexOf(':');
         // TODO LOCALNAME: evaluation of local name might not be correct

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeNameImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeNameImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeNameImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeNameImpl.java Tue Apr 24 09:50:25 2012
@@ -19,7 +19,7 @@
 package org.apache.jackrabbit.oak.query.ast;
 
 import org.apache.jackrabbit.mk.util.PathUtils;
-import org.apache.jackrabbit.oak.query.CoreValue;
+import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.query.index.Filter;
 
 public class NodeNameImpl extends DynamicOperandImpl {
@@ -53,7 +53,7 @@ public class NodeNameImpl extends Dynami
     }
 
     @Override
-    public  CoreValue currentValue() {
+    public CoreValue currentValue() {
         String name = PathUtils.getName(selector.currentPath());
         return query.getValueFactory().createValue(name);
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyExistenceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyExistenceImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyExistenceImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyExistenceImpl.java Tue Apr 24 09:50:25 2012
@@ -18,7 +18,7 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
-import org.apache.jackrabbit.oak.query.CoreValue;
+import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.query.index.Filter;
 
 public class PropertyExistenceImpl extends ConstraintImpl {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java Tue Apr 24 09:50:25 2012
@@ -21,7 +21,7 @@ package org.apache.jackrabbit.oak.query.
 import org.apache.jackrabbit.mk.json.JsopTokenizer;
 import org.apache.jackrabbit.mk.simple.NodeImpl;
 import org.apache.jackrabbit.mk.util.PathUtils;
-import org.apache.jackrabbit.oak.query.CoreValue;
+import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.query.index.Filter;
 
 public class PropertyValueImpl extends DynamicOperandImpl {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java Tue Apr 24 09:50:25 2012
@@ -21,8 +21,8 @@ package org.apache.jackrabbit.oak.query.
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.json.JsopTokenizer;
 import org.apache.jackrabbit.mk.simple.NodeImpl;
+import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.query.Query;
-import org.apache.jackrabbit.oak.query.CoreValue;
 import org.apache.jackrabbit.oak.query.index.Cursor;
 import org.apache.jackrabbit.oak.query.index.Filter;
 import org.apache.jackrabbit.oak.query.index.QueryIndex;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/StaticOperandImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/StaticOperandImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/StaticOperandImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/StaticOperandImpl.java Tue Apr 24 09:50:25 2012
@@ -18,7 +18,7 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
-import org.apache.jackrabbit.oak.query.CoreValue;
+import org.apache.jackrabbit.oak.api.CoreValue;
 
 public abstract class StaticOperandImpl extends AstElement {
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/UpperCaseImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/UpperCaseImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/UpperCaseImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/UpperCaseImpl.java Tue Apr 24 09:50:25 2012
@@ -18,7 +18,7 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
-import org.apache.jackrabbit.oak.query.CoreValue;
+import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.query.index.Filter;
 
 public class UpperCaseImpl extends DynamicOperandImpl {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/Filter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/Filter.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/Filter.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/Filter.java Tue Apr 24 09:50:25 2012
@@ -21,7 +21,7 @@ package org.apache.jackrabbit.oak.query.
 import java.util.HashMap;
 import java.util.Map.Entry;
 import org.apache.jackrabbit.mk.util.PathUtils;
-import org.apache.jackrabbit.oak.query.CoreValue;
+import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.query.ast.Operator;
 import org.apache.jackrabbit.oak.query.ast.SelectorImpl;
 

Added: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java?rev=1329612&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java Tue Apr 24 09:50:25 2012
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.query;
+
+import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.mk.core.MicroKernelImpl;
+import org.apache.jackrabbit.oak.api.CoreValueFactory;
+import org.apache.jackrabbit.oak.core.CoreValueFactoryImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * AbstractQueryTest...
+ */
+public abstract class AbstractQueryTest {
+
+    /**
+     * logger instance
+     */
+    private static final Logger log = LoggerFactory.getLogger(AbstractQueryTest.class);
+
+    // TODO improve: use ContentRepository here instead of creating mk instance.
+    protected final MicroKernel mk = new MicroKernelImpl();
+    protected final CoreValueFactory vf = new CoreValueFactoryImpl(mk);
+}
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java Tue Apr 24 09:50:25 2012
@@ -13,8 +13,11 @@
  */
 package org.apache.jackrabbit.oak.query;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import org.apache.jackrabbit.oak.api.CoreValue;
+import org.apache.jackrabbit.oak.api.Result;
+import org.apache.jackrabbit.oak.api.ResultRow;
+import org.junit.Test;
+
 import java.io.FileOutputStream;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -27,19 +30,16 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-import org.apache.jackrabbit.mk.api.MicroKernel;
-import org.apache.jackrabbit.mk.core.MicroKernelImpl;
-import org.apache.jackrabbit.oak.api.Result;
-import org.apache.jackrabbit.oak.api.ResultRow;
-import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 /**
  * Test the query feature.
  */
-public class QueryTest {
+public class QueryTest extends AbstractQueryTest {
 
-    private final MicroKernel mk = new MicroKernelImpl();
-    private QueryEngineImpl qe = new QueryEngineImpl(mk);
+    private QueryEngineImpl qe = new QueryEngineImpl(mk, vf);
 
     @Test
     public void script() throws Exception {
@@ -56,7 +56,6 @@ public class QueryTest {
         mk.commit("/", "+ \"test\": { \"hello\": {\"id\": \"1\"}, \"world\": {\"id\": \"2\"}}",
                 null, null);
         HashMap<String, CoreValue> sv = new HashMap<String, CoreValue>();
-        CoreValueFactory vf = new CoreValueFactory();
         sv.put("id", vf.createValue("1"));
         Iterator<? extends ResultRow> result;
         result = qe.executeQuery("select * from [nt:base] where id = $id",

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/FilterTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/FilterTest.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/FilterTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/FilterTest.java Tue Apr 24 09:50:25 2012
@@ -18,26 +18,28 @@
  */
 package org.apache.jackrabbit.oak.query.index;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import java.util.ArrayList;
-import java.util.Random;
-import org.apache.jackrabbit.oak.query.CoreValue;
-import org.apache.jackrabbit.oak.query.CoreValueFactory;
+import org.apache.jackrabbit.oak.api.CoreValue;
+import org.apache.jackrabbit.oak.query.AbstractQueryTest;
 import org.apache.jackrabbit.oak.query.ast.Operator;
 import org.apache.jackrabbit.oak.query.index.Filter.PathRestriction;
 import org.junit.Test;
 
+import java.util.ArrayList;
+import java.util.Random;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 /**
  * Tests the Filter class.
  */
-public class FilterTest {
+public class FilterTest extends AbstractQueryTest {
 
     @Test
     public void propertyRestriction() {
-        CoreValue one = new CoreValueFactory().createValue("1");
-        CoreValue two = new CoreValueFactory().createValue("2");
+        CoreValue one = vf.createValue("1");
+        CoreValue two = vf.createValue("2");
 
         Filter f = new Filter(null);
         assertTrue(null == f.getPropertyRestriction("x"));

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java Tue Apr 24 09:50:25 2012
@@ -25,7 +25,6 @@ import org.apache.jackrabbit.oak.api.Tre
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.jcr.ValueFactory;
 import javax.jcr.lock.LockManager;
 import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.version.VersionManager;
@@ -35,7 +34,7 @@ public interface SessionContext<T extend
     GlobalContext getGlobalContext();
     String getWorkspaceName();
     ContentSession getContentSession();
-    ValueFactory getValueFactory();
+    ValueFactoryImpl getValueFactory();
     LockManager getLockManager() throws RepositoryException;
     NodeTypeManager getNodeTypeManager() throws RepositoryException;
     VersionManager getVersionManager() throws RepositoryException;

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java Tue Apr 24 09:50:25 2012
@@ -59,7 +59,7 @@ public class SessionImpl extends Abstrac
 
     private final GlobalContext globalContext;
     private final ContentSession contentSession;
-    private final ValueFactory valueFactory;
+    private final ValueFactoryImpl valueFactory;
     private final Workspace workspace;
     private final SessionContext<SessionImpl> sessionContext = new Context();
 
@@ -456,7 +456,7 @@ public class SessionImpl extends Abstrac
         }
 
         @Override
-        public ValueFactory getValueFactory() {
+        public ValueFactoryImpl getValueFactory() {
             return valueFactory;
         }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ValueFactoryImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ValueFactoryImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ValueFactoryImpl.java Tue Apr 24 09:50:25 2012
@@ -38,7 +38,7 @@ import java.util.Calendar;
 /**
  * CoreValueFactoryImpl...
  */
-class ValueFactoryImpl implements ValueFactory {
+public class ValueFactoryImpl implements ValueFactory {
 
     /**
      * logger instance
@@ -57,6 +57,23 @@ class ValueFactoryImpl implements ValueF
         this.resolver = new DummyNamePathResolver();
     }
 
+    public CoreValueFactory getCoreValueFactory() {
+        return factory;
+    }
+
+    public Value createValue(CoreValue coreValue) {
+        return new ValueImpl(coreValue, resolver);
+    }
+
+    public CoreValue getCoreValue(Value jcrValue) {
+        if (jcrValue instanceof ValueImpl) {
+            return ((ValueImpl) jcrValue).unwrap();
+        } else {
+            // TODO
+            throw new UnsupportedOperationException("Unsupported Value implementation.");
+        }
+    }
+
     //-------------------------------------------------------< ValueFactory >---
     @Override
     public Value createValue(String value) {

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ValueImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ValueImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ValueImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ValueImpl.java Tue Apr 24 09:50:25 2012
@@ -38,7 +38,7 @@ import java.util.TimeZone;
 /**
  * ValueImpl...
  */
-public class ValueImpl implements Value {
+class ValueImpl implements Value {
 
     /**
      * logger instance
@@ -62,6 +62,10 @@ public class ValueImpl implements Value 
         this.resolver = resolver;
     }
 
+    CoreValue unwrap() {
+        return value;
+    }
+
     //--------------------------------------------------------------< Value >---
     /**
      * @see javax.jcr.Value#getType()

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java Tue Apr 24 09:50:25 2012
@@ -18,13 +18,13 @@
  */
 package org.apache.jackrabbit.oak.jcr.query;
 
+import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.QueryEngine;
 import org.apache.jackrabbit.oak.api.Result;
 import org.apache.jackrabbit.oak.jcr.SessionContext;
 import org.apache.jackrabbit.oak.jcr.SessionImpl;
 import org.apache.jackrabbit.oak.jcr.WorkspaceImpl;
 import org.apache.jackrabbit.oak.jcr.query.qom.QueryObjectModelFactoryImpl;
-import org.apache.jackrabbit.oak.query.CoreValue;
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
@@ -46,9 +46,11 @@ public class QueryManagerImpl implements
 
     private final QueryObjectModelFactoryImpl qomFactory = new QueryObjectModelFactoryImpl();
     private final QueryEngine queryEngine;
+    private final SessionContext<SessionImpl> sessionContext;
 
     public QueryManagerImpl(WorkspaceImpl workspace, SessionContext<SessionImpl> sessionContext) {
         queryEngine = sessionContext.getContentSession().getQueryEngine();
+        this.sessionContext = sessionContext;
     }
 
     @Override
@@ -93,18 +95,17 @@ public class QueryManagerImpl implements
         try {
             HashMap<String, CoreValue> bindMap = convertMap(bindVariableMap);
             Result r = queryEngine.executeQuery(statement, language, bindMap);
-            return new QueryResultImpl(r);
+            return new QueryResultImpl(r, sessionContext.getValueFactory());
         } catch (ParseException e) {
             throw new InvalidQueryException(e);
         }
     }
 
-    private static HashMap<String, CoreValue> convertMap(HashMap<String, Value> bindVariableMap)
-            throws RepositoryException {
+    private HashMap<String, CoreValue> convertMap(HashMap<String, Value> bindVariableMap) {
 
         HashMap<String, CoreValue> map = new HashMap<String, CoreValue>();
         for (Entry<String, Value> e : bindVariableMap.entrySet()) {
-            map.put(e.getKey(), ValueConverter.convert(e.getValue()));
+            map.put(e.getKey(), sessionContext.getValueFactory().getCoreValue(e.getValue()));
         }
         return map;
     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java Tue Apr 24 09:50:25 2012
@@ -21,6 +21,7 @@ package org.apache.jackrabbit.oak.jcr.qu
 import org.apache.jackrabbit.commons.iterator.RowIteratorAdapter;
 import org.apache.jackrabbit.oak.api.Result;
 import org.apache.jackrabbit.oak.api.ResultRow;
+import org.apache.jackrabbit.oak.jcr.ValueFactoryImpl;
 
 import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
@@ -33,10 +34,12 @@ import java.util.Iterator;
  */
 public class QueryResultImpl implements QueryResult {
 
-    final Result result;
+    private final Result result;
+    private final ValueFactoryImpl valueFactory;
 
-    public QueryResultImpl(Result result) {
+    public QueryResultImpl(Result result, ValueFactoryImpl valueFactory) {
         this.result = result;
+        this.valueFactory = valueFactory;
     }
 
     @Override
@@ -62,7 +65,7 @@ public class QueryResultImpl implements 
 
             @Override
             public RowImpl next() {
-                return new RowImpl(it.next());
+                return new RowImpl(it.next(), valueFactory);
             }
 
             @Override

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/RowImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/RowImpl.java?rev=1329612&r1=1329611&r2=1329612&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/RowImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/RowImpl.java Tue Apr 24 09:50:25 2012
@@ -18,8 +18,9 @@
  */
 package org.apache.jackrabbit.oak.jcr.query;
 
+import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.ResultRow;
-import org.apache.jackrabbit.oak.query.CoreValue;
+import org.apache.jackrabbit.oak.jcr.ValueFactoryImpl;
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
@@ -32,9 +33,11 @@ import javax.jcr.query.Row;
 public class RowImpl implements Row {
 
     private final ResultRow row;
+    private ValueFactoryImpl valueFactory;
 
-    public RowImpl(ResultRow row) {
+    public RowImpl(ResultRow row, ValueFactoryImpl valueFactory) {
         this.row = row;
+        this.valueFactory = valueFactory;
     }
 
     @Override
@@ -73,7 +76,7 @@ public class RowImpl implements Row {
 
     @Override
     public Value getValue(String columnName) throws RepositoryException {
-        return ValueConverter.convert(row.getValue(columnName));
+        return valueFactory.createValue(row.getValue(columnName));
     }
 
     @Override
@@ -82,7 +85,7 @@ public class RowImpl implements Row {
         int len = values.length;
         Value[] v2 = new Value[values.length];
         for (int i = 0; i < len; i++) {
-            v2[i] = ValueConverter.convert(values[i]);
+            v2[i] = valueFactory.createValue(values[i]);
         }
         return v2;
     }



Mime
View raw message