Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / feature / FeatureQuery.java @ 24496

History | View | Annotate | Download (6.58 KB)

1 23380 cordinyana
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Gobernment (CIT)
5 23754 jjdelcerro
*
6 23380 cordinyana
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10 23754 jjdelcerro
*
11 23380 cordinyana
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15 23754 jjdelcerro
*
16 23380 cordinyana
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18 23754 jjdelcerro
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 23380 cordinyana
* MA  02110-1301, USA.
20 23754 jjdelcerro
*
21 23380 cordinyana
*/
22
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2008 {DiSiD Technologies}  {Create Parameter object to define FeatureCollections queries}
26
 */
27 24496 jmvivo
package org.gvsig.fmap.dal.feature;
28 23380 cordinyana
29 24496 jmvivo
import org.gvsig.fmap.dal.DataQuery;
30 23754 jjdelcerro
import org.gvsig.tools.evaluator.Evaluator;
31 23380 cordinyana
32
/**
33
 * Defines the properties of a collection of Features, as a result of a query
34
 * through a FeatureStore.
35
 * <p>
36 23754 jjdelcerro
 * A FeatureQuery is always defined by a FeatureType, or by the list of
37
 * attribute names of the FeatureStore to return.
38 23380 cordinyana
 * </p>
39
 * <p>
40
 * The filter allows to select Features whose properties have values with the
41
 * characteristics defined by the filter.
42
 * </p>
43
 * <p>
44
 * The order is used to set the order of the result FeatureCollection, based on
45
 * the values of the properties of the Features.
46
 * </p>
47
 * <p>
48
 * The scala parameter can be used by the FeatureStore as a hint about the
49
 * quality or resolution of the data needed to view or operate with the data
50
 * returned. As an example, the FeatureStore may use the scala to return only a
51
 * representative subset of the data, or maybe to return Features with less
52
 * detail, like a point or a line instead of a polygon.
53
 * </p>
54
 * <p>
55
 * If an implementation of FeatureStore is able to get other parameters to
56
 * customize the behavior of the getDataCollection methods, there is an option
57
 * to set more parameters through the setAttribute method.
58
 * </p>
59 23754 jjdelcerro
 *
60 23380 cordinyana
 * @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a>
61
 */
