capture
[rrq/gorite.git] / com / intendico / data / QueryBase.java
1 /*********************************************************************
2 Copyright 2012, Ralph Ronnquist.
3
4 This file is part of GORITE.
5
6 GORITE is free software: you can redistribute it and/or modify it
7 under the terms of the Lesser GNU General Public License as published
8 by the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 GORITE is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14 License for more details.
15
16 You should have received a copy of the Lesser GNU General Public
17 License along with GORITE.  If not, see <http://www.gnu.org/licenses/>.
18 **********************************************************************/
19
20 package com.intendico.data;
21
22 import java.util.Observer;
23 import java.util.Vector;
24
25 /**
26  * The QueryBase class is a wrapper class that provides transparent
27  * implementations for the {@link Query} methods. It is intended to be
28  * base class for simple query implementations that only need to
29  * override one or a few of the implementations, typically the
30  * constructor.
31  */
32 public class QueryBase implements Query {
33
34     /**
35      * Holds a/the sub query wrapped by this QueryBase.
36      */
37     public Query query;
38
39     /**
40      * Constructor;
41      */
42     public QueryBase() {
43     }
44
45     /**
46      * Constructor;
47      */
48     public QueryBase(Query q) {
49         query = q;
50     }
51
52     /**
53      * The {@link Query#copy} method implemented by returning this
54      * same query.
55      */
56     public Query copy(Vector/*<Ref>*/ newrefs) throws Exception {
57         return this;
58     }
59
60     /**
61      * The {@link Query#reset} method implemented by forwarding to the
62      * wrapped query.
63      */
64     public void reset() throws Exception {
65         query.reset();
66     }
67
68     /**
69      * The {@link Query#next} method implemented by forwarding to the
70      * wrapped query.
71      */
72     public boolean next() throws Exception {
73         return query.next();
74     }
75
76     /**
77      * The {@link Query#getRefs} method implemented by forwarding to the
78      * wrapped query.
79      */
80     public Vector/*<Ref>*/ getRefs(Vector/*<Ref>*/ v) {
81         return query.getRefs( v );
82     }
83
84     /**
85      * The {@link Query#addObserver} method implemented by forwarding
86      * to the wrapped query.
87      */
88     public void addObserver(Observer x) {
89         query.addObserver( x );
90     }
91
92     /**
93      * The {@link Query#deleteObserver} method implemented by
94      * forwarding to the wrapped query.
95      */
96     public void deleteObserver(Observer x) {
97         query.deleteObserver( x );
98     }
99
100     /**
101      * The {@link Query#addable} method implemented by forwarding to
102      * the wrapped query.
103      */
104     public boolean addable() {
105         return query.addable();
106     }
107
108     /**
109      * The {@link Query#add} method implemented by forwarding to the
110      * wrapped query.
111      */
112     public boolean add() {
113         return query.add();
114     }
115
116     /**
117      * The {@link Query#removable} method implemented by forwarding to
118      * the wrapped query.
119      */
120     public boolean removable() {
121         return query.removable();
122     }
123
124     /**
125      * The {@link Query#remove} method implemented by forwarding to
126      * the wrapped query.
127      */
128     public boolean remove() {
129         return query.remove();
130     }
131
132     /**
133      * Returns the textual representation of the wrapped query, within
134      * parentheses.
135      */
136     public String toString() {
137         return "(" + query + ")";
138     }
139 }