KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > store > impl > rdbms > expression > RDBMSResultSet


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/expression/RDBMSResultSet.java,v 1.3 2004/07/28 09:34:08 ib Exp $
3  * $Revision: 1.3 $
4  * $Date: 2004/07/28 09:34:08 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2004 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23 package org.apache.slide.store.impl.rdbms.expression;
24
25 import java.util.Collection JavaDoc;
26 import java.util.HashSet JavaDoc;
27 import java.util.Iterator JavaDoc;
28
29 import org.apache.slide.common.SlideRuntimeException;
30 import org.apache.slide.search.BadQueryException;
31 import org.apache.slide.search.basic.IBasicResultSet;
32
33 /**
34  */

35 public class RDBMSResultSet extends HashSet JavaDoc implements IBasicResultSet {
36
37     private boolean _initialized;
38     private final RDBMSExpressionFactory _factory;
39
40     public RDBMSResultSet(RDBMSExpressionFactory factory) {
41         _factory = factory;
42     }
43
44     private void initialize() {
45         try {
46             super.addAll(_factory.getRequestedResourcePool().getPool());
47         }
48         catch (BadQueryException e) {
49             throw new SlideRuntimeException(e.toString(), true);
50         }
51         _initialized = true;
52     }
53     
54     public boolean isPartialResultSet() {
55         return _factory.getRequestedResourcePool().partialResult();
56     }
57
58     public void clear() {
59         if (!_initialized) {
60             _initialized = true;
61         }
62         super.clear();
63     }
64
65     public boolean contains(Object JavaDoc arg0) {
66         if (!_initialized) {
67             initialize();
68         }
69         return super.contains(arg0);
70     }
71
72     public boolean isEmpty() {
73         if (!_initialized) {
74             initialize();
75         }
76         return super.isEmpty();
77     }
78
79     public Iterator JavaDoc iterator() {
80         if (!_initialized) {
81             initialize();
82         }
83         return super.iterator();
84     }
85
86     public boolean remove(Object JavaDoc arg0) {
87         if (!_initialized) {
88             initialize();
89         }
90         return super.remove(arg0);
91     }
92     
93     public int size() {
94         if (!_initialized) {
95             initialize();
96         }
97         return super.size();
98     }
99     
100     public boolean removeAll(Collection JavaDoc arg0) {
101         if (!_initialized) {
102             initialize();
103         }
104         return super.removeAll(arg0);
105     }
106     
107     public boolean containsAll(Collection JavaDoc arg0) {
108         if (!_initialized) {
109             initialize();
110         }
111         return super.containsAll(arg0);
112     }
113
114     public boolean retainAll(Collection JavaDoc arg0) {
115         if (!_initialized) {
116             initialize();
117         }
118         return super.retainAll(arg0);
119     }
120
121     public Object JavaDoc[] toArray() {
122         if (!_initialized) {
123             initialize();
124         }
125         return super.toArray();
126     }
127
128     public Object JavaDoc[] toArray(Object JavaDoc[] arg0) {
129         if (!_initialized) {
130             initialize();
131         }
132         return super.toArray(arg0);
133     }
134
135 }
Popular Tags