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
/* 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
*
6
* 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
*
11
* 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
*
16
* 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
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
* MA  02110-1301, USA.
20
*
21
*/
22

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2008 {DiSiD Technologies}  {Create Parameter object to define FeatureCollections queries}
26
 */
27
package org.gvsig.fmap.dal.feature;
28

    
29
import org.gvsig.fmap.dal.DataQuery;
30
import org.gvsig.tools.evaluator.Evaluator;
31

    
32
/**
33
 * Defines the properties of a collection of Features, as a result of a query
34
 * through a FeatureStore.
35
 * <p>
36
 * A FeatureQuery is always defined by a FeatureType, or by the list of
37
 * attribute names of the FeatureStore to return.
38
 * </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
 *
60
 * @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a>
61
 */
62
public class FeatureQuery extends DataQuery {
63

    
64
    private FeatureType featureType;
65

    
66
    private String[] attributeNames;
67

    
68
    private Evaluator filter;
69

    
70
    private FeatureQueryOrder order = new FeatureQueryOrder();
71

    
72
    /**
73
     * Creates a FeatureQuery which will load all available Features of a type.
74
     *
75
     * @param featureType
76
     *            the type of Features of the query
77
     */
78
    public FeatureQuery() {
79
        super();
80
    }
81

    
82
        /**
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
    /**
94
     * Creates a FeatureQuery with the type of features, a filter and the order
95
     * for the FeatureCollection.
96
     *
97
     * @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
    public FeatureQuery(FeatureType featureType, Evaluator filter) {
105
        super();
106
        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
     *
114
     * @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
    public FeatureQuery(FeatureType featureType, Evaluator filter,
124
            double scale) {
125
        super(scale);
126
        this.featureType = featureType;
127
        this.filter = filter;
128
    }
129

    
130
        /**
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
        super();
139
        this.attributeNames = attributeNames;
140
    }
141

    
142
        /**
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
        super();
155
        this.attributeNames = attributeNames;
156
        this.filter = filter;
157
    }
158

    
159
        /**
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
            double scale) {
174
        super(scale);
175
        this.attributeNames = attributeNames;
176
        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
        /**
195
         * @return the attribute names
196
         */
197
    public String[] getAttributeNames() {
198
                return attributeNames;
199
    }
200

    
201
        /**
202
         * @param attributeNames
203
         *            the attribute names to set
204
         */
205
    public void setAttributeNames(String[] attributeNames) {
206
                this.attributeNames = attributeNames;
207
    }
208

    
209
    /**
210
     * @return the filter
211
     */
212
    public Evaluator getFilter() {
213
        return filter;
214
    }
215

    
216
    /**
217
     * @param filter
218
     *            the filter to set
219
     */
220
    public void setFilter(Evaluator filter) {
221
        this.filter = filter;
222
    }
223

    
224
    /**
225
     * @return the order
226
     */
227
    public FeatureQueryOrder getOrder() {
228
        return order;
229
    }
230

    
231
        public boolean hasFilter() {
232
                return this.filter != null;
233
        }
234

    
235
        public boolean hasOrder() {
236
                return this.order.size() > 0;
237
        }
238

    
239
}