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