KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > jcr > query > QueryImpl


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.jcr.query;
18
19 import javax.jcr.ItemExistsException;
20 import javax.jcr.ItemNotFoundException;
21 import javax.jcr.Node;
22 import javax.jcr.PathNotFoundException;
23 import javax.jcr.RepositoryException;
24 import javax.jcr.UnsupportedRepositoryOperationException;
25 import javax.jcr.lock.LockException;
26 import javax.jcr.nodetype.ConstraintViolationException;
27 import javax.jcr.query.InvalidQueryException;
28 import javax.jcr.query.Query;
29 import javax.jcr.version.VersionException;
30
31 import org.alfresco.jcr.session.SessionImpl;
32 import org.alfresco.jcr.util.JCRProxyFactory;
33
34
35 /**
36  * Alfresco implementation of JCR Query
37  *
38  * @author David Caruana
39  */

40 public abstract class QueryImpl implements Query
41 {
42     /** Session */
43     private SessionImpl session;
44
45     /** Query Statement */
46     private String JavaDoc statement;
47     
48     /** Proxy */
49     private Query proxy = null;
50     
51     
52     /**
53      * Construct
54      *
55      * @param statement query language
56      */

57     public QueryImpl(SessionImpl session, String JavaDoc statement)
58     {
59         this.session = session;
60         this.statement = statement;
61     }
62
63     /**
64      * Get proxied JCR Query
65      *
66      * @return proxy
67      */

68     public Query getProxy()
69     {
70         if (proxy == null)
71         {
72             proxy = (Query)JCRProxyFactory.create(this, Query.class, session);
73         }
74         return proxy;
75     }
76     
77     /**
78      * Get Session
79      *
80      * @return session
81      */

82     public SessionImpl getSession()
83     {
84         return session;
85     }
86     
87     /**
88      * Is the statement valid?
89      *
90      * @throws InvalidQueryException
91      */

92     public abstract void isValidStatement() throws InvalidQueryException;
93     
94     /* (non-Javadoc)
95      * @see javax.jcr.query.Query#getStatement()
96      */

97     public String JavaDoc getStatement()
98     {
99         return statement;
100     }
101
102     /* (non-Javadoc)
103      * @see javax.jcr.query.Query#getStoredQueryPath()
104      */

105     public String JavaDoc getStoredQueryPath() throws ItemNotFoundException, RepositoryException
106     {
107         throw new ItemNotFoundException("This query has not been saved to the Repository");
108     }
109
110     /* (non-Javadoc)
111      * @see javax.jcr.query.Query#storeAsNode(java.lang.String)
112      */

113     public Node storeAsNode(String JavaDoc absPath) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, UnsupportedRepositoryOperationException, RepositoryException
114     {
115         throw new UnsupportedRepositoryOperationException();
116     }
117
118 }
119
Popular Tags