62 23457 cordinyana
public class FeatureQuery extends DataQuery {
63 23754 jjdelcerro
64 23380 cordinyana
    private FeatureType featureType;
65
66 23754 jjdelcerro
    private String[] attributeNames;
67 23380 cordinyana
68 23754 jjdelcerro
    private Evaluator filter;
69 23380 cordinyana
70 23754 jjdelcerro
    private FeatureQueryOrder order = new FeatureQueryOrder();
71
72 23380 cordinyana
    /**
73
     * Creates a FeatureQuery which will load all available Features of a type.
74 23754 jjdelcerro
     *
75 23380 cordinyana
     * @param featureType
76
     *            the type of Features of the query
77
     */
78 24245 jjdelcerro
    public FeatureQuery() {
79 23457 cordinyana
        super();
80 23380 cordinyana
    }
81
82 24245 jjdelcerro
        /**
83
         * Creates a FeatureQuery which will load all available Features of a type.
84
         *
85
         * @param featureType
86
         *            the type of Features of the query
87
         */
88
   public FeatureQuery(FeatureType featureType) {
89
       super();
90
       this.featureType = featureType;
91
   }
92
93 23380 cordinyana
    /**
94
     * Creates a FeatureQuery with the type of features, a filter and the order
95
     * for the FeatureCollection.
96 23754 jjdelcerro
     *
97 23380 cordinyana
     * @param featureType
98
     *            the type of Features of the query
99
     * @param filter
100
     *            based on the properties of the Features
101
     * @param order
102
     *            for the result
103
     */
104 23754 jjdelcerro
    public FeatureQuery(FeatureType featureType, Evaluator filter) {
105 23457 cordinyana
        super();
106 23380 cordinyana
        this.featureType = featureType;
107
        this.filter = filter;
108
    }
109
110
    /**
111
     * Creates a FeatureQuery with the type of features, a filter, the order for
112
     * the FeatureCollection and the view scale.
113 23754 jjdelcerro
     *
114 23380 cordinyana
     * @param featureType
115
     *            the type of Features of the query
116
     * @param filter
117
     *            based on the properties of the Features
118
     * @param order
119
     *            for the result
120
     * @param scale
121
     *            to view the Features.
122
     */
123 23754 jjdelcerro
    public FeatureQuery(FeatureType featureType, Evaluator filter,
124 23380 cordinyana
            double scale) {
125 23457 cordinyana
        super(scale);
126 23380 cordinyana
        this.featureType = featureType;
127
        this.filter = filter;
128
    }
129
130 23754 jjdelcerro
        /**
131
         * Creates a FeatureQuery which will load a list of attribute names of all
132
         * available Features.
133
         *
134
         * @param attributeNames
135
         *            the list of attribute names to load
136
         */
137
    public FeatureQuery(String[] attributeNames) {
138 23457 cordinyana
        super();
139 23754 jjdelcerro
        this.attributeNames = attributeNames;
140 23380 cordinyana
    }
141
142 23754 jjdelcerro
        /**
143
         * Creates a FeatureQuery with the list of attribute names of feature, a
144
         * filter and the order for the FeatureCollection.
145
         *
146
         * @param attributeNames
147
         *            the list of attribute names to load
148
         * @param filter
149
         *            based on the properties of the Features
150
         * @param order
151
         *            for the result
152
         */
153
    public FeatureQuery(String[] attributeNames, Evaluator filter) {
154 23457 cordinyana
        super();
155 23754 jjdelcerro
        this.attributeNames = attributeNames;
156 23380 cordinyana
        this.filter = filter;
157
    }
158
159 23754 jjdelcerro
        /**
160
         * Creates a FeatureQuery with the list of attribute names of feature, a
161
         * filter, the order for the FeatureCollection and the view scale.
162
         *
163
         * @param attributeNames
164
         *            the list of attribute names to load
165
         * @param filter
166
         *            based on the properties of the Features
167
         * @param order
168
         *            for the result
169
         * @param scale
170
         *            to view the Features.
171
         */
172
    public FeatureQuery(String[] attributeNames, Evaluator filter,
173 23380 cordinyana
            double scale) {
174 23457 cordinyana
        super(scale);
175 23754 jjdelcerro
        this.attributeNames = attributeNames;
176 23380 cordinyana
        this.filter = filter;
177
    }
178
179
    /**
180
     * @return the featureType
181
     */
182
    public FeatureType getFeatureType() {
183
        return featureType;
184
    }
185
186
    /**
187
     * @param featureType
188
     *            the featureType to set
189
     */
190
    public void setFeatureType(FeatureType featureType) {
191
        this.featureType = featureType;
192
    }
193
194 23754 jjdelcerro
        /**
195
         * @return the attribute names
196
         */
197
    public String[] getAttributeNames() {
198
                return attributeNames;
199 23380 cordinyana
    }
200
201 23754 jjdelcerro
        /**
202
         * @param attributeNames
203
         *            the attribute names to set
204
         */
205
    public void setAttributeNames(String[] attributeNames) {
206
                this.attributeNames = attributeNames;
207 23380 cordinyana
    }
208
209
    /**
210
     * @return the filter
211
     */
212 23754 jjdelcerro
    public Evaluator getFilter() {
213 23380 cordinyana
        return filter;
214
    }
215
216
    /**
217
     * @param filter
218
     *            the filter to set
219
     */
220 23754 jjdelcerro
    public void setFilter(Evaluator filter) {
221 23380 cordinyana
        this.filter = filter;
222
    }
223
224
    /**
225
     * @return the order
226
     */
227 23754 jjdelcerro
    public FeatureQueryOrder getOrder() {
228 23380 cordinyana
        return order;
229
    }
230
231 23820 jjdelcerro
        public boolean hasFilter() {
232
                return this.filter != null;
233
        }
234
235
        public boolean hasOrder() {
236
                return this.order.size() > 0;
237
        }
238
239 23380 cordinyana
}