Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.api / src / main / java / org / gvsig / fmap / dal / feature / FeatureType.java @ 44435

History | View | Annotate | Download (10.4 KB)

1 40559 jjdelcerro
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24 40435 jjdelcerro
package org.gvsig.fmap.dal.feature;
25
26 44262 jjdelcerro
import java.util.Comparator;
27 40435 jjdelcerro
import java.util.Iterator;
28
import java.util.List;
29 44262 jjdelcerro
import java.util.function.Predicate;
30
import org.apache.commons.lang3.StringUtils;
31 40435 jjdelcerro
32
import org.cresques.cts.IProjection;
33
34
import org.gvsig.fmap.geom.Geometry;
35 44262 jjdelcerro
import org.gvsig.tools.dataTypes.DataType;
36
import org.gvsig.tools.dataTypes.DataTypes;
37 40435 jjdelcerro
import org.gvsig.tools.dynobject.DynClass;
38 44253 jjdelcerro
import org.gvsig.tools.dynobject.DynStruct_v2;
39 40435 jjdelcerro
import org.gvsig.tools.evaluator.Evaluator;
40 44149 jjdelcerro
import org.gvsig.tools.util.UnmodifiableBasicList;
41 40435 jjdelcerro
42
/**
43
 * <p>
44 44262 jjdelcerro
 * This interface provides all the information that describes the structure of a
45
 * type of feature, methods for managing it and also offers a variety of utility
46 40435 jjdelcerro
 * methods for simplicity's sake.
47
 * </p>
48
 *
49
 * <p>
50
 * The relevant information that compounds a FeatureType includes:
51
 * </p>
52
 *
53 44262 jjdelcerro
 * <ul>
54
 * <li> {@link FeatureAttributeDescriptor}(s)
55
 * <li> {@link FeatureRule}(s)
56
 * <li> Its size
57
 * <li> Its SRS(s)
58
 * <li> Its identifier
59
 * <li> Whether features of this type have an OID or not (identifier assigned by
60
 * the store).
61 40435 jjdelcerro
 * </ul>
62
 *
63
 * <p>
64
 * Methods for management include:
65
 * </p>
66
 *
67 44262 jjdelcerro
 * <ul>
68
 * <li>Obtaining its editable instance.
69
 * <li>Obtaining an iterator over its attributes.
70
 * <li>Knowing whether this FeatureType has any associated evaluator for
71
 * calculated attributes.
72
 * </ul>
73 40435 jjdelcerro
 *
74
 * <p>
75
 * Utility methods include:
76
 * </p>
77
 *
78
 * <ul>
79
 * <li>Getting a copy of the FeatureType.
80
 * <li>Getting the default geometry attribute.
81
 * <li>Getting the default spatial reference system.
82 44077 jjdelcerro
 * </ul>
83 40435 jjdelcerro
 */
