KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > core > search > Query


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2006 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.cms.core.search;
14
15 import javax.jcr.ItemExistsException;
16 import javax.jcr.ItemNotFoundException;
17 import javax.jcr.Node;
18 import javax.jcr.PathNotFoundException;
19 import javax.jcr.RepositoryException;
20 import javax.jcr.UnsupportedRepositoryOperationException;
21 import javax.jcr.lock.LockException;
22 import javax.jcr.nodetype.ConstraintViolationException;
23 import javax.jcr.version.VersionException;
24
25
26 /**
27  * Date: Apr 4, 2005 Time: 11:02:35 AM
28  * @author Sameer Charles
29  */

30
31 public interface Query {
32
33     String JavaDoc XPATH = "xpath"; //$NON-NLS-1$
34

35     String JavaDoc SQL = "sql"; //$NON-NLS-1$
36

37     /**
38      * <i>Description inherited from javax.jcr.query.Query#execute()</i><br>
39      * Executes this query and returns a <code>{@link QueryResult}</code>.
40      * @return a <code>QueryResult</code>
41      * @throws RepositoryException if an error occurs
42      */

43     QueryResult execute() throws RepositoryException;
44
45     /**
46      * <i>Description inherited from javax.jcr.query.Query#getStatement()</i><br>
47      * Returns the statement set for this query.
48      * @return the query statement.
49      */

50     String JavaDoc getStatement();
51
52     /**
53      * <i>Description inherited from javax.jcr.query.Query#getLanguage()</i><br>
54      * Returns the language set for this query. This will be one of the query language constants returned by
55      * {@link QueryManager#getSupportedQueryLanguages}.
56      * @return the query language.
57      */

58     String JavaDoc getLanguage();
59
60     /**
61      * <i>Description inherited from javax.jcr.query.Query#getStoredQueryPath()</i><br>
62      * If this is a <code>Query</code> object that has been stored using {@link Query#storeAsNode} (regardless of
63      * whether it has been <code>save</code>d yet) or retrieved using {@link QueryManager#getQuery}), then this
64      * method returns the path of the <code>nt:query</code> node that stores the query. If this is a transient query
65      * (that is, a <code>Query</code> object created with {@link QueryManager#createQuery} but not yet stored) then
66      * this method throws an <code>ItemNotFoundException</code>.
67      * @return path of the node representing this query.
68      * @throws ItemNotFoundException if this query is not a stored query.
69      * @throws RepositoryException if another error occurs.
70      */

71     String JavaDoc getStoredQueryPath() throws ItemNotFoundException, RepositoryException;
72
73     /**
74      * <i>Description inherited from javax.jcr.query.Query#storeAsNode()</i><br>
75      * Creates a node representing this <code>Query</code> in content. <p/> In a level 1 repository this method throws
76      * an <code>UnsupportedRepositoryOperationException</code>. <p/> In a level 2 repository it creates a node of
77      * type <code>nt:query</code> at <code>absPath</code> and returns that node. <p/> In order to persist the newly
78      * created node, a <code>save</code> must be performed that includes <i>the parent</i> of this new node within
79      * its scope. In other words, either a <code>Session.save</code> or an <code>Item.save</code> on the parent or
80      * higher-degree ancestor of <code>absPath</code> must be performed. <p/> An <code>ItemExistsException</code>
81      * will be thrown either immediately (by this method), or on <code>save</code>, if an item at the specified path
82      * already exists and same-name siblings are not allowed. Implementations may differ on when this validation is
83      * performed. <p/> A <code>PathNotFoundException</code> will be thrown either immediately , or on
84      * <code>save</code>, if the specified path implies intermediary nodes that do not exist. Implementations may
85      * differ on when this validation is performed. <p/> A <code>ConstraintViolationException</code>will be thrown
86      * either immediately or on <code>save</code>, if adding the node would violate a node type or
87      * implementation-specific constraintor if an attempt is made to add a node as the child of a property.
88      * Implementations may differ on when this validation is performed. <p/> A <code>VersionException</code> will be
89      * thrown either immediately (by this method), or on <code>save</code>, if the node to which the new child is
90      * being added is versionable and checked-in or is non-versionable but its nearest versionable ancestor is
91      * checked-in. Implementations may differ on when this validation is performed. <p/> A <code>LockException</code>
92      * will be thrown either immediately (by this method), or on <code>save</code>, if a lock prevents the addition
93      * of the node. Implementations may differ on when this validation is performed.
94      * @return the newly created node.
95      * @throws ItemExistsException if an item at the specified path already exists, same-name siblings are not allowed
96      * and this implementation performs this validation immediately instead of waiting until <code>save</code>.
97      * @throws PathNotFoundException if the specified path implies intermediary <code>Node</code>s that do not exist
98      * or the last element of <code>relPath</code> has an index, and this implementation performs this validation
99      * immediately instead of waiting until <code>save</code>.
100      * @throws ConstraintViolationException if a node type or implementation-specific constraint is violated or if an
101      * attempt is made to add a node as the child of a property and this implementation performs this validation
102      * immediately instead of waiting until <code>save</code>.
103      * @throws VersionException if the node to which the new child is being added is versionable and checked-in or is
104      * non-versionable but its nearest versionable ancestor is checked-in and this implementation performs this
105      * validation immediately instead of waiting until <code>save</code>.
106      * @throws LockException if a lock prevents the addition of the node and this implementation performs this
107      * validation immediately instead of waiting until <code>save</code>.
108      * @throws UnsupportedRepositoryOperationException in a level 1 implementation.
109      * @throws RepositoryException if another error occurs or if the <code>relPath</code> provided has an index on its
110      * final element.
111      */

112     Node storeAsNode(String JavaDoc s) throws ItemExistsException, PathNotFoundException, VersionException,
113         ConstraintViolationException, LockException, UnsupportedRepositoryOperationException, RepositoryException;
114
115 }
116
Popular Tags