| javax.jcr.query.Query
Query | public interface Query (Code) | | A Query object.
|
Field Summary | |
final public static String | JCR_JQOM A string constant representing the JCR-JQOM query language. | final public static String | JCR_SQL2 A string constant representing the JCR-SQL2 query language. | final public static int | SEARCH_VERSIONS Flag determining the scope of a query. | final public static int | SEARCH_WORKSPACE Flag determining the scope of a query. | final public static int | SEARCH_WORKSPACE_NO_SYSTEM Flag determining the scope of a query. | final public static String | SQL A string constant representing the SQL query language as defined in JCR 1.0. | final public static String | XPATH A string constant representing the XPath query language as defined in JCR 1.0. |
Method Summary | |
public QueryResult | execute() Executes this query and returns a
QueryResult object. | public QueryResult | execute(int searchSpace) Executes this query and returns a
QueryResult .
The flag searchSpace determines the scope of the search:
SEARCH_WORKSPACE : Search the current workspace. | public String | getLanguage() Returns the language set for this query. | public String | getStatement() Returns the statement defined for this query.
If the language of this query is string-based (like JCR-SQL2), this
method will return the statement that was used to create this query.
If the language of this query is JCR-JQOM, this method will return the
JCR-SQL2 equivalent of the JCR-JQOM object tree.
This is the standard serialization of JCR-JQOM and is also the string
stored in the jcr:statement property if the query is
persisted. | public String | getStoredQueryPath() If this is a Query object that has been stored using
Query.storeAsNode (regardless of whether it has been save d yet)
or retrieved using
QueryManager.getQuery ), then this method
returns the path of the nt:query node that stores the query. | public void | setLimit(long limit) Sets the maximum size of the result set to limit . | public void | setOffset(long offset) Sets the start offset of the result set to offset . | public Node | storeAsNode(String absPath) Creates a node representing this Query in content.
In a level 1 repository this method throws an UnsupportedRepositoryOperationException .
In a level 2 repository it creates a node of type nt:query at absPath
and returns that node.
In order to persist the newly created node, a save must be performed that includes the
parent of this new node within its scope. |
JCR_JQOM | final public static String JCR_JQOM(Code) | | A string constant representing the JCR-JQOM query language.
since: JCR 2.0 |
JCR_SQL2 | final public static String JCR_SQL2(Code) | | A string constant representing the JCR-SQL2 query language.
since: JCR 2.0 |
SEARCH_VERSIONS | final public static int SEARCH_VERSIONS(Code) | | Flag determining the scope of a query. For details, see
Query.execute(int) .
since: JCR 2.0 |
SEARCH_WORKSPACE | final public static int SEARCH_WORKSPACE(Code) | | Flag determining the scope of a query. For details, see
Query.execute(int) .
since: JCR 2.0 |
SEARCH_WORKSPACE_NO_SYSTEM | final public static int SEARCH_WORKSPACE_NO_SYSTEM(Code) | | Flag determining the scope of a query. For details, see
Query.execute(int) .
since: JCR 2.0 |
SQL | final public static String SQL(Code) | | A string constant representing the SQL query language as defined in JCR 1.0.
|
XPATH | final public static String XPATH(Code) | | A string constant representing the XPath query language as defined in JCR 1.0.
|
execute | public QueryResult execute(int searchSpace) throws SearchNotSupportedException, RepositoryException(Code) | | Executes this query and returns a
QueryResult .
The flag searchSpace determines the scope of the search:
SEARCH_WORKSPACE : Search the current workspace. In
repositories that support full versioning, each workspace includes a
subtree /jcr:system/jcr:versionStorage which reflects the
version information of the repository. In such repositories this option
will search the entire workspace including this version storage subtree.
In repositories that support only simple versioning, repository version
storage is not reflected in workspace content and so this option
will, by definition, not search versions. In that case searching of
versions can be done with the SEARCH_VERSIONS option.
In either of the above cases, if a repository supports other features
that mandate the storage of data under /jcr:system these
substructures will be searched under this option. To prevent search of
the system node subtree the option SEARCH_WORKSPACE_NO_SYSTEM
can be used.
This option is equivalent to the zero-parameter signature
Query.execute() .
SEARCH_WORKSPACE_NO_SYSTEM : Searches the current workspace
except for the /jcr:system subtree. If no /jcr:system
subtree exists this option is equivalent to SEARCH_WORKSPACE .
SEARCH_VERSIONS : Search all versions of all nodes in the
repository. This option will search version storage regardless of whether
it is reflected in workspace content (as when full versioning is s
upported) or hidden within the implementation (as when only simple
versioning is supported). Queries using this option will return results
in the form of nt:version nodes even in repositories that do
not expose version storage as content in the the workspace.
In repositories that support only simple versioning, using this option is
the only way to search version information. In repositories that support
full versioning this option is also supported though queries involving
features unique to full versioning will still require direct search of
the version history structure below /jcr:system/jcr:versionHistory .
A SearchNotSupportedException is thrown if the QueryManager
does not support the search mode.
Throws a RepositoryException if an error occurs.
Parameters: searchSpace - flag which determines the scope of the search a QueryResult throws: SearchNotSupportedException - if the QueryManager does not support the search mode. throws: RepositoryException - if an error occurs since: JCR 2.0 |
getStatement | public String getStatement()(Code) | | Returns the statement defined for this query.
If the language of this query is string-based (like JCR-SQL2), this
method will return the statement that was used to create this query.
If the language of this query is JCR-JQOM, this method will return the
JCR-SQL2 equivalent of the JCR-JQOM object tree.
This is the standard serialization of JCR-JQOM and is also the string
stored in the jcr:statement property if the query is
persisted. See
Query.storeAsNode(String) .
the query statement. |
setLimit | public void setLimit(long limit)(Code) | | Sets the maximum size of the result set to limit .
Parameters: limit - a long since: JCR 2.0 |
setOffset | public void setOffset(long offset)(Code) | | Sets the start offset of the result set to offset .
Parameters: offset - a long since: JCR 2.0 |
storeAsNode | public Node storeAsNode(String absPath) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, UnsupportedRepositoryOperationException, RepositoryException(Code) | | Creates a node representing this Query in content.
In a level 1 repository this method throws an UnsupportedRepositoryOperationException .
In a level 2 repository it creates a node of type nt:query at absPath
and returns that node.
In order to persist the newly created node, a save must be performed that includes the
parent of this new node within its scope. In other words, either a Session.save or
an Item.save on the parent or higher-degree ancestor of absPath must be performed.
In the context of this method the absPath provided must not
have an index on its final element. If it does then a RepositoryException
is thrown.
Strictly speaking, the parameter is actually a absolute path to the parent
node of the node to be added, appended with the name desired for the new
node. It does not specify a position within the child node ordering (if
such ordering is supported). If ordering is supported by the node type
of the parent node then the new node is appended to the end of the child
node list.
An ItemExistsException will be thrown either immediately (by
this method), or on save , if an item at the specified path already exists
and same-name siblings are not allowed. Implementations may differ on
when this validation is performed.
A PathNotFoundException will be thrown either immediately,
or on save , if the specified path implies intermediary
nodes that do not exist. Implementations may differ on when this validation is performed.
A ConstraintViolationException will be thrown either immediately
or on save , if adding the node would violate a node type or implementation-specific
constraint or if an attempt is made to add a node as the child of a property.
Implementations may differ on when this validation is performed.
A VersionException will be thrown either immediately (by
this method), or on save , if the node to which the new child is being
added is versionable and checked-in or is non-versionable but its nearest
versionable ancestor is checked-in. Implementations may differ on when
this validation is performed.
A LockException will be thrown either immediately (by
this method), or on save , if a lock prevents the addition of the node.
Implementations may differ on when this validation is performed.
Parameters: absPath - absolute path the query should be stored at the newly created node. throws: ItemExistsException - if an item at the specified path already exists,same-name siblings are not allowed and this implementation performs thisvalidation immediately instead of waiting until save . throws: PathNotFoundException - if the specified path implies intermediaryNode s that do not exist or the last element ofrelPath has an index, and this implementation performs thisvalidation immediately instead of waiting until save . throws: ConstraintViolationException - if a node type or implementation-specific constraintis violated or if an attempt is made to add a node as the child of a property and thisimplementation performs this validation immediately instead of waiting until save . throws: VersionException - if the node to which the new child is being added is versionable andchecked-in or is non-versionable but its nearest versionable ancestor is checked-in and thisimplementation performs this validation immediately instead of waiting until save . throws: LockException - if a lock prevents the addition of the node and thisimplementation performs this validation immediately instead of waiting until save . throws: UnsupportedRepositoryOperationException - in a level 1 implementation. throws: RepositoryException - if another error occurs or if the absPath provided hasan index on its final element. |
|
|