01: /*
02: * Copyright 2006 Day Management AG, Switzerland. All rights reserved.
03: */
04: package javax.jcr.query;
05:
06: import javax.jcr.RepositoryException;
07: import javax.jcr.Node;
08: import javax.jcr.query.qom.QueryObjectModelFactory;
09:
10: /**
11: * This interface encapsulates methods for the management of search queries.
12: * Provides methods for the creation and retrieval of search queries.
13: *
14: */
15: public interface QueryManager {
16:
17: /**
18: * Creates a new query by specifying the query <code>statement</code> itself and the
19: * <code>language</code> in which the query is stated. If the query <code>statement</code> is
20: * syntactically invalid, given the language specified, an
21: * <code>InvalidQueryException</code> is thrown. The <code>language</code> must
22: * be a string from among those returned by QueryManager.getSupportedQueryLanguages();
23: * if it is not, then an <code>InvalidQueryException</code> is thrown.
24: *
25: * @param statement a <code>String</code>
26: * @param language a <code>String</code>
27: * @return a <code>Query</code> object
28: * @throws InvalidQueryException if the query statement is syntactically invalid
29: * or the specified language is not supported
30: * @throws RepositoryException if another error occurs
31: */
32: public Query createQuery(String statement, String language)
33: throws InvalidQueryException, RepositoryException;
34:
35: /**
36: * Creates a new prepared query by specifying the query <code>statement</code>
37: * itself and the <code>language</code> in which the query is stated. If the
38: * query statement is syntactically invalid, given the language specified, an
39: * <code>InvalidQueryException</code> is thrown. The language parameter must be a string
40: * from among those returned by <code>QueryManager.getSupportedQueryLanguages()</code>;
41: * if it is not, then an <code>InvalidQueryException</code> is thrown.
42: *
43: * @param statement a <code>String</code>
44: * @param language a <code>String</code>
45: * @return a <code>PreparedQuery</code> object
46: * @throws InvalidQueryException if the query statement is syntactically invalid
47: * or the specified language is not supported
48: * @throws RepositoryException if another error occurs
49: * @since JCR 2.0
50: */
51: public PreparedQuery createPreparedQuery(String statement,
52: String language) throws InvalidQueryException,
53: RepositoryException;
54:
55: /**
56: * Returns a <code>QueryObjectModelFactory</code> with which a JCR-JQOM query
57: * can be built programmatically.
58: *
59: * @return a <code>QueryObjectModelFactory</code> object
60: * @since JCR 2.0
61: */
62: public QueryObjectModelFactory getQOMFactory();
63:
64: /**
65: * Retrieves an existing persistent query. If <code>node</code>
66: * is not a valid persisted query (that is, a node of type
67: * <code>nt:query</code>), an <code>InvalidQueryException</code>
68: * is thrown.
69: * <p/>
70: * Persistent queries are created by first using <code>QueryManager.createQuery</code>
71: * to create a <code>Query</code> object and then calling <code>Query.save</code> to
72: * persist the query to a location in the workspace.
73: *
74: * @param node a persisted query (that is, a node of type <code>nt:query</code>).
75: * @throws InvalidQueryException If <code>node</code> is not a valid persisted query
76: * (that is, a node of type <code>nt:query</code>).
77: * @throws RepositoryException if another error occurs
78: * @return a <code>Query</code> object.
79: */
80: public Query getQuery(Node node) throws InvalidQueryException,
81: RepositoryException;
82:
83: /**
84: * Returns an array of strings representing all query languages supported by this repository.
85: * In level 1 this set must include the strings represented by the constants
86: * {@link Query#JCR_SQL2} and {@link Query#JCR_JQOM}}. An implementation of
87: * either level may also support other languages, including the deprecated
88: * languages of JCR 1.0: {@link Query#XPATH} and {@link Query#SQL}.
89: *
90: * @return A string array.
91: * @throws RepositoryException if an error occurs.
92: */
93: public String[] getSupportedQueryLanguages()
94: throws RepositoryException;
95: }
|