jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r572945 [1/3] - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: ./ query/ query/lucene/ query/qom/
Date Wed, 05 Sep 2007 12:52:15 GMT
Author: mreutegg
Date: Wed Sep  5 05:52:12 2007
New Revision: 572945

URL: http://svn.apache.org/viewvc?rev=572945&view=rev
Log:
JCR-1104: JSR 283 support
- JQOM work in progress

Added:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/ExecutablePreparedQuery.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/PreparedQueryImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractQueryImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PreparedQueryImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/AbstractQOMNode.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/AndImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/BindVariableValueImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ChildNodeImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ChildNodeJoinConditionImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ColumnImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ComparisonImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ConstraintImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/DefaultTraversingQOMTreeVisitor.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/DescendantNodeImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/DescendantNodeJoinConditionImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/DynamicOperandImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/EquiJoinConditionImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/FullTextSearchImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/FullTextSearchScoreImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/JoinConditionImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/JoinImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/LengthImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/LowerCaseImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/NodeLocalNameImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/NodeNameImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/NotImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/OrImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/OrderingImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/PropertyExistenceImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/PropertyValueImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/QOMTreeVisitor.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/QueryObjectModelFactoryImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/QueryObjectModelImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/QueryObjectModelTree.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/SameNodeImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/SameNodeJoinConditionImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/SelectorImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/SourceImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/StaticOperandImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/UpperCaseImpl.java   (with props)
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SearchManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/AbstractQueryHandler.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/AbstractQueryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryHandler.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SearchManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SearchManager.java?rev=572945&r1=572944&r2=572945&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SearchManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SearchManager.java Wed Sep  5 05:52:12 2007
@@ -26,6 +26,11 @@
 import org.apache.jackrabbit.core.query.QueryHandler;
 import org.apache.jackrabbit.core.query.QueryHandlerContext;
 import org.apache.jackrabbit.core.query.QueryImpl;
+import org.apache.jackrabbit.core.query.PreparedQueryImpl;
+import org.apache.jackrabbit.core.query.qom.QueryObjectModelTree;
+import org.apache.jackrabbit.core.query.qom.QueryObjectModelImpl;
+import org.apache.jackrabbit.core.query.jsr283.PreparedQuery;
+import org.apache.jackrabbit.core.query.jsr283.qom.QueryObjectModel;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.ItemStateManager;
 import org.apache.jackrabbit.core.state.NodeState;
@@ -87,6 +92,12 @@
     private static final String PARAM_QUERY_IMPL = "queryClass";
 
     /**
+     * Name of the parameter that indicates the prepared query implementation
+     * class.
+     */
+    private static final String PARAM_PREPARED_QUERY_IMPL = "preparedQueryClass";
+
+    /**
      * Name of the parameter that specifies the idle time for a query handler.
      */
     private static final String PARAM_IDLE_TIME = "idleTime";
@@ -97,6 +108,11 @@
     private static final String DEFAULT_QUERY_IMPL_CLASS = QueryImpl.class.getName();
 
     /**
+     * Name of the default prepared query implementation class.
+     */
+    private static final String DEFAULT_PREPARED_QUERY_IMPL_CLASS = PreparedQueryImpl.class.getName();
+
+    /**
      * The search configuration.
      */
     private final SearchConfig config;
