Author: thomasm
Date: Wed Sep 19 10:37:27 2012
New Revision: 1387515

URL: http://svn.apache.org/viewvc?rev=1387515&view=rev
Log:
OAK-36 Implement a query parser - XPath: rep:spellcheck parsed but not supported

Modified:
    
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
    
jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt

Modified: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java?rev=1387515&r1=1387514&r2=1387515&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
 Wed Sep 19 10:37:27 2012
@@ -575,7 +575,8 @@ public class XPathToSQL2Converter {
 
     private Expression parseFunction(String functionName) throws 
ParseException {
         if ("jcr:like".equals(functionName)) {
-            Condition c = new Condition(parseExpression(), "like", null, 
Expression.PRECEDENCE_CONDITION);
+            Condition c = new Condition(parseExpression(), 
+                    "like", null, Expression.PRECEDENCE_CONDITION);
             read(",");
             c.right = parseExpression();
             read(")");
@@ -602,6 +603,11 @@ public class XPathToSQL2Converter {
             f.params.add(parseExpression());
             read(")");
             return f;
+        } else if ("fn:upper-case".equals(functionName)) {
+            Function f = new Function("upper");
+            f.params.add(parseExpression());
+            read(")");
+            return f;
         } else if ("fn:name".equals(functionName)) {
             Function f = new Function("name");
             if (!readIf(")")) {
@@ -611,19 +617,19 @@ public class XPathToSQL2Converter {
             }
             f.params.add(new SelectorExpr(currentSelector));
             return f;
-        } else if ("fn:upper-case".equals(functionName)) {
-            Function f = new Function("upper");
-            f.params.add(parseExpression());
-            read(")");
-            return f;
         } else if ("jcr:deref".equals(functionName)) {
-             // TODO support jcr:deref
+             // TODO maybe support jcr:deref
              throw getSyntaxError("jcr:deref is not supported");
         } else if ("rep:similar".equals(functionName)) {
-             // TODO support rep:similar
+             // TODO maybe support rep:similar
              throw getSyntaxError("rep:similar is not supported");
+        } else if ("rep:spellcheck".equals(functionName)) {
+            // TODO maybe support rep:spellcheck as in
+            // /jcr:root[rep:spellcheck('${query}')]/(rep:spellcheck())        
    
+            throw getSyntaxError("rep:spellcheck is not supported");
         } else {
-            throw getSyntaxError("jcr:like | jcr:contains | jcr:score | 
jcr:deref | fn:lower-case | fn:upper-case");
+            throw getSyntaxError("jcr:like | jcr:contains | jcr:score | 
xs:dateTime | " + 
+                    "fn:lower-case | fn:upper-case | fn:name");
         }
     }
 

Modified: 
jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt?rev=1387515&r1=1387514&r2=1387515&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt
 Wed Sep 19 10:37:27 2012
@@ -367,7 +367,7 @@ xpath2sql //element(*, my:type)[@my:valu
 invalid: Query: //element(*, my:type)[@my:value = [(*)'x']; expected: @, true, 
false, -, +, *, ., @, (
 
 xpath2sql //element(*, my:type)[jcr:strike(@title,'%Java%')]
-invalid: Query: //element(*, my:type)[jcr:strike(@(*)title,'%Java%')]; 
expected: jcr:like | jcr:contains | jcr:score | jcr:deref | fn:lower-case | 
fn:upper-case
+invalid: Query: //element(*, my:type)[jcr:strike(@(*)title,'%Java%')]; 
expected: jcr:like | jcr:contains | jcr:score | xs:dateTime | fn:lower-case | 
fn:upper-case | fn:name
 
 xpath2sql //element(*, my:type)[
 invalid: Query: //element(*, my:type)(*)[; expected: fn:not, not, (, @, true, 
false, -, +, *, ., @, (


Reply via email to