org.apache.jackrabbit.core.query
Class QueryImpl

java.lang.Object
  extended by org.apache.jackrabbit.core.query.AbstractQueryImpl
      extended by org.apache.jackrabbit.core.query.QueryImpl
All Implemented Interfaces:
Query
Direct Known Subclasses:
QueryObjectModelImpl

public class QueryImpl
extends AbstractQueryImpl

Provides the default implementation for a JCR query.


Field Summary
protected  QueryHandler handler
          The query handler for this query.
static String JCR_JQOM
          A string constant representing the JCR-JQOM query language.
static String JCR_SQL2
          A string constant representing the JCR-SQL2 query language.
protected  String language
          The syntax of the query statement
protected  Node node
          The node where this query is persisted.
protected  ExecutableQuery query
          The actual query implementation that can be executed
protected  SessionImpl session
          The session of the user executing this query
protected  String statement
          The query statement
 
Fields inherited from interface javax.jcr.query.Query
SQL, XPATH
 
Constructor Summary
QueryImpl()
           
 
Method Summary
 void bindValue(String varName, Value value)
          Binds the given value to the variable named varName.
protected  void checkInitialized()
          Checks if this query is initialized and throws an IllegalStateException if it is not yet initialized.
protected  void checkNotInitialized()
          Checks if this query is not yet initialized and throws an IllegalStateException if it is already initialized.
 QueryResult execute()
          This method simply forwards the execute call to the ExecutableQuery object returned by QueryHandler.createExecutableQuery(org.apache.jackrabbit.core.SessionImpl, org.apache.jackrabbit.core.ItemManager, java.lang.String, java.lang.String).
 String getLanguage()
          
 String getStatement()
          
 String getStoredQueryPath()
          
 void init(SessionImpl session, ItemManager itemMgr, QueryHandler handler, Node node)
          Initializes a query instance from a nt:query node.
 void init(SessionImpl session, ItemManager itemMgr, QueryHandler handler, QueryObjectModelTree qomTree, String language)
          Initializes a query instance from a query object model.
 void init(SessionImpl session, ItemManager itemMgr, QueryHandler handler, String statement, String language)
          Initializes a query instance from a query string.
protected  void setInitialized()
          Sets the initialized flag.
 void setLimit(long limit)
          Sets the maximum size of the result set.
 void setOffset(long offset)
          Sets the start offset of the result set.
 Node storeAsNode(String absPath)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JCR_SQL2

public static final String JCR_SQL2
A string constant representing the JCR-SQL2 query language.

Since:
JCR 2.0 TODO: REMOVE WHEN JSR 283 IS FINAL!!
See Also:
Constant Field Values

JCR_JQOM

public static final String JCR_JQOM
A string constant representing the JCR-JQOM query language.

Since:
JCR 2.0 TODO: REMOVE WHEN JSR 283 IS FINAL!!
See Also:
Constant Field Values

session

protected SessionImpl session
The session of the user executing this query


statement

protected String statement
The query statement


language

protected String language
The syntax of the query statement


query

protected ExecutableQuery query
The actual query implementation that can be executed


node

protected Node node
The node where this query is persisted. Only set when this is a persisted query.


handler

protected QueryHandler handler
The query handler for this query.

Constructor Detail

QueryImpl

public QueryImpl()
Method Detail

init

public void init(SessionImpl session,
                 ItemManager itemMgr,
                 QueryHandler handler,
                 String statement,
                 String language)
          throws InvalidQueryException
Description copied from class: AbstractQueryImpl
Initializes a query instance from a query string.

Specified by:
init in class AbstractQueryImpl
Parameters:
session - the session of the user executing this query.
itemMgr - the item manager of the session executing this query.
handler - the query handler of the search index.
statement - the query statement.
language - the syntax of the query statement.
Throws:
InvalidQueryException - if the query statement is invalid according to the specified language.

init

public void init(SessionImpl session,
                 ItemManager itemMgr,
                 QueryHandler handler,
                 Node node)
          throws InvalidQueryException,
                 RepositoryException
Description copied from class: AbstractQueryImpl
Initializes a query instance from a nt:query node.

Specified by:
init in class AbstractQueryImpl
Parameters:
session - the session of the user executing this query.
itemMgr - the item manager of the session executing this query.
handler - the query handler of the search index.
node - a node of type nt:query.
Throws:
InvalidQueryException - If node is not a valid persisted query (that is, a node of type nt:query).
RepositoryException - if another error occurs

init

public void init(SessionImpl session,
                 ItemManager itemMgr,
                 QueryHandler handler,
                 QueryObjectModelTree qomTree,
                 String language)
          throws InvalidQueryException,
                 RepositoryException
Description copied from class: AbstractQueryImpl
Initializes a query instance from a query object model.

Specified by:
init in class AbstractQueryImpl
Parameters:
session - the session of the user executing this query.
itemMgr - the item manager of the session executing this query.
handler - the query handler of the search index.
qomTree - the query object model tree.
language - the original query syntax from where the JQOM was created.
Throws:
RepositoryException - if another error occurs
InvalidQueryException

execute

public QueryResult execute()
                    throws RepositoryException
This method simply forwards the execute call to the ExecutableQuery object returned by QueryHandler.createExecutableQuery(org.apache.jackrabbit.core.SessionImpl, org.apache.jackrabbit.core.ItemManager, java.lang.String, java.lang.String).

Throws:
RepositoryException

getStatement

public String getStatement()


getLanguage

public String getLanguage()


getStoredQueryPath

public String getStoredQueryPath()
                          throws ItemNotFoundException,
                                 RepositoryException

Throws:
ItemNotFoundException
RepositoryException

storeAsNode

public Node storeAsNode(String absPath)
                 throws ItemExistsException,
                        PathNotFoundException,
                        VersionException,
                        ConstraintViolationException,
                        LockException,
                        UnsupportedRepositoryOperationException,
                        RepositoryException

Throws:
ItemExistsException
PathNotFoundException
VersionException
ConstraintViolationException
LockException
UnsupportedRepositoryOperationException
RepositoryException

bindValue

public void bindValue(String varName,
                      Value value)
               throws IllegalArgumentException,
                      RepositoryException
Binds the given value to the variable named varName.

Parameters:
varName - name of variable in query
value - value to bind
Throws:
IllegalArgumentException - if varName is not a valid variable in this query.
RepositoryException - if an error occurs.

setLimit

public void setLimit(long limit)
Sets the maximum size of the result set.

Parameters:
limit - new maximum size of the result set

setOffset

public void setOffset(long offset)
Sets the start offset of the result set.

Parameters:
offset - new start offset of the result set

setInitialized

protected void setInitialized()
Sets the initialized flag.


checkNotInitialized

protected void checkNotInitialized()
Checks if this query is not yet initialized and throws an IllegalStateException if it is already initialized.


checkInitialized

protected void checkInitialized()
Checks if this query is initialized and throws an IllegalStateException if it is not yet initialized.



Copyright © 2004-2008 The Apache Software Foundation. All Rights Reserved.