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