KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > remote > RangeQuery


1 /*****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  ****************************************************************/

19
20 package org.apache.cayenne.remote;
21
22 import org.apache.cayenne.map.DataMap;
23 import org.apache.cayenne.map.DbEntity;
24 import org.apache.cayenne.map.EntityResolver;
25 import org.apache.cayenne.map.ObjEntity;
26 import org.apache.cayenne.map.Procedure;
27 import org.apache.cayenne.query.PrefetchTreeNode;
28 import org.apache.cayenne.query.Query;
29 import org.apache.cayenne.query.QueryMetadata;
30 import org.apache.cayenne.query.QueryRouter;
31 import org.apache.cayenne.query.SQLAction;
32 import org.apache.cayenne.query.SQLActionVisitor;
33 import org.apache.cayenne.query.SQLResultSetMapping;
34 import org.apache.cayenne.reflect.ClassDescriptor;
35
36 /**
37  * An Query wrapper that triggers pagination processing on the server. This query is
38  * client-only and can't be executed on the server.
39  *
40  * @since 1.2
41  * @author Andrus Adamchik
42  */

43 class RangeQuery implements Query {
44
45     private String JavaDoc cacheKey;
46     private int fetchStartIndex;
47     private int fetchLimit;
48     private boolean fetchingDataRows;
49     private PrefetchTreeNode prefetchTree;
50
51     // exists for hessian serialization.
52
private RangeQuery() {
53
54     }
55
56     /**
57      * Creates a PaginatedQuery that returns a single page from an existing cached
58      * server-side result list.
59      */

60     public RangeQuery(String JavaDoc cacheKey, int fetchStartIndex, int fetchLimit,
61             QueryMetadata rootMetadata) {
62         this.cacheKey = cacheKey;
63         this.fetchStartIndex = fetchStartIndex;
64         this.fetchLimit = fetchLimit;
65         this.fetchingDataRows = rootMetadata.isFetchingDataRows();
66         this.prefetchTree = rootMetadata.getPrefetchTree();
67     }
68
69     public QueryMetadata getMetaData(EntityResolver resolver) {
70         return new QueryMetadata() {
71             
72             public SQLResultSetMapping getResultSetMapping() {
73                 return null;
74             }
75
76             public String JavaDoc getCacheKey() {
77                 return cacheKey;
78             }
79
80             public String JavaDoc[] getCacheGroups() {
81                 return null;
82             }
83
84             public int getFetchStartIndex() {
85                 return fetchStartIndex;
86             }
87
88             public int getFetchLimit() {
89                 return fetchLimit;
90             }
91
92             public boolean isFetchingDataRows() {
93                 return fetchingDataRows;
94             }
95
96             public int getPageSize() {
97                 return 0;
98             }
99
100             public String JavaDoc getCachePolicy() {
101                 return QueryMetadata.NO_CACHE;
102             }
103
104             public PrefetchTreeNode getPrefetchTree() {
105                 return prefetchTree;
106             }
107
108             public DataMap getDataMap() {
109                 throw new UnsupportedOperationException JavaDoc();
110             }
111
112             public DbEntity getDbEntity() {
113                 throw new UnsupportedOperationException JavaDoc();
114             }
115
116             public ObjEntity getObjEntity() {
117                 throw new UnsupportedOperationException JavaDoc();
118             }
119
120             public ClassDescriptor getClassDescriptor() {
121                 throw new UnsupportedOperationException JavaDoc();
122             }
123
124             public Procedure getProcedure() {
125                 throw new UnsupportedOperationException JavaDoc();
126             }
127
128             public boolean isRefreshingObjects() {
129                 throw new UnsupportedOperationException JavaDoc();
130             }
131
132             public boolean isResolvingInherited() {
133                 throw new UnsupportedOperationException JavaDoc();
134             }
135         };
136     }
137
138     public SQLAction createSQLAction(SQLActionVisitor visitor) {
139         throw new UnsupportedOperationException JavaDoc();
140     }
141
142     public String JavaDoc getName() {
143         throw new UnsupportedOperationException JavaDoc();
144     }
145
146     public void route(QueryRouter router, EntityResolver resolver, Query substitutedQuery) {
147         throw new UnsupportedOperationException JavaDoc();
148     }
149 }
150
Popular Tags