@@ -155,6 +171,13 @@
     private final String queryImplClassName;
 
     /**
+     * Fully qualified name of the prepared query implementation class.
+     * This class must extend {@link org.apache.jackrabbit.core.query.AbstractQueryImpl}
+     * and implement {@link PreparedQuery}!
+     */
+    private final String preparedQueryImplClassName;
+
+    /**
      * Creates a new <code>SearchManager</code>.
      *
      * @param config the search configuration.
@@ -215,6 +238,7 @@
 
         Properties params = config.getParameters();
         queryImplClassName = params.getProperty(PARAM_QUERY_IMPL, DEFAULT_QUERY_IMPL_CLASS);
+        preparedQueryImplClassName = params.getProperty(PARAM_PREPARED_QUERY_IMPL, DEFAULT_PREPARED_QUERY_IMPL_CLASS);
         if (params.containsKey(PARAM_IDLE_TIME)) {
             String msg = "Parameter 'idleTime' is not supported anymore. " +
                     "Please use 'maxIdleTime' in the repository configuration.";
@@ -273,6 +297,50 @@
     }
 
     /**
+     * Creates a prepared query object that can be executed on the workspace.
+     *
+     * @param session   the session of the user executing the query.
+     * @param itemMgr   the item manager of the user executing the query. Needed
+     *                  to return <code>Node</code> instances in the result set.
+     * @param statement the actual query statement.
+     * @param language  the syntax of the query statement.
+     * @return a <code>Query</code> instance to execute.
+     * @throws InvalidQueryException if the query is malformed or the
+     *                               <code>language</code> is unknown.
+     * @throws RepositoryException   if any other error occurs.
+     */
+    public PreparedQuery createPreparedQuery(SessionImpl session,
+                                             ItemManager itemMgr,
+                                             String statement,
+                                             String language)
+            throws InvalidQueryException, RepositoryException {
+        AbstractQueryImpl query = createPreparedQueryInstance();
+        query.init(session, itemMgr, handler, statement, language);
+        return (PreparedQuery) query;
+    }
+
+    /**
+     * Creates a query object model that can be executed on the workspace.
+     *
+     * @param session   the session of the user executing the query.
+     * @param qomTree   the query object model tree, representing the query.
+     * @param langugage the original language of the query statement.
+     * @return the query object model for the query.
+     * @throws InvalidQueryException the the query object model tree is
+     *                               considered invalid by the query handler
+     *                               implementation.
+     * @throws RepositoryException   if any other error occurs.
+     */
+    public QueryObjectModel createQueryObjectModel(SessionImpl session,
+                                                   QueryObjectModelTree qomTree,
+                                                   String langugage)
+            throws InvalidQueryException, RepositoryException {
+        QueryObjectModelImpl qom = new QueryObjectModelImpl();
+        qom.init(session, session.getItemManager(), handler, qomTree, langugage);
+        return qom;
+    }
+
+    /**
      * Creates a query object from a node that can be executed on the workspace.
      *
      * @param session the session of the user executing the query.
@@ -454,6 +522,33 @@
             }
         } catch (Throwable t) {
             throw new RepositoryException("Unable to create query: " + t.toString());
+        }
+    }
+
+    /**
+     * Creates a new instance of an {@link AbstractQueryImpl}, which also
+     * implements {@link PreparedQuery} and is not initialized.
+     *
+     * @return an new query instance.
+     * @throws RepositoryException if an error occurs while creating a new query
+     *                             instance.
+     */
+    protected AbstractQueryImpl createPreparedQueryInstance()
+            throws RepositoryException {
+        try {
+            Object obj = Class.forName(preparedQueryImplClassName).newInstance();
+            if (!(obj instanceof AbstractQueryImpl)) {
+                throw new IllegalArgumentException(preparedQueryImplClassName
+                        + " is not of type " + AbstractQueryImpl.class.getName());
+            } else if (!(obj instanceof PreparedQuery)) {
+                throw new IllegalArgumentException(preparedQueryImplClassName
+                        + " is not of type " + PreparedQuery.class.getName());
+            } else {
+                return (AbstractQueryImpl) obj;
+            }
+        } catch (Throwable t) {
+            throw new RepositoryException("Unable to create prepared query: "
+                    + t.toString(), t);
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/AbstractQueryHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/AbstractQueryHandler.java?rev=572945&r1=572944&r2=572945&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/AbstractQueryHandler.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/AbstractQueryHandler.java Wed Sep  5 05:52:12 2007
@@ -18,9 +18,13 @@
 
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.NodeIdIterator;
+import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.ItemManager;
+import org.apache.jackrabbit.core.query.qom.QueryObjectModelTree;
 import org.apache.jackrabbit.core.state.NodeStateIterator;
 
 import javax.jcr.RepositoryException;
+import javax.jcr.query.InvalidQueryException;
 import java.io.IOException;
 
 /**
@@ -79,5 +83,18 @@
         while (add.hasNext()) {
             addNode(add.nextNodeState());
         }
+    }
+
+    /**
+     * {@inheritDoc}
+     * <p/>
+     * Throws {@link UnsupportedOperationException}.
+     */
+    public ExecutablePreparedQuery createExecutablePreparedQuery(
+            SessionImpl session,
+            ItemManager itemMgr,
+            QueryObjectModelTree qomTree) throws InvalidQueryException {
+        throw new UnsupportedOperationException(
+                "This query handler does not support prepared queries");
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/AbstractQueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/AbstractQueryImpl.java?rev=572945&r1=572944&r2=572945&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/AbstractQueryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/AbstractQueryImpl.java Wed Sep  5 05:52:12 2007
@@ -23,6 +23,7 @@
 
 import org.apache.jackrabbit.core.ItemManager;
 import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.query.qom.QueryObjectModelTree;
 
 /**
  * Defines common initialization methods for all query implementations.
@@ -62,4 +63,21 @@
                               QueryHandler handler,
                               Node node)
             throws InvalidQueryException, RepositoryException;
+
+    /**
+     * Initializes a query instance from a query object model.
+     *
+     * @param session  the session of the user executing this query.
+     * @param itemMgr  the item manager of the session executing this query.
+     * @param handler  the query handler of the search index.
+     * @param qomTree  the query object model tree.
+     * @param language the original query syntax from where the JQOM was
+     *                 created.
+     * @throws RepositoryException if another error occurs
+     */
+    public abstract void init(SessionImpl session,
+                              ItemManager itemMgr,
+                              QueryHandler handler,
+                              QueryObjectModelTree qomTree,
+                              String language) throws RepositoryException;
 }

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/ExecutablePreparedQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/ExecutablePreparedQuery.java?rev=572945&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/ExecutablePreparedQuery.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/ExecutablePreparedQuery.java Wed Sep  5 05:52:12 2007
@@ -0,0 +1,42 @@
+/*
+ * 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;
+
+import org.apache.jackrabbit.name.QName;
+
+import javax.jcr.Value;
+import javax.jcr.RepositoryException;
+
+/**
+ * <code>ExecutablePreparedQuery</code> extends {@link ExecutableQuery} with
+ * a method to bind a value to a variable.
+ */
+public interface ExecutablePreparedQuery extends ExecutableQuery {
+
+    /**
+     * Binds the given <code>value</code> to the variable named
+     * <code>varName</code>.
+     *
+     * @param varName name of variable in query
+     * @param value   value to bind
+     * @throws IllegalArgumentException      if <code>varName</code> is not a
+     *                                       valid variable in this query.
+     * @throws javax.jcr.RepositoryException if an error occurs.
+     */
+    public void bindValue(QName varName, Value value)
+            throws IllegalArgumentException, RepositoryException;
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/ExecutablePreparedQuery.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/PreparedQueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/PreparedQueryImpl.java?rev=572945&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/PreparedQueryImpl.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/PreparedQueryImpl.java Wed Sep  5 05:52:12 2007
@@ -0,0 +1,142 @@
+/*
+ * 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;
+
+import org.apache.jackrabbit.core.query.jsr283.PreparedQuery;
+import org.apache.jackrabbit.core.query.qom.QueryObjectModelTree;
+import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.ItemManager;
+import org.apache.jackrabbit.name.NameException;
+import org.apache.jackrabbit.name.QName;
+
+import javax.jcr.Value;
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.query.InvalidQueryException;
+
+/**
+ * <code>PreparedQueryImpl</code>...
+ */
+public class PreparedQueryImpl extends QueryImpl implements PreparedQuery {
+
+    /**
+     * The executable prepared query.
+     */
+    protected ExecutablePreparedQuery query;
+
+    /**
+     * The query object model tree.
+     */
+    protected QueryObjectModelTree qomTree;
+
+    /**
+     * @inheritDoc
+     */
+    public void init(SessionImpl session,
+                     ItemManager itemMgr,
+                     QueryHandler handler,
+                     String statement,
+                     String language) throws InvalidQueryException {
+        checkNotInitialized();
+        this.session = session;
+        this.language = language;
+        this.handler = handler;
+        this.statement = statement;
+        this.query = handler.createExecutablePreparedQuery(
+                session, itemMgr, createQOMTree(statement, language));
+        setInitialized();
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void init(SessionImpl session,
+                     ItemManager itemMgr,
+                     QueryHandler handler,
+                     Node node) throws InvalidQueryException, RepositoryException {
+        checkNotInitialized();
+        this.session = session;
+        this.node = node;
+        this.handler = handler;
+
+        if (!node.isNodeType(session.getJCRName(QName.NT_QUERY))) {
+            throw new InvalidQueryException("node is not of type nt:query");
+        }
+        statement = node.getProperty(session.getJCRName(QName.JCR_STATEMENT)).getString();
+        language = node.getProperty(session.getJCRName(QName.JCR_LANGUAGE)).getString();
+        query = handler.createExecutablePreparedQuery(
+                session, itemMgr, createQOMTree(statement, language));
+        setInitialized();
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void init(SessionImpl session,
+                     ItemManager itemMgr,
+                     QueryHandler handler,
+                     QueryObjectModelTree qomTree,
+                     String language)
+            throws InvalidQueryException, RepositoryException {
+        checkNotInitialized();
+        this.session = session;
+        this.language = language;
+        this.handler = handler;
+        this.qomTree = qomTree;
+        this.statement = null; // TODO: format qomTree into a SQL2 statement
+        this.query = handler.createExecutablePreparedQuery(session, itemMgr, qomTree);
+        setInitialized();
+    }
+
+
+    /**
+     * Binds the given <code>value</code> to the variable named
+     * <code>varName</code>.
+     *
+     * @param varName name of variable in query
+     * @param value   value to bind
+     * @throws IllegalArgumentException      if <code>varName</code> is not a
+     *                                       valid variable in this query.
+     * @throws javax.jcr.RepositoryException if an error occurs.
+     */
+    public void bindValue(String varName, Value value)
+            throws IllegalArgumentException, RepositoryException {
+        try {
+            query.bindValue(session.getQName(varName), value);
+        } catch (NameException e) {
+            throw new RepositoryException(e.getMessage());
+        }
+    }
+
+    //----------------------------< internal >----------------------------------
+
+    /**
+     * Creates a {@link QueryObjectModelTree} representation for the query
+     * <code>statement</code>.
+     *
+     * @param statement the query statement.
+     * @param language  the language of the query statement.
+     * @return the {@link QueryObjectModelTree} representation.
+     * @throws InvalidQueryException if the query statement is malformed.
+     */
+    private QueryObjectModelTree createQOMTree(String statement,
+                                               String language)
+            throws InvalidQueryException {
+        // TODO: implement
+        return null;
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/PreparedQueryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryHandler.java?rev=572945&r1=572944&r2=572945&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryHandler.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryHandler.java Wed Sep  5 05:52:12 2007
@@ -25,6 +25,8 @@
 
 import javax.jcr.RepositoryException;
 import javax.jcr.query.InvalidQueryException;
+import org.apache.jackrabbit.core.query.qom.QueryObjectModelTree;
+
 import java.io.IOException;
 
 /**
@@ -106,4 +108,21 @@
                              ItemManager itemMgr,
                              String statement,
                              String language) throws InvalidQueryException;
+    
+    /**
+     * Creates a new query by specifying the query object model. If the query
+     * object model is considered invalid for the implementing class, an
+     * InvalidQueryException is thrown.
+     *
+     * @param session the session of the current user creating the query
+     *                object.
+     * @param itemMgr the item manager of the current user.
+     * @param qomTree query query object model tree.
+     * @return A <code>Query</code> object.
+     * @throws InvalidQueryException if the query object model tree is invalid.
+     */
+    ExecutablePreparedQuery createExecutablePreparedQuery(
+            SessionImpl session,
+            ItemManager itemMgr,
+            QueryObjectModelTree qomTree) throws InvalidQueryException;
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java?rev=572945&r1=572944&r2=572945&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java Wed Sep  5 05:52:12 2007
@@ -34,6 +34,8 @@
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.query.QueryResult;
+import org.apache.jackrabbit.core.query.qom.QueryObjectModelTree;
+
 import javax.jcr.version.VersionException;
 import java.text.NumberFormat;
 
@@ -48,6 +50,22 @@
     private static final Logger log = LoggerFactory.getLogger(QueryImpl.class);
 
     /**
+     * A string constant representing the JCR-SQL2 query language.
+     *
+     * @since JCR 2.0
+     * TODO: REMOVE WHEN JSR 283 IS FINAL!!
+     */
+    public static final String JCR_SQL2 = "JCR-SQL2";
+
+    /**
+     * A string constant representing the JCR-JQOM query language.
+     *
+     * @since JCR 2.0
+     * TODO: REMOVE WHEN JSR 283 IS FINAL!!
+     */
+    public static final String JCR_JQOM = "JCR-JQOM";
+
+    /**
      * The session of the user executing this query
      */
     protected SessionImpl session;
@@ -107,7 +125,7 @@
         this.language = language;
         this.handler = handler;
         this.query = handler.createExecutableQuery(session, itemMgr, statement, language);
-        initialized = true;
+        setInitialized();
     }
 
     /**
@@ -129,7 +147,21 @@
         statement = node.getProperty(session.getJCRName(QName.JCR_STATEMENT)).getString();
         language = node.getProperty(session.getJCRName(QName.JCR_LANGUAGE)).getString();
         query = handler.createExecutableQuery(session, itemMgr, statement, language);
-        initialized = true;
+        setInitialized();
+    }
+    
+    /**
+     * @inheritDoc
+     * <p/>
+     * Throws an {@link UnsupportedOperationException}.
+     */
+    public void init(SessionImpl session,
+                     ItemManager itemMgr,
+                     QueryHandler handler,
+                     QueryObjectModelTree qomTree,
+                     String language)
+            throws InvalidQueryException, RepositoryException {
+        throw new UnsupportedOperationException("not a prepared query");
     }
 
     /**
@@ -232,6 +264,13 @@
     }
 
     //-----------------------------< internal >---------------------------------
+
+    /**
+     * Sets the initialized flag.
+     */
+    protected void setInitialized() {
+        initialized = true;
+    }
 
     /**
      * Checks if this query is not yet initialized and throws an

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryManagerImpl.java?rev=572945&r1=572944&r2=572945&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryManagerImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryManagerImpl.java Wed Sep  5 05:52:12 2007
@@ -19,6 +19,9 @@
 import org.apache.jackrabbit.core.ItemManager;
 import org.apache.jackrabbit.core.SearchManager;
 import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.query.jsr283.PreparedQuery;
+import org.apache.jackrabbit.core.query.jsr283.qom.QueryObjectModelFactory;
+import org.apache.jackrabbit.core.query.qom.QueryObjectModelFactoryImpl;
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
@@ -61,6 +64,11 @@
     private final SearchManager searchMgr;
 
     /**
+     * The <code>QueryObjectModelFactory</code> for this query manager.
+     */
+    private final QueryObjectModelFactoryImpl qomFactory;
+
+    /**
      * Creates a new <code>QueryManagerImpl</code> for the passed
      * <code>session</code>
      *
@@ -74,6 +82,7 @@
         this.session = session;
         this.itemMgr = itemMgr;
         this.searchMgr = searchMgr;
+        this.qomFactory = new QueryObjectModelFactoryImpl(session, searchMgr);
     }
 
     /**
@@ -100,6 +109,45 @@
     public String[] getSupportedQueryLanguages() throws RepositoryException {
         return (String[]) SUPPORTED_QUERIES_LIST.toArray(new String[SUPPORTED_QUERIES.length]);
     }
+
+    //---------------------------< JSR 283 >------------------------------------
+
+    /**
+     * Creates a new prepared query by specifying the query
+     * <code>statement</code> itself and the <code>language</code> in which the
+     * query is stated. If the query statement is syntactically invalid, given
+     * the language specified, an <code>InvalidQueryException</code> is thrown.
+     * The language parameter must be a string from among those returned by
+     * <code>QueryManager.getSupportedQueryLanguages()</code>; if it is not,
+     * then an <code>InvalidQueryException</code> is thrown.
+     *
+     * @param statement a <code>String</code>
+     * @param language  a <code>String</code>
+     * @return a <code>PreparedQuery</code> object
+     * @throws InvalidQueryException if the query statement is syntactically
+     *                               invalid or the specified language is not
+     *                               supported
+     * @throws RepositoryException   if another error occurs
+     * @since JCR 2.0
+     */
+    public PreparedQuery createPreparedQuery(String statement, String language)
+            throws InvalidQueryException, RepositoryException {
+        sanityCheck();
+        return searchMgr.createPreparedQuery(session, itemMgr, statement, language);
+    }
+
+    /**
+     * Returns a <code>QueryObjectModelFactory</code> with which a JCR-JQOM
+     * query can be built programmatically.
+     *
+     * @return a <code>QueryObjectModelFactory</code> object
+     * @since JCR 2.0
+     */
+    public QueryObjectModelFactory getQOMFactory() {
+        return qomFactory;
+    }
+
+    //---------------------------< internal >-----------------------------------
 
     /**
      * Checks if this <code>QueryManagerImpl</code> instance is still usable,

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractQueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractQueryImpl.java?rev=572945&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractQueryImpl.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractQueryImpl.java Wed Sep  5 05:52:12 2007
@@ -0,0 +1,110 @@
+/*
+ * 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.lucene;
+
+import org.apache.jackrabbit.core.query.ExecutableQuery;
+import org.apache.jackrabbit.core.query.PropertyTypeRegistry;
+import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.ItemManager;
+
+/**
+ * <code>AbstractQueryImpl</code> provides a base class for executable queries
+ * based on {@link SearchIndex}.
+ */
+public abstract class AbstractQueryImpl implements ExecutableQuery {
+
+    /**
+     * The session of the user executing this query
+     */
+    protected final SessionImpl session;
+
+    /**
+     * The item manager of the user executing this query
+     */
+    protected final ItemManager itemMgr;
+
+    /**
+     * The actual search index
+     */
+    protected final SearchIndex index;
+
+    /**
+     * The property type registry for type lookup.
+     */
+    protected final PropertyTypeRegistry propReg;
+
+    /**
+     * If <code>true</code> the default ordering of the result nodes is in
+     * document order.
+     */
+    private boolean documentOrder = true;
+
+    /**
+     * Creates a new query instance from a query string.
+     *
+     * @param session the session of the user executing this query.
+     * @param itemMgr the item manager of the session executing this query.
+     * @param index   the search index.
+     * @param propReg the property type registry.
+     */
+    public AbstractQueryImpl(SessionImpl session,
+                             ItemManager itemMgr,
+                             SearchIndex index,
+                             PropertyTypeRegistry propReg) {
+        this.session = session;
+        this.itemMgr = itemMgr;
+        this.index = index;
+        this.propReg = propReg;
+    }
+
+    /**
+     * If set <code>true</code> the result nodes will be in document order
+     * per default (if no order by clause is specified). If set to
+     * <code>false</code> the result nodes are returned in whatever sequence
+     * the index has stored the nodes. That sequence is stable over multiple
+     * invocations of the same query, but will change when nodes get added or
+     * removed from the index.
+     * <p/>
+     * The default value for this property is <code>true</code>.
+     * @return the current value of this property.
+     */
+    public boolean getRespectDocumentOrder() {
+        return documentOrder;
+    }
+
+    /**
+     * Sets a new value for this property.
+     *
+     * @param documentOrder if <code>true</code> the result nodes are in
+     * document order per default.
+     *
+     * @see #getRespectDocumentOrder()
+     */
+    public void setRespectDocumentOrder(boolean documentOrder) {
+        this.documentOrder = documentOrder;
+    }
+
+    /**
+     * Returns <code>true</code> if this query node needs items under
+     * /jcr:system to be queried.
+     *
+     * @return <code>true</code> if this query node needs content under
+     *         /jcr:system to be queried; <code>false</code> otherwise.
+     */
+    public abstract boolean needsSystemTree();
+
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractQueryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PreparedQueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PreparedQueryImpl.java?rev=572945&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PreparedQueryImpl.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PreparedQueryImpl.java Wed Sep  5 05:52:12 2007
@@ -0,0 +1,164 @@
+/*
+ * 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.lucene;
+
+import org.apache.jackrabbit.core.query.ExecutablePreparedQuery;
+import org.apache.jackrabbit.core.query.PropertyTypeRegistry;
+import org.apache.jackrabbit.core.query.jsr283.qom.QueryObjectModelConstants;
+import org.apache.jackrabbit.core.query.qom.QueryObjectModelTree;
+import org.apache.jackrabbit.core.query.qom.DefaultTraversingQOMTreeVisitor;
+import org.apache.jackrabbit.core.query.qom.BindVariableValueImpl;
+import org.apache.jackrabbit.core.query.qom.ColumnImpl;
+import org.apache.jackrabbit.core.query.qom.OrderingImpl;
+import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.ItemManager;
+import org.apache.jackrabbit.name.QName;
+import org.apache.lucene.search.Query;
+
+import javax.jcr.Value;
+import javax.jcr.RepositoryException;
+import javax.jcr.query.QueryResult;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * <code>PreparedQueryImpl</code>...
+ */
+public class PreparedQueryImpl
+        extends AbstractQueryImpl
+        implements ExecutablePreparedQuery {
+
+    /**
+     * The query object model tree.
+     */
+    private final QueryObjectModelTree qomTree;
+
+    /**
+     * Set&lt;QName>, where QName is a variable name in the QOM tree.
+     */
+    private final Set variableNames = new HashSet();
+
+    /**
+     * Binding of variable name to value. Maps {@link QName} to {@link Value}.
+     */
+    private final Map bindValues = new HashMap();
+
+    /**
+     * Creates a new query instance from a query string.
+     *
+     * @param session the session of the user executing this query.
+     * @param itemMgr the item manager of the session executing this query.
+     * @param index   the search index.
+     * @param propReg the property type registry.
+     * @param qomTree the query object model tree.
+     */
+    public PreparedQueryImpl(SessionImpl session,
+                             ItemManager itemMgr,
+                             SearchIndex index,
+                             PropertyTypeRegistry propReg,
+                             QueryObjectModelTree qomTree) {
+        super(session, itemMgr, index, propReg);
+        this.qomTree = qomTree;
+        extractBindVariableNames(qomTree, variableNames);
+    }
+
+    /**
+     * Returns <code>true</code> if this query node needs items under
+     * /jcr:system to be queried.
+     *
+     * @return <code>true</code> if this query node needs content under
+     *         /jcr:system to be queried; <code>false</code> otherwise.
+     */
+    public boolean needsSystemTree() {
+        // TODO: analyze QOM tree
+        return true;
+    }
+
+    //-------------------------< ExecutableQuery >------------------------------
+
+    /**
+     * Executes this query and returns a <code>{@link javax.jcr.query.QueryResult}</code>.
+     *
+     * @param offset the offset in the total result set
+     * @param limit  the maximum result size
+     * @return a <code>QueryResult</code>
+     * @throws RepositoryException if an error occurs
+     */
+    public QueryResult execute(long offset, long limit)
+            throws RepositoryException {
+        // TODO: turn QOM tree into a lucene query
+        Query query = null;
+
+        ColumnImpl[] columns = qomTree.getColumns();
+        QName[] selectProps = new QName[columns.length];
+        for (int i = 0; i < columns.length; i++) {
+            selectProps[i] = columns[i].getPropertyQName();
+        }
+        OrderingImpl[] orderings = qomTree.getOrderings();
+        // TODO: there are many kinds of DynamicOperand that can be ordered by
+        QName[] orderProps = new QName[orderings.length];
+        boolean[] orderSpecs = new boolean[orderings.length];
+        for (int i = 0; i < orderings.length; i++) {
+            orderSpecs[i] = orderings[i].getOrder() == QueryObjectModelConstants.ORDER_ASCENDING;
+        }
+        return new QueryResultImpl(index, itemMgr,
+                session.getNamespaceResolver(), session.getAccessManager(),
+                this, query, selectProps, orderProps, orderSpecs,
+                getRespectDocumentOrder(), offset, limit);
+    }
+
+    //-----------------------< ExecutablePreparedQuery >------------------------
+
+    /**
+     * Binds the given <code>value</code> to the variable named
+     * <code>varName</code>.
+     *
+     * @param varName name of variable in query
+     * @param value   value to bind
+     * @throws IllegalArgumentException if <code>varName</code> is not a valid
+     *                                  variable in this query.
+     * @throws RepositoryException      if an error occurs.
+     */
+    public void bindValue(QName varName, Value value)
+            throws IllegalArgumentException, RepositoryException {
+        if (!variableNames.contains(varName)) {
+            throw new IllegalArgumentException("not a valid variable in this query");
+        } else {
+            bindValues.put(varName, value);
+        }
+    }
+
+    //--------------------------< internal >------------------------------------
+
+    /**
+     * Extracts all {@link BindVariableValueImpl} from the <code>qomTree</code>
+     * into the <code>bindVariablesNames</code> set.
+     *
+     * @param qomTree            the QOM tree.
+     * @param bindVariableNames where to put the bind variable names.
+     */
+    private void extractBindVariableNames(QueryObjectModelTree qomTree,
+                                           final Set bindVariableNames) {
+        qomTree.accept(new DefaultTraversingQOMTreeVisitor() {
+            public void visit(BindVariableValueImpl node, Object data) {
+                bindVariableNames.add(node.getBindVariableQName());
+            }
+        }, null);
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PreparedQueryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java?rev=572945&r1=572944&r2=572945&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java Wed Sep  5 05:52:12 2007
@@ -47,7 +47,7 @@
 /**
  * Implements the {@link ExecutableQuery} interface.
  */
-public class QueryImpl implements ExecutableQuery {
+public class QueryImpl extends AbstractQueryImpl {
 
     /**
      * The logger instance for this class
@@ -65,32 +65,6 @@
     protected final QueryRootNode root;
 
     /**
-     * The session of the user executing this query
-     */
-    protected final SessionImpl session;
-
-    /**
-     * The item manager of the user executing this query
-     */
-    protected final ItemManager itemMgr;
-
-    /**
-     * The actual search index
-     */
-    protected final SearchIndex index;
-
-    /**
-     * The property type registry for type lookup.
-     */
-    protected final PropertyTypeRegistry propReg;
-
-    /**
-     * If <code>true</code> the default ordering of the result nodes is in
-     * document order.
-     */
-    private boolean documentOrder = true;
-
-    /**
      * Creates a new query instance from a query string.
      *
      * @param session   the session of the user executing this query.
@@ -110,26 +84,14 @@
                      String statement,
                      String language,
                      QueryNodeFactory factory) throws InvalidQueryException {
-        this.session = session;
-        this.itemMgr = itemMgr;
-        this.index = index;
-        this.propReg = propReg;
+        super(session, itemMgr, index, propReg);
         // parse query according to language
         // build query tree using the passed factory
         this.root = QueryParser.parse(statement, language,
                 session.getNamespaceResolver(), factory);
-
-        allNodesQueryNode = factory.createQueryRootNode();
-        PathQueryNode pathNode = factory.createPathQueryNode(allNodesQueryNode);
-        LocationStepQueryNode lsNode = factory.createLocationStepQueryNode(pathNode);
-        lsNode.setNameTest(null);
-        lsNode.setIncludeDescendants(true);
-        pathNode.addPathStep(lsNode);
-        pathNode.setAbsolute(true);
-        allNodesQueryNode.setLocationNode(pathNode);
-        
+        allNodesQueryNode = createMatchAllNodesQuery(factory);
     }
-
+    
     /**
      * Executes this query and returns a <code>{@link QueryResult}</code>.
      *
@@ -170,36 +132,10 @@
             ascSpecs[i] = orderSpecs[i].isAscending();
         }
 
-        return new QueryResultImpl(index, itemMgr, session.getNamespaceResolver(),
-                session.getAccessManager(), this, query, getSelectProperties(),
-                orderProperties, ascSpecs, documentOrder, offset, limit);
-    }
-
-    /**
-     * If set <code>true</code> the result nodes will be in document order
-     * per default (if no order by clause is specified). If set to
-     * <code>false</code> the result nodes are returned in whatever sequence
-     * the index has stored the nodes. That sequence is stable over multiple
-     * invocations of the same query, but will change when nodes get added or
-     * removed from the index.
-     * <p/>
-     * The default value for this property is <code>true</code>.
-     * @return the current value of this property.
-     */
-    public boolean getRespectDocumentOrder() {
-        return documentOrder;
-    }
-
-    /**
-     * Sets a new value for this property.
-     *
-     * @param documentOrder if <code>true</code> the result nodes are in
-     * document order per default.
-     *
-     * @see #getRespectDocumentOrder()
-     */
-    public void setRespectDocumentOrder(boolean documentOrder) {
-        this.documentOrder = documentOrder;
+        return new QueryResultImpl(index, itemMgr,
+                session.getNamespaceResolver(), session.getAccessManager(),
+                this, query, getSelectProperties(), orderProperties, ascSpecs,
+                getRespectDocumentOrder(), offset, limit);
     }
 
     /**
@@ -258,7 +194,29 @@
      * @return <code>true</code> if this query node needs content under
      *         /jcr:system to be queried; <code>false</code> otherwise.
      */
-    protected boolean needsSystemTree() {
+    public boolean needsSystemTree() {
         return this.root.needsSystemTree();
+    }
+
+    //----------------------------< internal >----------------------------------
+
+    /**
+     * Creates an abstract query tree that matches all nodes. XPath example:
+     * //element(*, nt:base)
+     *
+     * @param factory the query node factory.
+     * @return the abstract query tree.
+     */
+    private static QueryRootNode createMatchAllNodesQuery(
+            QueryNodeFactory factory) {
+        QueryRootNode allNodesQueryNode = factory.createQueryRootNode();
+        PathQueryNode pathNode = factory.createPathQueryNode(allNodesQueryNode);
+        LocationStepQueryNode lsNode = factory.createLocationStepQueryNode(pathNode);
+        lsNode.setNameTest(null);
+        lsNode.setIncludeDescendants(true);
+        pathNode.addPathStep(lsNode);
+        pathNode.setAbsolute(true);
+        allNodesQueryNode.setLocationNode(pathNode);
+        return allNodesQueryNode;
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java?rev=572945&r1=572944&r2=572945&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java Wed Sep  5 05:52:12 2007
@@ -72,7 +72,7 @@
     /**
      * The query instance which created this query result.
      */
-    protected final QueryImpl queryImpl;
+    protected final AbstractQueryImpl queryImpl;
 
     /**
      * The lucene query to execute.
@@ -158,7 +158,7 @@
                            ItemManager itemMgr,
                            NamespaceResolver resolver,
                            AccessManager accessMgr,
-                           QueryImpl queryImpl,
+                           AbstractQueryImpl queryImpl,
                            Query query,
                            QName[] selectProps,
                            QName[] orderProps,

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java?rev=572945&r1=572944&r2=572945&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java Wed Sep  5 05:52:12 2007
@@ -25,6 +25,8 @@
 import org.apache.jackrabbit.core.query.ExecutableQuery;
 import org.apache.jackrabbit.core.query.QueryHandlerContext;
 import org.apache.jackrabbit.core.query.QueryHandler;
+import org.apache.jackrabbit.core.query.ExecutablePreparedQuery;
+import org.apache.jackrabbit.core.query.qom.QueryObjectModelTree;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.NodeStateIterator;
 import org.apache.jackrabbit.core.state.ItemStateManager;
@@ -524,6 +526,30 @@
     }
 
     /**
+     * Creates a new query by specifying the query object model. If the query
+     * object model is considered invalid for the implementing class, an
+     * InvalidQueryException is thrown.
+     *
+     * @param session the session of the current user creating the query
+     *                object.
+     * @param itemMgr the item manager of the current user.
+     * @param qomTree query query object model tree.
+     * @return A <code>Query</code> object.
+     * @throws javax.jcr.query.InvalidQueryException
+     *          if the query object model tree is invalid.
+     * @see QueryHandler#createExecutablePreparedQuery(org.apache.jackrabbit.core.SessionImpl, org.apache.jackrabbit.core.ItemManager, org.apache.jackrabbit.core.query.qom.QueryObjectModelTree)
+     */
+    public ExecutablePreparedQuery createExecutablePreparedQuery(
+            SessionImpl session,
+            ItemManager itemMgr,
+            QueryObjectModelTree qomTree) throws InvalidQueryException {
+        PreparedQueryImpl query = new PreparedQueryImpl(session, itemMgr, this,
+                getContext().getPropertyTypeRegistry(), qomTree);
+        query.setRespectDocumentOrder(documentOrder);
+        return query;
+    }
+
+    /**
      * This method returns the QueryNodeFactory used to parse Queries. This method
      * may be overridden to provide a customized QueryNodeFactory
      */
@@ -557,7 +583,7 @@
      * @return the lucene Hits object.
      * @throws IOException if an error occurs while searching the index.
      */
-    public QueryHits executeQuery(QueryImpl queryImpl,
+    public QueryHits executeQuery(AbstractQueryImpl queryImpl,
                                   Query query,
                                   QName[] orderProps,
                                   boolean[] orderSpecs) throws IOException {

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/AbstractQOMNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/AbstractQOMNode.java?rev=572945&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/AbstractQOMNode.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/AbstractQOMNode.java Wed Sep  5 05:52:12 2007
@@ -0,0 +1,84 @@
+/*
+ * 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 org.apache.jackrabbit.name.NamePathResolver;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.Path;
+
+import javax.jcr.NamespaceException;
+
+/**
+ * <code>AbstractQOMNode</code>...
+ */
+public abstract class AbstractQOMNode {
+
+    protected final NamePathResolver resolver;
+
+    public AbstractQOMNode(NamePathResolver resolver) {
+        this.resolver = resolver;
+    }
+
+    /**
+     * Accepts a <code>visitor</code> and calls the appropriate visit method
+     * depending on the type of this QOM node.
+     *
+     * @param visitor the visitor.
+     * @param data    user defined data, which is passed to the visit method.
+     */
+    public abstract void accept(QOMTreeVisitor visitor, Object data);
+
+    //---------------------------< internal >-----------------------------------
+
+    /**
+     * Returns the prefixed JCR name for the given qualified name or
+     * <code>null</code> if <code>name</code> is <code>null</code>.
+     *
+     * @param name the qualified name.
+     * @return the prefixed JCR name or <code>name.toString()</code> if an
+     *         unknown namespace URI is encountered.
+     */
+    protected String getJCRName(QName name) {
+        if (name == null) {
+            return null;
+        }
+        try {
+            return resolver.getJCRName(name);
+        } catch (NamespaceException e) {
+            return name.toString();
+        }
+    }
+
+    /**
+     * Returns the prefixed JCR path for the given qualified path or
+     * <code>null</code> if <code>path</code> is <code>null</code>.
+     *
+     * @param path qualified path
+     * @return prefixed JCR path or <code>path.toString()</code> if an unknown
+     *         namespace URI is encountered.
+     */
+    protected String getJCRPath(Path path) {
+        if (path == null) {
+            return null;
+        }
+        try {
+            return resolver.getJCRPath(path);
+        } catch (NamespaceException e) {
+            return path.toString();
+        }
+    }
+}

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

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/AndImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/AndImpl.java?rev=572945&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/AndImpl.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/AndImpl.java Wed Sep  5 05:52:12 2007
@@ -0,0 +1,74 @@
+/*
+ * 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 org.apache.jackrabbit.name.NamePathResolver;
+
+import org.apache.jackrabbit.core.query.jsr283.qom.And;
+import org.apache.jackrabbit.core.query.jsr283.qom.Constraint;
+
+/**
+ * <code>AndImpl</code>...
+ */
+public class AndImpl extends ConstraintImpl implements And {
+
+    /**
+     * The first constraint.
+     */
+    private final ConstraintImpl constraint1;
+
+    /**
+     * The second constraint.
+     */
+    private final ConstraintImpl constraint2;
+
+    AndImpl(NamePathResolver resolver, ConstraintImpl c1, ConstraintImpl c2) {
+        super(resolver);
+        this.constraint1 = c1;
+        this.constraint2 = c2;
+    }
+
+    /**
+     * Gets the first constraint.
+     *
+     * @return the constraint; non-null
+     */
+    public Constraint getConstraint1() {
+        return constraint1;
+    }
+
+    /**
+     * Gets the second constraint.
+     *
+     * @return the constraint; non-null
+     */
+    public Constraint getConstraint2() {
+        return constraint2;
+    }
+
+    //------------------------< AbstractQOMNode >-------------------------------
+
+    /**
+     * Accepts a <code>visitor</code> and calls the appropriate visit method
+     * depending on the type of this QOM node.
+     *
+     * @param visitor the visitor.
+     */
+    public void accept(QOMTreeVisitor visitor, Object data) {
+        visitor.visit(this, data);
+    }
+}

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

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/BindVariableValueImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/BindVariableValueImpl.java?rev=572945&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/BindVariableValueImpl.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/BindVariableValueImpl.java Wed Sep  5 05:52:12 2007
@@ -0,0 +1,72 @@
+/*
+ * 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 org.apache.jackrabbit.name.NamePathResolver;
+import org.apache.jackrabbit.name.QName;
+
+import org.apache.jackrabbit.core.query.jsr283.qom.BindVariableValue;
+
+/**
+ * <code>BindVariableValueImpl</code>...
+ */
+public class BindVariableValueImpl
+        extends StaticOperandImpl
+        implements BindVariableValue {
+
+    /**
+     * The name of the bind variable.
+     */
+    private final QName variableName;
+
+    BindVariableValueImpl(NamePathResolver resolver, QName variableName) {
+        super(resolver);
+        this.variableName = variableName;
+    }
+
+    /**
+     * Gets the name of the bind variable.
+     *
+     * @return the bind variable name; non-null
+     */
+    public QName getBindVariableQName() {
+        return variableName;
+    }
+
+    //-------------------------< BindVariableValue >----------------------------
+
+    /**
+     * Gets the name of the bind variable.
+     *
+     * @return the bind variable name; non-null
+     */
+    public String getBindVariableName() {
+        return getJCRName(variableName);
+    }
+
+    //------------------------< AbstractQOMNode >-------------------------------
+
+    /**
+     * Accepts a <code>visitor</code> and calls the appropriate visit method
+     * depending on the type of this QOM node.
+     *
+     * @param visitor the visitor.
+     */
+    public void accept(QOMTreeVisitor visitor, Object data) {
+        visitor.visit(this, data);
+    }
+}

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

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ChildNodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ChildNodeImpl.java?rev=572945&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ChildNodeImpl.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ChildNodeImpl.java Wed Sep  5 05:52:12 2007
@@ -0,0 +1,75 @@
+/*
+ * 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 org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.NamePathResolver;
+
+import org.apache.jackrabbit.core.query.jsr283.qom.ChildNode;
+
+/**
+ * <code>ChildNodeImpl</code>...
+ */
+public class ChildNodeImpl extends ConstraintImpl implements ChildNode {
+
+    /**
+     * The name of a selector.
+     */
+    private final QName selectorName;
+
+    /**
+     * An absolute path.
+     */
+    private final Path path;
+
+    ChildNodeImpl(NamePathResolver resolver, QName selectorName, Path path) {
+        super(resolver);
+        this.selectorName = selectorName;
+        this.path = path;
+    }
+
+    /**
+     * Gets the name of the selector against which to apply this constraint.
+     *
+     * @return the selector name; non-null
+     */
+    public String getSelectorName() {
+        return getJCRName(selectorName);
+    }
+
+    /**
+     * Gets the absolute path.
+     *
+     * @return the path; non-null
+     */
+    public String getPath() {
+        return getJCRPath(path);
+    }
+
+    //------------------------< AbstractQOMNode >-------------------------------
+
+    /**
+     * Accepts a <code>visitor</code> and calls the appropriate visit method
+     * depending on the type of this QOM node.
+     *
+     * @param visitor the visitor.
+     */
+    public void accept(QOMTreeVisitor visitor, Object data) {
+        visitor.visit(this, data);
+    }
+}

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

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ChildNodeJoinConditionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ChildNodeJoinConditionImpl.java?rev=572945&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ChildNodeJoinConditionImpl.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ChildNodeJoinConditionImpl.java Wed Sep  5 05:52:12 2007
@@ -0,0 +1,78 @@
+/*
+ * 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 org.apache.jackrabbit.name.NamePathResolver;
+import org.apache.jackrabbit.name.QName;
+
+import org.apache.jackrabbit.core.query.jsr283.qom.ChildNodeJoinCondition;
+
+/**
+ * <code>ChildNodeJoinConditionImpl</code>...
+ */
+public class ChildNodeJoinConditionImpl
+        extends JoinConditionImpl
+        implements ChildNodeJoinCondition {
+
+    /**
+     * The name of the child selector.
+     */
+    private final QName childSelectorName;
+
+    /**
+     * The name of the parent selector.
+     */
+    private final QName parentSelectorName;
+
+    ChildNodeJoinConditionImpl(NamePathResolver resolver,
+                               QName childSelectorName,
+                               QName parentSelectorName) {
+        super(resolver);
+        this.childSelectorName = childSelectorName;
+        this.parentSelectorName = parentSelectorName;
+    }
+
+    /**
+     * Gets the name of the child selector.
+     *
+     * @return the selector name; non-null
+     */
+    public String getChildSelectorName() {
+        return getJCRName(childSelectorName);
+    }
+
+    /**
+     * Gets the name of the parent selector.
+     *
+     * @return the selector name; non-null
+     */
+    public String getParentSelectorName() {
+        return getJCRName(parentSelectorName);
+    }
+
+    //------------------------< AbstractQOMNode >-------------------------------
+
+    /**
+     * Accepts a <code>visitor</code> and calls the appropriate visit method
+     * depending on the type of this QOM node.
+     *
+     * @param visitor the visitor.
+     */
+    public void accept(QOMTreeVisitor visitor, Object data) {
+        visitor.visit(this, data);
+    }
+}

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

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ColumnImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ColumnImpl.java?rev=572945&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ColumnImpl.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ColumnImpl.java Wed Sep  5 05:52:12 2007
@@ -0,0 +1,128 @@
+/*
+ * 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 org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.NamePathResolver;
+
+import org.apache.jackrabbit.core.query.jsr283.qom.Column;
+
+/**
+ * <code>ColumnImpl</code>...
+ */
+public class ColumnImpl extends AbstractQOMNode implements Column {
+
+    /**
+     * The name of the selector.
+     */
+    private final QName selectorName;
+
+    /**
+     * The name of the property.
+     */
+    private final QName propertyName;
+
+    /**
+     * The name of the column.
+     */
+    private final QName columnName;
+
+    ColumnImpl(NamePathResolver resolver,
+               QName selectorName,
+               QName propertyName,
+               QName columnName) {
+        super(resolver);
+        this.selectorName = selectorName;
+        this.propertyName = propertyName;
+        this.columnName = columnName;
+    }
+
+    /**
+     * Gets the name of the selector.
+     *
+     * @return the selector name; non-null
+     */
+    public QName getSelectorQName() {
+        return selectorName;
+    }
+
+    /**
+     * Gets the name of the property.
+     *
+     * @return the property name, or null to include a column for each
+     *         single-value non-residual property of the selector's node type
+     */
+    public QName getPropertyQName() {
+        return propertyName;
+    }
+
+    /**
+     * Gets the column name.
+     * <p/>
+     *
+     * @return the column name; must be null if <code>getPropertyName</code> is
+     *         null and non-null otherwise
+     */
+    public QName getColumnQName() {
+        return columnName;
+    }
+
+
+    //---------------------------< Column >-------------------------------------
+
+    /**
+     * Gets the name of the selector.
+     *
+     * @return the selector name; non-null
+     */
+    public String getSelectorName() {
+        return getJCRName(selectorName);
+    }
+
+    /**
+     * Gets the name of the property.
+     *
+     * @return the property name, or null to include a column for each
+     *         single-value non-residual property of the selector's node type
+     */
+    public String getPropertyName() {
+        return getJCRName(propertyName);
+    }
+
+    /**
+     * Gets the column name.
+     * <p/>
+     *
+     * @return the column name; must be null if <code>getPropertyName</code> is
+     *         null and non-null otherwise
+     */
+    public String getColumnName() {
+        return getJCRName(columnName);
+    }
+
+    //------------------------< AbstractQOMNode >-------------------------------
+
+    /**
+     * Accepts a <code>visitor</code> and calls the appropriate visit method
+     * depending on the type of this QOM node.
+     *
+     * @param visitor the visitor.
+     */
+    public void accept(QOMTreeVisitor visitor, Object data) {
+        visitor.visit(this, data);
+    }
+}

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

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ComparisonImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ComparisonImpl.java?rev=572945&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ComparisonImpl.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ComparisonImpl.java Wed Sep  5 05:52:12 2007
@@ -0,0 +1,100 @@
+/*
+ * 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 org.apache.jackrabbit.name.NamePathResolver;
+
+import org.apache.jackrabbit.core.query.jsr283.qom.Comparison;
+import org.apache.jackrabbit.core.query.jsr283.qom.DynamicOperand;
+import org.apache.jackrabbit.core.query.jsr283.qom.StaticOperand;
+
+/**
+ * <code>ComparisonImpl</code>...
+ */
+public class ComparisonImpl extends ConstraintImpl implements Comparison {
+
+    /**
+     * The first operand.
+     */
+    private final DynamicOperandImpl operand1;
+
+    /**
+     * The operator.
+     */
+    private final int operator;
+
+    /**
+     * The second operand.
+     */
+    private final StaticOperandImpl operand2;
+
+    ComparisonImpl(NamePathResolver resolver,
+                   DynamicOperandImpl operand1,
+                   int operator,
+                   StaticOperandImpl operand2) {
+        super(resolver);
+        this.operand1 = operand1;
+        this.operator = operator;
+        this.operand2 = operand2;
+    }
+
+    /**
+     * Gets the first operand.
+     *
+     * @return the operand; non-null
+     */
+    public DynamicOperand getOperand1() {
+        return operand1;
+    }
+
+    /**
+     * Gets the operator.
+     *
+     * @return either <ul> <li>{@link org.apache.jackrabbit.core.query.jsr283.qom.QueryObjectModelConstants#OPERATOR_EQUAL_TO},</li>
+     *         <li>{@link org.apache.jackrabbit.core.query.jsr283.qom.QueryObjectModelConstants#OPERATOR_NOT_EQUAL_TO},</li>
+     *         <li>{@link org.apache.jackrabbit.core.query.jsr283.qom.QueryObjectModelConstants#OPERATOR_LESS_THAN},</li>
+     *         <li>{@link org.apache.jackrabbit.core.query.jsr283.qom.QueryObjectModelConstants#OPERATOR_LESS_THAN_OR_EQUAL_TO},</li>
+     *         <li>{@link org.apache.jackrabbit.core.query.jsr283.qom.QueryObjectModelConstants#OPERATOR_GREATER_THAN},</li>
+     *         <li>{@link org.apache.jackrabbit.core.query.jsr283.qom.QueryObjectModelConstants#OPERATOR_GREATER_THAN_OR_EQUAL_TO},
+     *         or</li> <li>{@link org.apache.jackrabbit.core.query.jsr283.qom.QueryObjectModelConstants#OPERATOR_LIKE}</li>
+     *         </ul>
+     */
+    public int getOperator() {
+        return operator;
+    }
+
+    /**
+     * Gets the second operand.
+     *
+     * @return the operand; non-null
+     */
+    public StaticOperand getOperand2() {
+        return operand2;
+    }
+
+    //------------------------< AbstractQOMNode >-------------------------------
+
+    /**
+     * Accepts a <code>visitor</code> and calls the appropriate visit method
+     * depending on the type of this QOM node.
+     *
+     * @param visitor the visitor.
+     */
+    public void accept(QOMTreeVisitor visitor, Object data) {
+        visitor.visit(this, data);
+    }
+}

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

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ConstraintImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ConstraintImpl.java?rev=572945&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ConstraintImpl.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/qom/ConstraintImpl.java Wed Sep  5 05:52:12 2007
@@ -0,0 +1,34 @@
+/*
+ * 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 org.apache.jackrabbit.name.NamePathResolver;
+
+import org.apache.jackrabbit.core.query.jsr283.qom.Constraint;
+
+/**
+ * <code>ConstraintImpl</code> is the common basis for classes that implement
+ * the {@link org.apache.jackrabbit.core.query.jsr283.qom.Constraint} interface.
+ */
+public abstract class ConstraintImpl
+        extends AbstractQOMNode
+        implements Constraint {
+
+    public ConstraintImpl(NamePathResolver resolver) {
+        super(resolver);
+    }
+}

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



Mime
View raw message