84 44253 jjdelcerro
public interface FeatureType extends DynClass, DynStruct_v2, UnmodifiableBasicList<FeatureAttributeDescriptor> {
85 40435 jjdelcerro
86 44262 jjdelcerro
    public static final Predicate<FeatureAttributeDescriptor> BASIC_TYPES_FILTER = new Predicate<FeatureAttributeDescriptor>() {
87
        @Override
88
        public boolean test(FeatureAttributeDescriptor attrdesc) {
89
            DataType t = attrdesc.getDataType();
90
            boolean r = !(t.isContainer() || t.isDynObject() || t.isObject());
91
            return r;
92
        }
93
    };
94 40435 jjdelcerro
95 44262 jjdelcerro
    public static Predicate<FeatureAttributeDescriptor> ALL_FILTER = new Predicate<FeatureAttributeDescriptor>() {
96
        @Override
97
        public boolean test(FeatureAttributeDescriptor t) {
98
            return true;
99
        }
100
    };
101
    /**
102
     * Returns a new copy of this FeatureType
103
     *
104
     * @return a new copy of this FeatureType
105
     */
106
    public FeatureType getCopy();
107 40435 jjdelcerro
108 44318 jjdelcerro
    public void copyFrom(FeatureType other);
109
110 44262 jjdelcerro
    /**
111
     * Returns a {@link FeatureRules} containing all rules applicable to
112
     * features of this type.
113
     *
114
     * @return a {@link FeatureRules} containing all rules applicable to
115
     * features of this type.
116
     */
117
    public FeatureRules getRules();
118 40435 jjdelcerro
119 44262 jjdelcerro
    /**
120
     * Returns an editable instance of this FeatureType. Any modifications on a
121
     * FeatureType must be done through its editable instance.
122
     *
123
     * @return the editable instance of this FeatureType.
124
     *
125
     * @see EditableFeatureType
126
     */
127
    public EditableFeatureType getEditable();
128 40435 jjdelcerro
129 44262 jjdelcerro
    /**
130
     * Given the name of an attribute, this method returns its position in this
131
     * FeatureType.
132
     *
133
     * @param name of the attribute
134
     * @return position of the attribute
135
     */
136
    public int getIndex(String name);
137 40435 jjdelcerro
138 44262 jjdelcerro
    /**
139
     * Returns an attribute descriptor given its name.
140
     *
141
     * @param name of the attribute
142
     * @return descriptor of the attribute, a
143
     * {@link FeatureAttributeDescriptor}.
144
     */
145
    public Object get(String name);
146 40435 jjdelcerro
147 44262 jjdelcerro
    /**
148
     * Returns an attribute descriptor given its index
149
     *
150
     * @param index of the attribute
151
     *
152
     * @return descriptor of the attribute, a {@link FeatureAttributeDescriptor}
153
     */
154
    public FeatureAttributeDescriptor get(int index);
155 40435 jjdelcerro
156 44262 jjdelcerro
    /**
157
     * Returns a {@link FeatureAttributeDescriptor} given the attribute name, or
158
     * null if an attribute with the given name does not exist.
159
     *
160
     * @param name of the attribute
161
     *
162
     * @return a {@link FeatureAttributeDescriptor}
163
     */
164
    public FeatureAttributeDescriptor getAttributeDescriptor(String name);
165 40435 jjdelcerro
166 44262 jjdelcerro
    /**
167
     * Returns a {@link FeatureAttributeDescriptor} given the attribute index.
168
     *
169
     * @param index of the attribute
170
     *
171
     * @return a {@link FeatureAttributeDescriptor}
172
     */
173
    public FeatureAttributeDescriptor getAttributeDescriptor(int index);
174 40435 jjdelcerro
175 44262 jjdelcerro
    /**
176
     * Returns an iterator over this FeatureType's attributes. Elements returned
177
     * by this iterator are of type {@link FeatureAttributeDescriptor}.
178
     *
179
     * @return An iterator over this FeatureType's
180
     * {@link FeatureAttributeDescriptor}s.
181
     */
182
    public Iterator iterator();
183 40435 jjdelcerro
184 44262 jjdelcerro
    /**
185
     * Returns this FeatureType size. The size of a FeatureType is determined by
186
     * its number of attributes.
187
     *
188
     * @return this FeatureType size, defined as the number of attributes it is
189
     * composed of.
190
     *
191
     */
192
    public int size();
193 40435 jjdelcerro
194 44262 jjdelcerro
    public boolean isEmpty();
195 40435 jjdelcerro
196 44262 jjdelcerro
    /**
197
     * Returns this FeatureType identifier. This identifier must always be equal
198
     * to a store.
199
     *
200
     * @return the identifier.
201
     */
202
    public String getId();
203 40435 jjdelcerro
204 44262 jjdelcerro
    /**
205
     * Returns the name of the attribute that will be used as default geometry
206
     * attribute for those processes that require a geometry (for instance
207
     * rendering).
208
     *
209
     * @return name of the default geometry attribute.
210
     */
211
    public String getDefaultGeometryAttributeName();
212 40435 jjdelcerro
213 44262 jjdelcerro
    /**
214
     * Returns the index of the attribute that will be used as default geometry
215
     * attribute.
216
     *
217
     * @return index of the default geometry attribute.
218
     */
219
    public int getDefaultGeometryAttributeIndex();
220 40435 jjdelcerro
221 44262 jjdelcerro
    /**
222
     * Returns a list with the SRSs in which this FeatureType geometries are
223
     * expressed. Normally there may be one SRS for each attribute of type
224
     * {@link Geometry}.
225
     *
226
     * @return a list with the SRS in which this FeatureType geometries are
227
     * expressed.
228
     */
229
    public List getSRSs();
230 40435 jjdelcerro
231 44262 jjdelcerro
    /**
232
     * Returns the SRS in which the default geometry attribute is expressed.
233
     *
234
     * @return the SRS in which the default geometry attribute is expressed,
235
     * null if not has a default geometry attribute.
236
     */
237
    public IProjection getDefaultSRS();
238 40435 jjdelcerro
239 44262 jjdelcerro
    /**
240
     * Indicates whether this FeatureType has any assigned {@link Evaluator}(s).
241
     * Evaluators are used to obtain the values for calculated attributes.
242
     *
243
     * @return true if this FeatureType has any assigned {@link Evaluator}(s).
244
     */
245
    public boolean hasEvaluators(); // FIXME: Quitar del interface y dejar en DefaultFeatureType
246 40435 jjdelcerro
247 44262 jjdelcerro
    /**
248
     * Indicates whether {@link Feature}(s) of this FeatureType have an OID
249
     * defined. An OID is the Feature unique identifier.
250
     *
251
     * Some stores provide their own OIDs which are always unique (such as
252
     * Postgre) while others don't support this concept and then it is the
253
     * library who creates runtime ad-hoc OIDs as it see fits, but then
254
     * integrity of this OIDs among different work sessions cannot be guaranteed
255
     * (this is the case for shape files).
256
     *
257
     * @return true if this FeatureType has an OID defined, false otherwise.
258
     *
259
     */
260
    public boolean hasOID();
261 40435 jjdelcerro
262 44262 jjdelcerro
    /**
263
     * Incicates if attibutes with automatic values are allowed in the source
264
     *
265
     * @return true if source supports this feature, false otherwise
266
     */
267
    public boolean allowAutomaticValues();
268 40435 jjdelcerro
269 44262 jjdelcerro
    /**
270
     * Returns an Array of the FeatureAttributeDescriptor
271 40435 jjdelcerro
     *
272
     * @return
273
     */
274 44262 jjdelcerro
    public FeatureAttributeDescriptor[] getAttributeDescriptors();
275 40435 jjdelcerro
276 43739 jjdelcerro
    /**
277 44262 jjdelcerro
     * Returns an Array of the FeatureAttributeDescriptor that compounds the
278
     * primary key. If not have primary keys return a empty array.
279 44077 jjdelcerro
     *
280
     * @return
281
     */
282 44262 jjdelcerro
    public FeatureAttributeDescriptor[] getPrimaryKey();
283 44077 jjdelcerro
284 44435 jjdelcerro
    public boolean hasPrimaryKey();
285
286
    public boolean supportReferences();
287
288 44077 jjdelcerro
    /**
289 44262 jjdelcerro
     * Returns the default geometry FeatureAttributeDescriptor. Return null if
290
     * it's not set
291 44077 jjdelcerro
     *
292
     * @return
293
     */
294 44262 jjdelcerro
    public FeatureAttributeDescriptor getDefaultGeometryAttribute();
295
296
    /**
297
     * Returns the default time FeatureAttributeDescriptor. Return null if it's
298
     * not set.
299
     *
300
     * @return the default time attribute
301
     */
302
    public FeatureAttributeDescriptor getDefaultTimeAttribute();
303
304
    /**
305
     * Returns the name of the attribute that will be used as default geometry
306
     * attribute for those processes that require a geometry (for instance
307
     * rendering).
308
     *
309
     * @return name of the default geometry attribute.
310
     */
311
    public String getDefaultTimeAttributeName();
312
313
    /**
314
     * Returns the index of the attribute that will be used as default geometry
315
     * attribute.
316
     *
317
     * @return index of the default geometry attribute.
318
     */
319 44077 jjdelcerro
    public int getDefaultTimeAttributeIndex();
320
321
    /**
322 43739 jjdelcerro
     * Return the store associated to this type.
323 44262 jjdelcerro
     *
324 43739 jjdelcerro
     * @return the FeatureStore of the type.
325
     */
326 44262 jjdelcerro
    public FeatureStore getStore();
327 40435 jjdelcerro
328 44262 jjdelcerro
    public List<FeatureAttributeDescriptor> getFilteredAttributes(
329
            Predicate<FeatureAttributeDescriptor> filter,
330
            int max
331
    );
332
333
    public List<FeatureAttributeDescriptor> getRecentUseds();
334
335 40435 jjdelcerro
}