jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r573622 [2/2] - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/query/ main/java/org/apache/jackrabbit/core/query/jsr283/qom/ main/java/org/apache/jackrabbit/core/query/lucene/ main/java/org/apache/jackrabbit/...
Date Fri, 07 Sep 2007 16:10:02 GMT
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/QOMTreeVisitor.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/QOMTreeVisitor.java?rev=573622&r1=573621&r2=573622&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/QOMTreeVisitor.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/QOMTreeVisitor.java
Fri Sep  7 09:09:59 2007
@@ -21,55 +21,57 @@
  */
 public interface QOMTreeVisitor {
 
-    public void visit(AndImpl node, Object data);
+    public Object visit(AndImpl node, Object data) throws Exception;
 
-    public void visit(BindVariableValueImpl node, Object data);
+    public Object visit(BindVariableValueImpl node, Object data) throws Exception;
 
-    public void visit(ChildNodeImpl node, Object data);
+    public Object visit(ChildNodeImpl node, Object data) throws Exception;
 
-    public void visit(ChildNodeJoinConditionImpl node, Object data);
+    public Object visit(ChildNodeJoinConditionImpl node, Object data) throws Exception;
 
-    public void visit(ColumnImpl node, Object data);
+    public Object visit(ColumnImpl node, Object data) throws Exception;
 
-    public void visit(ComparisonImpl node, Object data);
+    public Object visit(ComparisonImpl node, Object data) throws Exception;
 
-    public void visit(DescendantNodeImpl node, Object data);
+    public Object visit(DescendantNodeImpl node, Object data) throws Exception;
 
-    public void visit(DescendantNodeJoinConditionImpl node, Object data);
+    public Object visit(DescendantNodeJoinConditionImpl node, Object data) throws Exception;
 
-    public void visit(EquiJoinConditionImpl node, Object data);
+    public Object visit(EquiJoinConditionImpl node, Object data) throws Exception;
 
-    public void visit(FullTextSearchImpl node, Object data);
+    public Object visit(FullTextSearchImpl node, Object data) throws Exception;
 
-    public void visit(FullTextSearchScoreImpl node, Object data);
+    public Object visit(FullTextSearchScoreImpl node, Object data) throws Exception;
 
-    public void visit(JoinImpl node, Object data);
+    public Object visit(JoinImpl node, Object data) throws Exception;
 
-    public void visit(LengthImpl node, Object data);
+    public Object visit(LengthImpl node, Object data) throws Exception;
 
-    public void visit(LowerCaseImpl node, Object data);
+    public Object visit(LiteralImpl node, Object data) throws Exception;
 
-    public void visit(NodeLocalNameImpl node, Object data);
+    public Object visit(LowerCaseImpl node, Object data) throws Exception;
 
-    public void visit(NodeNameImpl node, Object data);
+    public Object visit(NodeLocalNameImpl node, Object data) throws Exception;
 
-    public void visit(NotImpl node, Object data);
+    public Object visit(NodeNameImpl node, Object data) throws Exception;
 
-    public void visit(OrderingImpl node, Object data);
+    public Object visit(NotImpl node, Object data) throws Exception;
 
-    public void visit(OrImpl node, Object data);
+    public Object visit(OrderingImpl node, Object data) throws Exception;
 
-    public void visit(PropertyExistenceImpl node, Object data);
+    public Object visit(OrImpl node, Object data) throws Exception;
 
-    public void visit(PropertyValueImpl node, Object data);
+    public Object visit(PropertyExistenceImpl node, Object data) throws Exception;
 
-    public void visit(QueryObjectModelTree node, Object data);
+    public Object visit(PropertyValueImpl node, Object data) throws Exception;
 
-    public void visit(SameNodeImpl node, Object data);
+    public Object visit(QueryObjectModelTree node, Object data) throws Exception;
 
-    public void visit(SameNodeJoinConditionImpl node, Object data);
+    public Object visit(SameNodeImpl node, Object data) throws Exception;
 
-    public void visit(SelectorImpl node, Object data);
+    public Object visit(SameNodeJoinConditionImpl node, Object data) throws Exception;
 
-    public void visit(UpperCaseImpl node, Object data);
+    public Object visit(SelectorImpl node, Object data) throws Exception;
+
+    public Object visit(UpperCaseImpl node, Object data) throws Exception;
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/QueryObjectModelFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/QueryObjectModelFactoryImpl.java?rev=573622&r1=573621&r2=573622&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/QueryObjectModelFactoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/QueryObjectModelFactoryImpl.java
Fri Sep  7 09:09:59 2007
@@ -54,12 +54,14 @@
 import org.apache.jackrabbit.core.query.jsr283.qom.UpperCase;
 import org.apache.jackrabbit.core.query.jsr283.qom.BindVariableValue;
 import org.apache.jackrabbit.core.query.jsr283.qom.QueryObjectModelConstants;
+import org.apache.jackrabbit.core.query.jsr283.qom.Literal;
 import org.apache.jackrabbit.core.query.QueryImpl;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.SearchManager;
 
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.RepositoryException;
+import javax.jcr.Value;
 import java.util.BitSet;
 
 /**
@@ -867,6 +869,23 @@
         } catch (NameException e) {
             throw new InvalidQueryException(e.getMessage());
         }
+    }
+
+    /**
+     * Evaluates to a literal value.
+     *
+     * @param value a JCR value; non-null
+     * @return the operand; non-null
+     * @throws InvalidQueryException if the query is invalid
+     * @throws RepositoryException   if the operation otherwise fails
+     */
+    public Literal literal(Value value)
+            throws InvalidQueryException, RepositoryException {
+        if (value == null) {
+            // TODO: correct exception?
+            throw new RepositoryException("value must not be null");
+        }
+        return new LiteralImpl(resolver, value);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/QueryObjectModelTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/QueryObjectModelTree.java?rev=573622&r1=573621&r2=573622&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/QueryObjectModelTree.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/QueryObjectModelTree.java
Fri Sep  7 09:09:59 2007
@@ -108,8 +108,8 @@
      *
      * @param visitor the visitor.
      */
-    public void accept(QOMTreeVisitor visitor, Object data) {
-        visitor.visit(this, data);
+    public Object accept(QOMTreeVisitor visitor, Object data) throws Exception {
+        return visitor.visit(this, data);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/SameNodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/SameNodeImpl.java?rev=573622&r1=573621&r2=573622&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/SameNodeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/SameNodeImpl.java
Fri Sep  7 09:09:59 2007
@@ -72,7 +72,7 @@
      *
      * @param visitor the visitor.
      */
-    public void accept(QOMTreeVisitor visitor, Object data) {
-        visitor.visit(this, data);
+    public Object accept(QOMTreeVisitor visitor, Object data) throws Exception {
+        return visitor.visit(this, data);
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/SameNodeJoinConditionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/SameNodeJoinConditionImpl.java?rev=573622&r1=573621&r2=573622&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/SameNodeJoinConditionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/SameNodeJoinConditionImpl.java
Fri Sep  7 09:09:59 2007
@@ -89,7 +89,7 @@
      *
      * @param visitor the visitor.
      */
-    public void accept(QOMTreeVisitor visitor, Object data) {
-        visitor.visit(this, data);
+    public Object accept(QOMTreeVisitor visitor, Object data) throws Exception {
+        return visitor.visit(this, data);
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/SelectorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/SelectorImpl.java?rev=573622&r1=573621&r2=573622&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/SelectorImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/SelectorImpl.java
Fri Sep  7 09:09:59 2007
@@ -49,6 +49,29 @@
      *
      * @return the node type name; non-null
      */
+    public QName getNodeTypeQName() {
+        return nodeTypeName;
+    }
+
+    /**
+     * Gets the selector name.
+     * <p/>
+     * A selector's name can be used elsewhere in the query to identify the
+     * selector.
+     *
+     * @return the selector name; non-null
+     */
+    public QName getSelectorQName() {
+        return selectorName;
+    }
+
+    //-----------------------------< Selector >---------------------------------
+
+    /**
+     * Gets the name of the required node type.
+     *
+     * @return the node type name; non-null
+     */
     public String getNodeTypeName() {
         return getJCRName(nodeTypeName);
     }
@@ -73,7 +96,7 @@
      *
      * @param visitor the visitor.
      */
-    public void accept(QOMTreeVisitor visitor, Object data) {
-        visitor.visit(this, data);
+    public Object accept(QOMTreeVisitor visitor, Object data) throws Exception {
+        return visitor.visit(this, data);
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/UpperCaseImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/UpperCaseImpl.java?rev=573622&r1=573621&r2=573622&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/UpperCaseImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/UpperCaseImpl.java
Fri Sep  7 09:09:59 2007
@@ -53,7 +53,7 @@
      *
      * @param visitor the visitor.
      */
-    public void accept(QOMTreeVisitor visitor, Object data) {
-        visitor.visit(this, data);
+    public Object accept(QOMTreeVisitor visitor, Object data) throws Exception {
+        return visitor.visit(this, data);
     }
 }

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/qom/SelectorQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/qom/SelectorQueryTest.java?rev=573622&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/qom/SelectorQueryTest.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/qom/SelectorQueryTest.java
Fri Sep  7 09:09:59 2007
@@ -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.core.query.qom;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.NodeIterator;
+import javax.jcr.query.Query;
+
+/**
+ * <code>SelectorQueryTest</code>...
+ */
+public class SelectorQueryTest extends AbstractQOMTest {
+
+    public void testSelector() throws RepositoryException {
+        // make sure there's at least one node with this node type
+        testRootNode.addNode(nodeName1, testNodeType);
+        testRootNode.save();
+        Query q = qomFactory.createQuery(
+                qomFactory.selector(testNodeType), null, null, null);
+        NodeIterator it = q.execute().getNodes();
+        while (it.hasNext()) {
+            assertTrue("Wrong node type", it.nextNode().isNodeType(testNodeType));
+        }
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/qom/SelectorQueryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message