jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1309840 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java
Date Thu, 05 Apr 2012 13:25:09 GMT
Author: thomasm
Date: Thu Apr  5 13:25:09 2012
New Revision: 1309840

URL: http://svn.apache.org/viewvc?rev=1309840&view=rev
Log:
OAK-28 Query implementation (temporarily support relative properties in SQL-2 to simplify
XPath to SQL-2 conversion)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java

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=1309840&r1=1309839&r2=1309840&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
Thu Apr  5 13:25:09 2012
@@ -18,6 +18,9 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
+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.query.index.Filter;
 
@@ -53,7 +56,28 @@ public class PropertyValueImpl extends D
 
     @Override
     public CoreValue currentValue() {
-        return selector.currentProperty(propertyName);
+        if (propertyName.indexOf('/') < 0) {
+            return selector.currentProperty(propertyName);
+        }
+        // TODO really support relative properties?
+        NodeImpl n = selector.currentNode();
+        String[] elements = PathUtils.split(propertyName);
+        for (int i = 0; i < elements.length - 1; i++) {
+            String p = elements[i];
+            if (!n.exists(p)) {
+                return null;
+            }
+            n = n.getNode(p);
+        }
+        String name = PathUtils.getName(propertyName);
+        if (!n.hasProperty(name)) {
+            return null;
+        }
+        // TODO data type mapping
+        String value = n.getProperty(name);
+        value = JsopTokenizer.decodeQuoted(value);
+        return query.getValueFactory().createValue(value);
+
     }
 
     public void bindSelector(SourceImpl source) {



Mime
View raw message