svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.impl / src / main / java / org / gvsig / fmap / dal / feature / impl / DefaultFeature.java @ 45647
History | View | Annotate | Download (45.3 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.impl; |
25 | |||
26 | import java.lang.ref.WeakReference; |
||
27 | 44669 | jjdelcerro | import java.math.BigDecimal; |
28 | 45023 | fdiaz | import java.time.LocalDateTime; |
29 | import java.time.ZoneId; |
||
30 | 44655 | jjdelcerro | import java.time.format.DateTimeFormatter; |
31 | 43550 | jjdelcerro | import java.util.ArrayList; |
32 | 40435 | jjdelcerro | import java.util.Date; |
33 | 44858 | jjdelcerro | import java.util.HashMap; |
34 | 40435 | jjdelcerro | import java.util.Iterator; |
35 | import java.util.List; |
||
36 | 43550 | jjdelcerro | import java.util.Map; |
37 | 44655 | jjdelcerro | import java.util.Objects; |
38 | import javax.json.JsonObject; |
||
39 | 44779 | omartinez | import org.apache.commons.lang3.ArrayUtils; |
40 | 44128 | jjdelcerro | import org.apache.commons.lang3.StringUtils; |
41 | 40435 | jjdelcerro | import org.cresques.cts.IProjection; |
42 | 44818 | jjdelcerro | import org.gvsig.expressionevaluator.ExpressionUtils; |
43 | 44128 | jjdelcerro | import org.gvsig.fmap.dal.DALLocator; |
44 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.DataTypes; |
45 | import org.gvsig.fmap.dal.exception.DataEvaluatorRuntimeException; |
||
46 | import org.gvsig.fmap.dal.exception.DataException; |
||
47 | 44128 | jjdelcerro | import org.gvsig.fmap.dal.feature.DataProfile; |
48 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.feature.EditableFeature; |
49 | 44773 | jjdelcerro | import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
50 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.feature.Feature; |
51 | import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
||
52 | 41335 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureAttributeEmulator; |
53 | import org.gvsig.fmap.dal.feature.FeatureAttributeGetter; |
||
54 | 45581 | fdiaz | import org.gvsig.fmap.dal.feature.FeatureExtraColumns; |
55 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureReference; |
56 | import org.gvsig.fmap.dal.feature.FeatureStore; |
||
57 | import org.gvsig.fmap.dal.feature.FeatureType; |
||
58 | import org.gvsig.fmap.dal.feature.exception.IllegalValueException; |
||
59 | import org.gvsig.fmap.dal.feature.exception.SetReadOnlyAttributeException; |
||
60 | 42775 | jjdelcerro | import org.gvsig.fmap.dal.feature.impl.dynobjectutils.DynObjectFeatureFacade; |
61 | 45647 | fdiaz | import org.gvsig.fmap.dal.feature.impl.featurereference.FeatureReferenceFactory; |
62 | 43729 | fdiaz | import org.gvsig.fmap.dal.feature.spi.DefaultFeatureProvider; |
63 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
64 | import org.gvsig.fmap.geom.Geometry; |
||
65 | import org.gvsig.fmap.geom.primitive.Envelope; |
||
66 | 45581 | fdiaz | import org.gvsig.json.Json; |
67 | import org.gvsig.json.JsonObjectBuilder; |
||
68 | 40435 | jjdelcerro | import org.gvsig.tools.ToolsLocator; |
69 | 44799 | jjdelcerro | import org.gvsig.tools.dataTypes.Coercion; |
70 | 40435 | jjdelcerro | import org.gvsig.tools.dataTypes.CoercionException; |
71 | 45581 | fdiaz | import org.gvsig.tools.dataTypes.DataType; |
72 | 40435 | jjdelcerro | import org.gvsig.tools.dataTypes.DataTypesManager; |
73 | 45581 | fdiaz | import org.gvsig.tools.dataTypes.impl.coercion.CoerceToString; |
74 | 40435 | jjdelcerro | import org.gvsig.tools.dynobject.DynObject; |
75 | import org.gvsig.tools.evaluator.Evaluator; |
||
76 | import org.gvsig.tools.evaluator.EvaluatorData; |
||
77 | import org.gvsig.tools.evaluator.EvaluatorException; |
||
78 | import org.gvsig.tools.exception.BaseException; |
||
79 | import org.gvsig.tools.exception.BaseRuntimeException; |
||
80 | 40876 | jjdelcerro | import org.gvsig.tools.lang.Cloneable; |
81 | 45581 | fdiaz | import org.slf4j.Logger; |
82 | import org.slf4j.LoggerFactory; |
||
83 | 40435 | jjdelcerro | |
84 | 44799 | jjdelcerro | @SuppressWarnings("UseSpecificCatch") |
85 | 40876 | jjdelcerro | public class DefaultFeature implements Feature, EvaluatorData, Cloneable { |
86 | 40435 | jjdelcerro | |
87 | 45581 | fdiaz | private static final Logger LOGGER = LoggerFactory.getLogger(DefaultFeature.class); |
88 | 43729 | fdiaz | |
89 | 45581 | fdiaz | private static DataTypesManager dataTypesManager = null; |
90 | protected FeatureProvider data;
|
||
91 | protected FeatureReference reference;
|
||
92 | private WeakReference storeRef; |
||
93 | 40435 | jjdelcerro | |
94 | 45581 | fdiaz | private boolean inserted = false; |
95 | private Object[] extraValuesData; |
||
96 | private Map<String, Object> extraValues; // not persistent |
||
97 | |||
98 | 40435 | jjdelcerro | /*
|
99 | * Usar con mucha precaucion o mejor no usar. Lo precisa el
|
||
100 | * DefaultFeatureSet en la ordenacion.
|
||
101 | 45581 | fdiaz | */
|
102 | public DefaultFeature(FeatureStore store) {
|
||
103 | this.storeRef = new WeakReference(store); |
||
104 | this.reference = null; |
||
105 | } |
||
106 | 40435 | jjdelcerro | |
107 | 45581 | fdiaz | public DefaultFeature(FeatureStore store, FeatureProvider data) {
|
108 | this.data = data;
|
||
109 | this.extraValuesData = null; |
||
110 | this.storeRef = new WeakReference(store); |
||
111 | this.reference = null; |
||
112 | this.inserted = !data.isNew();
|
||
113 | } |
||
114 | 40435 | jjdelcerro | |
115 | 45581 | fdiaz | DefaultFeature(DefaultFeature feature) { |
116 | this.data = feature.data.getCopy();
|
||
117 | this.extraValuesData = ArrayUtils.clone(feature.extraValuesData);
|
||
118 | this.storeRef = feature.storeRef;
|
||
119 | this.reference = feature.reference;
|
||
120 | this.inserted = feature.isInserted();
|
||
121 | } |
||
122 | 40435 | jjdelcerro | |
123 | 43729 | fdiaz | public DefaultFeature(FeatureType targetType, Feature sourceFeature) {
|
124 | 45581 | fdiaz | DefaultFeature defaultFeature = (DefaultFeature) sourceFeature; |
125 | this.data = new DefaultFeatureProvider(targetType, (DefaultFeatureProvider) defaultFeature.getData()); |
||
126 | 44779 | omartinez | this.extraValuesData = null; |
127 | 43729 | fdiaz | this.storeRef = defaultFeature.storeRef;
|
128 | this.reference = defaultFeature.reference;
|
||
129 | this.inserted = defaultFeature.isInserted();
|
||
130 | |||
131 | FeatureType sourceType = sourceFeature.getType(); |
||
132 | |||
133 | for (FeatureAttributeDescriptor targetAttrDescriptor : targetType) {
|
||
134 | 45581 | fdiaz | if (targetAttrDescriptor.isComputed()) {
|
135 | continue;
|
||
136 | 43729 | fdiaz | } |
137 | int sourceIndex = sourceType.getIndex(targetAttrDescriptor.getName());
|
||
138 | 45581 | fdiaz | if (sourceIndex < 0) { |
139 | 43729 | fdiaz | continue;
|
140 | } |
||
141 | Object value = sourceFeature.get(sourceIndex);
|
||
142 | if (value == null && !targetAttrDescriptor.allowNull()) { |
||
143 | continue;
|
||
144 | } |
||
145 | 45581 | fdiaz | this.setforced(targetAttrDescriptor.getIndex(), targetAttrDescriptor, value);
|
146 | 43729 | fdiaz | } |
147 | } |
||
148 | |||
149 | 45581 | fdiaz | public void setData(FeatureProvider data) { |
150 | this.data = data;
|
||
151 | this.extraValuesData = null; |
||
152 | this.reference = null; |
||
153 | this.inserted = true; |
||
154 | } |
||
155 | 40435 | jjdelcerro | |
156 | 45581 | fdiaz | public FeatureProvider getData() {
|
157 | return this.data; |
||
158 | } |
||
159 | 40435 | jjdelcerro | |
160 | 45581 | fdiaz | protected DataTypesManager getDataTypesManager() {
|
161 | if (dataTypesManager == null) { |
||
162 | dataTypesManager = ToolsLocator.getDataTypesManager(); |
||
163 | } |
||
164 | return dataTypesManager;
|
||
165 | } |
||
166 | 40435 | jjdelcerro | |
167 | 44641 | jjdelcerro | protected void set(FeatureAttributeDescriptor attribute, Object value) { |
168 | 41335 | jjdelcerro | int i = attribute.getIndex();
|
169 | 40435 | jjdelcerro | |
170 | 45581 | fdiaz | if (attribute.isReadOnly()) {
|
171 | 41823 | jjdelcerro | throw new SetReadOnlyAttributeException(attribute.getName(), this.getType()); |
172 | 41335 | jjdelcerro | } |
173 | FeatureAttributeEmulator emulator = attribute.getFeatureAttributeEmulator(); |
||
174 | 45581 | fdiaz | if (emulator != null) { |
175 | emulator.set((EditableFeature) this, value);
|
||
176 | 41335 | jjdelcerro | return;
|
177 | } |
||
178 | 43729 | fdiaz | |
179 | 45581 | fdiaz | if (value == null) { |
180 | if (!attribute.allowNull()) {
|
||
181 | if (!attribute.isAutomatic()) {
|
||
182 | 41335 | jjdelcerro | throw new IllegalValueException(attribute, value); |
183 | } |
||
184 | } |
||
185 | this.data.set(i, null); |
||
186 | return;
|
||
187 | 40435 | jjdelcerro | |
188 | 41335 | jjdelcerro | } |
189 | 40435 | jjdelcerro | |
190 | 45581 | fdiaz | if (attribute.getFeatureAttributeGetter() != null) { |
191 | 41335 | jjdelcerro | value = attribute.getFeatureAttributeGetter().setter(value); |
192 | 40435 | jjdelcerro | } |
193 | 44641 | jjdelcerro | this.setforced(i, attribute, value);
|
194 | } |
||
195 | 41335 | jjdelcerro | |
196 | 44641 | jjdelcerro | private void setforced(int i, FeatureAttributeDescriptor attribute, Object value) { |
197 | |||
198 | 42218 | jjdelcerro | Class objectClass = attribute.getObjectClass();
|
199 | 45581 | fdiaz | if (objectClass != null) { |
200 | if (objectClass.isInstance(value)) {
|
||
201 | if (attribute.getType() == DataTypes.DECIMAL) {
|
||
202 | BigDecimal d = (BigDecimal) value; |
||
203 | if (d.scale() == attribute.getScale() && d.precision() <= attribute.getPrecision()) {
|
||
204 | this.data.set(i, value);
|
||
205 | return;
|
||
206 | } |
||
207 | } else {
|
||
208 | 44799 | jjdelcerro | this.data.set(i, value);
|
209 | return;
|
||
210 | } |
||
211 | } |
||
212 | DataProfile dataProfile = attribute.getDataProfile(); |
||
213 | 45581 | fdiaz | if (dataProfile != null) { |
214 | 42218 | jjdelcerro | try {
|
215 | 44799 | jjdelcerro | value = dataProfile.coerce( |
216 | attribute.getDataType(), |
||
217 | 45581 | fdiaz | value, |
218 | 44799 | jjdelcerro | attribute.getTags() |
219 | ); |
||
220 | 42218 | jjdelcerro | } catch (CoercionException e) {
|
221 | 44799 | jjdelcerro | |
222 | 42218 | jjdelcerro | } |
223 | 45581 | fdiaz | } |
224 | 44799 | jjdelcerro | try {
|
225 | Coercion coercer = attribute.getDataType().getCoercion(); |
||
226 | 45581 | fdiaz | if (attribute.getType() == DataTypes.STRING && value instanceof Boolean) { |
227 | 45131 | fdiaz | value = coercer.coerce(value, attribute.getCoercionContext()); |
228 | value = StringUtils.left((String) value, attribute.getSize());
|
||
229 | } else {
|
||
230 | 45581 | fdiaz | value = coercer.coerce(value, attribute.getCoercionContext()); |
231 | 45131 | fdiaz | } |
232 | 44799 | jjdelcerro | } catch (CoercionException e) {
|
233 | throw new IllegalArgumentException("Can't convert to " |
||
234 | + attribute.getDataType().getName() |
||
235 | + " from '"
|
||
236 | 45581 | fdiaz | + value == null ? "NULL" : value.getClass().getName() |
237 | + "' with value '"
|
||
238 | + Objects.toString(value) |
||
239 | + "' and context '"
|
||
240 | + attribute.getCoercionContext() |
||
241 | + "'.");
|
||
242 | 40435 | jjdelcerro | } |
243 | 41335 | jjdelcerro | } |
244 | 40435 | jjdelcerro | this.data.set(i, value);
|
245 | } |
||
246 | 43729 | fdiaz | |
247 | 45581 | fdiaz | private Object get(int index, Class theClass, int type) { |
248 | 40435 | jjdelcerro | Object value = this.get(index); |
249 | 45581 | fdiaz | if (theClass.isInstance(value)) {
|
250 | 40435 | jjdelcerro | return value;
|
251 | } |
||
252 | try {
|
||
253 | return this.getDataTypesManager().coerce(type, value); |
||
254 | } catch (CoercionException e) {
|
||
255 | 43729 | fdiaz | |
256 | 40435 | jjdelcerro | if (value == null) { |
257 | return null; |
||
258 | } |
||
259 | throw new IllegalArgumentException( |
||
260 | 45581 | fdiaz | "Can't convert to " + theClass.getName()
|
261 | + " from '" + value.getClass().getName()
|
||
262 | + "' with value '" + value.toString() + "'."); |
||
263 | 40435 | jjdelcerro | } |
264 | } |
||
265 | 43729 | fdiaz | |
266 | 40435 | jjdelcerro | public void initializeValues() { |
267 | FeatureType type = this.getType();
|
||
268 | 44297 | jjdelcerro | for (FeatureAttributeDescriptor attribute : type) {
|
269 | 40435 | jjdelcerro | if (attribute.isAutomatic() || attribute.isReadOnly()
|
270 | 45581 | fdiaz | || attribute.isComputed()) { |
271 | 40435 | jjdelcerro | continue;
|
272 | } |
||
273 | if (attribute.getDefaultValue() == null && !attribute.allowNull()) { |
||
274 | continue;
|
||
275 | } |
||
276 | 45581 | fdiaz | Object value = attribute.getDefaultValue();
|
277 | if (value instanceof CharSequence) { |
||
278 | String s = ((CharSequence) value).toString(); |
||
279 | if (ExpressionUtils.isDynamicText(s)) {
|
||
280 | try {
|
||
281 | value = ExpressionUtils.evaluateDynamicText(s); |
||
282 | } catch (Throwable th) { |
||
283 | value = null;
|
||
284 | } |
||
285 | 44818 | jjdelcerro | } |
286 | } |
||
287 | this.set(attribute, value);
|
||
288 | 40435 | jjdelcerro | } |
289 | } |
||
290 | |||
291 | public void clear() { |
||
292 | initializeValues(); |
||
293 | } |
||
294 | |||
295 | public void initializeValues(Feature feature) { |
||
296 | 45581 | fdiaz | FeatureType myType = this.getType();
|
297 | FeatureType type = feature.getType(); |
||
298 | 44779 | omartinez | extraValuesData = null;
|
299 | 44297 | jjdelcerro | for (FeatureAttributeDescriptor attribute : type) {
|
300 | 45581 | fdiaz | FeatureAttributeDescriptor myAttribute = myType.getAttributeDescriptor(attribute.getName()); |
301 | 40435 | jjdelcerro | if (myAttribute != null) { |
302 | this.set(myAttribute, feature.get(attribute.getIndex()));
|
||
303 | } |
||
304 | } |
||
305 | } |
||
306 | |||
307 | 44297 | jjdelcerro | @Override
|
308 | 40435 | jjdelcerro | public FeatureStore getStore() {
|
309 | return (FeatureStore) this.storeRef.get(); |
||
310 | } |
||
311 | |||
312 | 44297 | jjdelcerro | @Override
|
313 | 40435 | jjdelcerro | public FeatureType getType() {
|
314 | return this.data.getType(); |
||
315 | } |
||
316 | |||
317 | 44297 | jjdelcerro | @Override
|
318 | 40435 | jjdelcerro | public EditableFeature getEditable() {
|
319 | return new DefaultEditableFeature(this); |
||
320 | } |
||
321 | |||
322 | 44297 | jjdelcerro | @Override
|
323 | 40435 | jjdelcerro | public Feature getCopy() {
|
324 | return new DefaultFeature(this); |
||
325 | } |
||
326 | 43729 | fdiaz | |
327 | 44297 | jjdelcerro | @Override
|
328 | @SuppressWarnings("CloneDoesntCallSuperClone") |
||
329 | 40876 | jjdelcerro | public Object clone() throws CloneNotSupportedException { |
330 | return new DefaultFeature(this); |
||
331 | } |
||
332 | 40435 | jjdelcerro | |
333 | 44297 | jjdelcerro | @Override
|
334 | 40435 | jjdelcerro | public FeatureReference getReference() {
|
335 | if (this.reference == null) { |
||
336 | if (!isInserted()) {
|
||
337 | return null; |
||
338 | } |
||
339 | 45647 | fdiaz | reference = FeatureReferenceFactory.createFromFeature(this);
|
340 | 40435 | jjdelcerro | } |
341 | return this.reference; |
||
342 | } |
||
343 | |||
344 | 44331 | jjdelcerro | @Override
|
345 | public Object getOrDefault(String name, Object defaultValue) { |
||
346 | int index = this.data.getType().getIndex(name); |
||
347 | 45581 | fdiaz | if (index < 0) { |
348 | 44331 | jjdelcerro | return defaultValue;
|
349 | } |
||
350 | return this.get(index); |
||
351 | } |
||
352 | |||
353 | @Override
|
||
354 | public String getStringOrDefault(String name, String defaultValue) { |
||
355 | int index = this.data.getType().getIndex(name); |
||
356 | 45581 | fdiaz | if (index < 0) { |
357 | 44331 | jjdelcerro | return defaultValue;
|
358 | } |
||
359 | try {
|
||
360 | return (String) this.get(index); |
||
361 | 45581 | fdiaz | } catch (Throwable th) { |
362 | 44331 | jjdelcerro | return defaultValue;
|
363 | } |
||
364 | } |
||
365 | |||
366 | @Override
|
||
367 | 45540 | jjdelcerro | public boolean getBooleanOrDefault(String name, boolean defaultValue) { |
368 | int index = this.data.getType().getIndex(name); |
||
369 | 45581 | fdiaz | if (index < 0) { |
370 | 45540 | jjdelcerro | return defaultValue;
|
371 | } |
||
372 | try {
|
||
373 | return this.getBoolean(index); |
||
374 | 45581 | fdiaz | } catch (Throwable th) { |
375 | 45540 | jjdelcerro | return defaultValue;
|
376 | } |
||
377 | } |
||
378 | |||
379 | @Override
|
||
380 | 44331 | jjdelcerro | public int getIntOrDefault(String name, int defaultValue) { |
381 | int index = this.data.getType().getIndex(name); |
||
382 | 45581 | fdiaz | if (index < 0) { |
383 | 44331 | jjdelcerro | return defaultValue;
|
384 | } |
||
385 | try {
|
||
386 | 45540 | jjdelcerro | return this.getInt(index); |
387 | 45581 | fdiaz | } catch (Throwable th) { |
388 | 44331 | jjdelcerro | return defaultValue;
|
389 | } |
||
390 | } |
||
391 | |||
392 | @Override
|
||
393 | public long getLongOrDefault(String name, long defaultValue) { |
||
394 | int index = this.data.getType().getIndex(name); |
||
395 | 45581 | fdiaz | if (index < 0) { |
396 | 44331 | jjdelcerro | return defaultValue;
|
397 | } |
||
398 | try {
|
||
399 | 45540 | jjdelcerro | return this.getLong(index); |
400 | 45581 | fdiaz | } catch (Throwable th) { |
401 | 44331 | jjdelcerro | return defaultValue;
|
402 | } |
||
403 | } |
||
404 | |||
405 | @Override
|
||
406 | public float getFloatOrDefault(String name, float defaultValue) { |
||
407 | int index = this.data.getType().getIndex(name); |
||
408 | 45581 | fdiaz | if (index < 0) { |
409 | 44331 | jjdelcerro | return defaultValue;
|
410 | } |
||
411 | try {
|
||
412 | 45540 | jjdelcerro | return this.getFloat(index); |
413 | 45581 | fdiaz | } catch (Throwable th) { |
414 | 44331 | jjdelcerro | return defaultValue;
|
415 | } |
||
416 | } |
||
417 | |||
418 | @Override
|
||
419 | public double getDoubleOrDefault(String name, double defaultValue) { |
||
420 | int index = this.data.getType().getIndex(name); |
||
421 | 45581 | fdiaz | if (index < 0) { |
422 | 44331 | jjdelcerro | return defaultValue;
|
423 | } |
||
424 | try {
|
||
425 | 45540 | jjdelcerro | return this.getDouble(index); |
426 | 45581 | fdiaz | } catch (Throwable th) { |
427 | 44331 | jjdelcerro | return defaultValue;
|
428 | } |
||
429 | } |
||
430 | |||
431 | @Override
|
||
432 | 44669 | jjdelcerro | public BigDecimal getDecimalOrDefault(String name, BigDecimal defaultValue) { |
433 | int index = this.data.getType().getIndex(name); |
||
434 | 45581 | fdiaz | if (index < 0) { |
435 | 44669 | jjdelcerro | return defaultValue;
|
436 | } |
||
437 | try {
|
||
438 | 45540 | jjdelcerro | return this.getDecimal(index); |
439 | 45581 | fdiaz | } catch (Throwable th) { |
440 | 44669 | jjdelcerro | return defaultValue;
|
441 | } |
||
442 | } |
||
443 | |||
444 | @Override
|
||
445 | 44331 | jjdelcerro | public Date getDateOrDefault(String name, Date defaultValue) { |
446 | int index = this.data.getType().getIndex(name); |
||
447 | 45581 | fdiaz | if (index < 0) { |
448 | 44331 | jjdelcerro | return defaultValue;
|
449 | } |
||
450 | try {
|
||
451 | 45540 | jjdelcerro | return this.getDate(index); |
452 | 45581 | fdiaz | } catch (Throwable th) { |
453 | 44331 | jjdelcerro | return defaultValue;
|
454 | } |
||
455 | } |
||
456 | |||
457 | @Override
|
||
458 | public Object getOrDefault(int index, Object defaultValue) { |
||
459 | 45581 | fdiaz | if (index < 0 || index >= this.data.getType().size()) { |
460 | 44331 | jjdelcerro | return defaultValue;
|
461 | } |
||
462 | try {
|
||
463 | return this.get(index); |
||
464 | 45581 | fdiaz | } catch (Throwable th) { |
465 | 44331 | jjdelcerro | return defaultValue;
|
466 | } |
||
467 | } |
||
468 | |||
469 | @Override
|
||
470 | public String getStringOrDefault(int index, String defaultValue) { |
||
471 | 45581 | fdiaz | if (index < 0 || index >= this.data.getType().size()) { |
472 | 44331 | jjdelcerro | return defaultValue;
|
473 | } |
||
474 | try {
|
||
475 | 45540 | jjdelcerro | return this.getString(index); |
476 | 45581 | fdiaz | } catch (Throwable th) { |
477 | 44331 | jjdelcerro | return defaultValue;
|
478 | } |
||
479 | } |
||
480 | |||
481 | @Override
|
||
482 | 45540 | jjdelcerro | public boolean getBooleanOrDefault(int index, boolean defaultValue) { |
483 | 45581 | fdiaz | if (index < 0 || index >= this.data.getType().size()) { |
484 | 45540 | jjdelcerro | return defaultValue;
|
485 | } |
||
486 | try {
|
||
487 | return this.getBoolean(index); |
||
488 | 45581 | fdiaz | } catch (Throwable th) { |
489 | 45540 | jjdelcerro | return defaultValue;
|
490 | } |
||
491 | } |
||
492 | |||
493 | @Override
|
||
494 | 44331 | jjdelcerro | public int getIntOrDefault(int index, int defaultValue) { |
495 | 45581 | fdiaz | if (index < 0 || index >= this.data.getType().size()) { |
496 | 44331 | jjdelcerro | return defaultValue;
|
497 | } |
||
498 | try {
|
||
499 | 45540 | jjdelcerro | return this.getInt(index); |
500 | 45581 | fdiaz | } catch (Throwable th) { |
501 | 44331 | jjdelcerro | return defaultValue;
|
502 | } |
||
503 | } |
||
504 | |||
505 | @Override
|
||
506 | public long getLongOrDefault(int index, long defaultValue) { |
||
507 | 45581 | fdiaz | if (index < 0 || index >= this.data.getType().size()) { |
508 | 44331 | jjdelcerro | return defaultValue;
|
509 | } |
||
510 | try {
|
||
511 | 45540 | jjdelcerro | return this.getLong(index); |
512 | 45581 | fdiaz | } catch (Throwable th) { |
513 | 44331 | jjdelcerro | return defaultValue;
|
514 | } |
||
515 | } |
||
516 | |||
517 | @Override
|
||
518 | public float getFloatOrDefault(int index, float defaultValue) { |
||
519 | 45581 | fdiaz | if (index < 0 || index >= this.data.getType().size()) { |
520 | 44331 | jjdelcerro | return defaultValue;
|
521 | } |
||
522 | try {
|
||
523 | 45540 | jjdelcerro | return this.getFloat(index); |
524 | 45581 | fdiaz | } catch (Throwable th) { |
525 | 44331 | jjdelcerro | return defaultValue;
|
526 | } |
||
527 | } |
||
528 | |||
529 | @Override
|
||
530 | public double getDoubleOrDefault(int index, double defaultValue) { |
||
531 | 45581 | fdiaz | if (index < 0 || index >= this.data.getType().size()) { |
532 | 44331 | jjdelcerro | return defaultValue;
|
533 | } |
||
534 | try {
|
||
535 | 45540 | jjdelcerro | return this.getDouble(index); |
536 | 45581 | fdiaz | } catch (Throwable th) { |
537 | 44331 | jjdelcerro | return defaultValue;
|
538 | } |
||
539 | } |
||
540 | |||
541 | @Override
|
||
542 | 44669 | jjdelcerro | public BigDecimal getDecimalOrDefault(int index, BigDecimal defaultValue) { |
543 | 45581 | fdiaz | if (index < 0 || index >= this.data.getType().size()) { |
544 | 44669 | jjdelcerro | return defaultValue;
|
545 | } |
||
546 | try {
|
||
547 | 45540 | jjdelcerro | return this.getDecimal(index); |
548 | 45581 | fdiaz | } catch (Throwable th) { |
549 | 44669 | jjdelcerro | return defaultValue;
|
550 | } |
||
551 | } |
||
552 | |||
553 | @Override
|
||
554 | 44331 | jjdelcerro | public Date getDateOrDefault(int index, Date defaultValue) { |
555 | 45581 | fdiaz | if (index < 0 || index >= this.data.getType().size()) { |
556 | 44331 | jjdelcerro | return defaultValue;
|
557 | } |
||
558 | try {
|
||
559 | 45540 | jjdelcerro | return this.getDate(index); |
560 | 45581 | fdiaz | } catch (Throwable th) { |
561 | 44331 | jjdelcerro | return defaultValue;
|
562 | } |
||
563 | } |
||
564 | |||
565 | 40435 | jjdelcerro | class UnableToGetReferenceException extends BaseRuntimeException { |
566 | |||
567 | /**
|
||
568 | 43729 | fdiaz | *
|
569 | 40435 | jjdelcerro | */
|
570 | private static final long serialVersionUID = 1812805035204824163L; |
||
571 | |||
572 | /**
|
||
573 | * @param exception
|
||
574 | */
|
||
575 | 44799 | jjdelcerro | @SuppressWarnings("OverridableMethodCallInConstructor") |
576 | 40435 | jjdelcerro | public UnableToGetReferenceException(BaseException exception) {
|
577 | super("Unable to get reference", "_UnableToGetReferenceException", |
||
578 | 45581 | fdiaz | serialVersionUID); |
579 | 40435 | jjdelcerro | this.initCause(exception);
|
580 | 43729 | fdiaz | |
581 | 40435 | jjdelcerro | } |
582 | 43729 | fdiaz | |
583 | 40435 | jjdelcerro | } |
584 | 43729 | fdiaz | |
585 | 44297 | jjdelcerro | @Override
|
586 | 45581 | fdiaz | public void validate(int mode) throws DataException { |
587 | 40435 | jjdelcerro | ((DefaultFeatureType) this.data.getType()).validateFeature(this, mode); |
588 | } |
||
589 | |||
590 | 44297 | jjdelcerro | @Override
|
591 | 40435 | jjdelcerro | public List getSRSs() { |
592 | // TODO Auto-generated method stub
|
||
593 | return null; |
||
594 | } |
||
595 | |||
596 | 44297 | jjdelcerro | @Override
|
597 | 40435 | jjdelcerro | public Envelope getDefaultEnvelope() {
|
598 | 41342 | jjdelcerro | Envelope envelope = this.data.getDefaultEnvelope();
|
599 | 45581 | fdiaz | if (envelope == null) { |
600 | 44618 | jjdelcerro | int i = this.data.getType().getDefaultGeometryAttributeIndex(); |
601 | 45581 | fdiaz | if (i < 0) { |
602 | 44618 | jjdelcerro | return null; |
603 | } |
||
604 | 41342 | jjdelcerro | Geometry geom = this.getDefaultGeometry();
|
605 | 45581 | fdiaz | if (geom != null) { |
606 | 41348 | jjdelcerro | envelope = geom.getEnvelope(); |
607 | } |
||
608 | 41342 | jjdelcerro | } |
609 | return envelope;
|
||
610 | 40435 | jjdelcerro | } |
611 | |||
612 | 44022 | jjdelcerro | @Override
|
613 | 40435 | jjdelcerro | public Geometry getDefaultGeometry() {
|
614 | 45581 | fdiaz | Geometry geom = this.data.getDefaultGeometry();
|
615 | if (geom == null) { |
||
616 | 44022 | jjdelcerro | int i = this.data.getType().getDefaultGeometryAttributeIndex(); |
617 | 45581 | fdiaz | if (i < 0) { |
618 | 44618 | jjdelcerro | return null; |
619 | } |
||
620 | 44022 | jjdelcerro | Object x = this.get(i); |
621 | 45581 | fdiaz | if (x instanceof Geometry) { |
622 | 44022 | jjdelcerro | geom = (Geometry) x; |
623 | } else {
|
||
624 | geom = this.getGeometry(i);
|
||
625 | } |
||
626 | 43420 | jjdelcerro | } |
627 | 45581 | fdiaz | if (geom != null) { |
628 | if (geom.getProjection() == null) { |
||
629 | 44022 | jjdelcerro | FeatureType type = this.getType();
|
630 | DefaultFeatureAttributeDescriptor attrdesc = (DefaultFeatureAttributeDescriptor) type.get(type.getDefaultGeometryAttributeIndex()); |
||
631 | IProjection proj = attrdesc.getSRS(this.storeRef);
|
||
632 | geom.setProjection(proj); |
||
633 | } |
||
634 | } |
||
635 | return geom;
|
||
636 | 40435 | jjdelcerro | } |
637 | |||
638 | 44767 | jjdelcerro | // @Override
|
639 | // public Time getDefaultTime() {
|
||
640 | // Time time = this.data.getDefaultTime();
|
||
641 | // if( time == null ) {
|
||
642 | // int i = this.data.getType().getDefaultTimeAttributeIndex();
|
||
643 | // Object x = this.get(i);
|
||
644 | // if( x instanceof Time ) {
|
||
645 | // time = (Time) x;
|
||
646 | // } else {
|
||
647 | // time = this.getTime(i);
|
||
648 | // }
|
||
649 | // }
|
||
650 | // return time;
|
||
651 | // }
|
||
652 | //
|
||
653 | 44086 | jjdelcerro | @Override
|
654 | 40435 | jjdelcerro | public IProjection getDefaultSRS() {
|
655 | 44022 | jjdelcerro | IProjection srs = this.data.getType().getDefaultSRS();
|
656 | 45581 | fdiaz | if (srs == null) { |
657 | 44022 | jjdelcerro | FeatureType type = this.getType();
|
658 | DefaultFeatureAttributeDescriptor attrdesc = (DefaultFeatureAttributeDescriptor) type.get(type.getDefaultGeometryAttributeIndex()); |
||
659 | srs = attrdesc.getSRS(this.storeRef);
|
||
660 | } |
||
661 | return srs;
|
||
662 | 40435 | jjdelcerro | } |
663 | |||
664 | 44297 | jjdelcerro | @Override
|
665 | 40435 | jjdelcerro | public List getGeometries() { |
666 | // TODO Auto-generated method stub
|
||
667 | return null; |
||
668 | } |
||
669 | |||
670 | 44128 | jjdelcerro | @Override
|
671 | public Object getFromProfile(int index) { |
||
672 | FeatureAttributeDescriptor descriptor = this.data.getType().getAttributeDescriptor(index);
|
||
673 | Object value = this.get(index); |
||
674 | String profileName = descriptor.getDataProfileName();
|
||
675 | 45581 | fdiaz | if (StringUtils.isBlank(profileName)) {
|
676 | 44128 | jjdelcerro | return value;
|
677 | } |
||
678 | DataProfile profile = DALLocator.getDataManager().getDataProfile(profileName); |
||
679 | 45581 | fdiaz | if (profile == null) { |
680 | 44128 | jjdelcerro | return value;
|
681 | } |
||
682 | 44253 | jjdelcerro | return profile.createData(value, descriptor.getTags());
|
683 | 44128 | jjdelcerro | } |
684 | |||
685 | @Override
|
||
686 | public Object getFromProfile(String name) { |
||
687 | FeatureAttributeDescriptor descriptor = this.data.getType().getAttributeDescriptor(name);
|
||
688 | return this.getFromProfile(descriptor.getIndex()); |
||
689 | } |
||
690 | |||
691 | 44297 | jjdelcerro | @Override
|
692 | 40435 | jjdelcerro | public Object get(String name) { |
693 | int index = this.data.getType().getIndex(name); |
||
694 | 45581 | fdiaz | if (index < 0) { |
695 | 45155 | omartinez | // buscamos en los extra cols
|
696 | 45581 | fdiaz | if (hasExtraColumnValue(name)) {
|
697 | 45155 | omartinez | return getExtraColumnValue(name);
|
698 | } |
||
699 | if (hasExtraValue(name)) {
|
||
700 | return getExtraValue(name);
|
||
701 | } |
||
702 | // y si esta ahi return
|
||
703 | 45581 | fdiaz | throw new IllegalArgumentException("Attribute name '" + name + "' not found in the feature."); |
704 | 40435 | jjdelcerro | } |
705 | return this.get(index); |
||
706 | } |
||
707 | 45581 | fdiaz | |
708 | 44669 | jjdelcerro | @Override
|
709 | public boolean isNull(int index) { |
||
710 | FeatureType type = this.data.getType();
|
||
711 | 45581 | fdiaz | if (index < 0 || index >= type.size()) { |
712 | throw new IllegalArgumentException("Attribute index '" + index + "' out of range (0 to " + this.data.getType().size() + "."); |
||
713 | 44669 | jjdelcerro | } |
714 | FeatureAttributeDescriptor attribute = type.getAttributeDescriptor(index); |
||
715 | if (!this.data.getType().hasEvaluators()) { |
||
716 | 45581 | fdiaz | return this.data.get(index) == null; |
717 | 44669 | jjdelcerro | } |
718 | Evaluator eval = attribute.getEvaluator(); |
||
719 | if (eval == null) { |
||
720 | 45581 | fdiaz | return this.data.get(index) == null; |
721 | 44669 | jjdelcerro | } |
722 | Object value = this.data.get(index); |
||
723 | if (value != null) { |
||
724 | return true; |
||
725 | } |
||
726 | try {
|
||
727 | value = eval.evaluate(this);
|
||
728 | } catch (EvaluatorException e) {
|
||
729 | throw new DataEvaluatorRuntimeException(e); |
||
730 | } |
||
731 | this.data.set(index, value);
|
||
732 | 45581 | fdiaz | return value == null; |
733 | 44669 | jjdelcerro | } |
734 | 45581 | fdiaz | |
735 | 44669 | jjdelcerro | @Override
|
736 | public boolean isNull(String name) { |
||
737 | int index = this.data.getType().getIndex(name); |
||
738 | 45581 | fdiaz | if (index < 0) { |
739 | throw new IllegalArgumentException("Attribute name '" + name + "' not found in the feature."); |
||
740 | 44669 | jjdelcerro | } |
741 | return this.isNull(index); |
||
742 | } |
||
743 | 43729 | fdiaz | |
744 | 43550 | jjdelcerro | public boolean has_key(String key) { |
745 | Object x = this.getType().get(key); |
||
746 | return x != null; |
||
747 | } |
||
748 | 43729 | fdiaz | |
749 | 43550 | jjdelcerro | public List<String> keys() { |
750 | List<String> ks = new ArrayList<>(); |
||
751 | 45581 | fdiaz | for (FeatureAttributeDescriptor attr : this.getType()) { |
752 | 43550 | jjdelcerro | ks.add(attr.getName()); |
753 | } |
||
754 | return ks;
|
||
755 | } |
||
756 | 43729 | fdiaz | |
757 | 43550 | jjdelcerro | public Iterator<String> iterkeys() { |
758 | final Iterator it = this.getType().iterator(); |
||
759 | return new Iterator<String>() { |
||
760 | @Override
|
||
761 | public boolean hasNext() { |
||
762 | return it.hasNext();
|
||
763 | } |
||
764 | 40435 | jjdelcerro | |
765 | 43550 | jjdelcerro | @Override
|
766 | public String next() { |
||
767 | 45581 | fdiaz | return ((FeatureAttributeDescriptor) it.next()).getName();
|
768 | 43550 | jjdelcerro | } |
769 | 43561 | jjdelcerro | |
770 | @Override
|
||
771 | public void remove() { |
||
772 | throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
||
773 | } |
||
774 | 43550 | jjdelcerro | }; |
775 | } |
||
776 | 40435 | jjdelcerro | |
777 | 43550 | jjdelcerro | public Iterator iteritems() { |
778 | final Iterator it = this.getType().iterator(); |
||
779 | return new Iterator<Map.Entry>() { |
||
780 | @Override
|
||
781 | public boolean hasNext() { |
||
782 | return it.hasNext();
|
||
783 | } |
||
784 | |||
785 | @Override
|
||
786 | public Map.Entry next() { |
||
787 | 45581 | fdiaz | final String name = ((FeatureAttributeDescriptor) it.next()).getName(); |
788 | 43550 | jjdelcerro | return new Map.Entry<String, Object>() { |
789 | @Override
|
||
790 | public String getKey() { |
||
791 | return name;
|
||
792 | } |
||
793 | |||
794 | @Override
|
||
795 | public Object getValue() { |
||
796 | return get(name);
|
||
797 | } |
||
798 | |||
799 | @Override
|
||
800 | public Object setValue(Object value) { |
||
801 | throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
||
802 | } |
||
803 | 43729 | fdiaz | |
804 | 43550 | jjdelcerro | }; |
805 | } |
||
806 | 43561 | jjdelcerro | |
807 | @Override
|
||
808 | public void remove() { |
||
809 | throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
||
810 | } |
||
811 | 43729 | fdiaz | }; |
812 | 43550 | jjdelcerro | } |
813 | |||
814 | @Override
|
||
815 | 40435 | jjdelcerro | public Object get(int index) { |
816 | FeatureType type = this.data.getType();
|
||
817 | 45581 | fdiaz | if (index < 0 || index >= type.size()) { |
818 | throw new IllegalArgumentException("Attribute index '" + index + "' out of range (0 to " + this.data.getType().size() + "."); |
||
819 | 40435 | jjdelcerro | } |
820 | 44840 | jjdelcerro | Object value = this.data.get(index); |
821 | 40435 | jjdelcerro | FeatureAttributeDescriptor attribute = type.getAttributeDescriptor(index); |
822 | 44840 | jjdelcerro | if (type.hasEvaluators()) {
|
823 | 45581 | fdiaz | Evaluator eval = attribute.getEvaluator(); |
824 | if (eval != null) { |
||
825 | if (value == null) { // Ya hemos calculado el campo ? |
||
826 | // FIXME: para comprobar si esta calculado usar un array especifico.
|
||
827 | try {
|
||
828 | value = eval.evaluate(this);
|
||
829 | } catch (EvaluatorException e) {
|
||
830 | throw new DataEvaluatorRuntimeException(e); |
||
831 | } |
||
832 | this.data.set(index, value);
|
||
833 | } |
||
834 | } |
||
835 | 43729 | fdiaz | } |
836 | 44840 | jjdelcerro | value = get(attribute, value); |
837 | 45581 | fdiaz | return value;
|
838 | 40435 | jjdelcerro | } |
839 | |||
840 | 45581 | fdiaz | private Object get(FeatureAttributeDescriptor featureAttributeDescriptor, Object value) { |
841 | 41335 | jjdelcerro | FeatureAttributeEmulator emulator = featureAttributeDescriptor.getFeatureAttributeEmulator(); |
842 | 45581 | fdiaz | if (emulator != null) { |
843 | 44226 | jjdelcerro | // int index = featureAttributeDescriptor.getIndex();
|
844 | // value = this.data.get(index);
|
||
845 | // if( value==null ) {
|
||
846 | 45581 | fdiaz | value = emulator.get(this);
|
847 | 44226 | jjdelcerro | // this.data.set(index,value);
|
848 | // }
|
||
849 | 44022 | jjdelcerro | } else {
|
850 | FeatureAttributeGetter getter = featureAttributeDescriptor.getFeatureAttributeGetter(); |
||
851 | 45581 | fdiaz | if (getter != null) { |
852 | 44022 | jjdelcerro | value = getter.getter(value); |
853 | } |
||
854 | 40435 | jjdelcerro | } |
855 | 44951 | omartinez | DataType dataType = featureAttributeDescriptor.getDataType(); |
856 | 45047 | jjdelcerro | Class<? extends DataType> theClass = dataType.getDefaultClass(); |
857 | 45581 | fdiaz | if (theClass != null && !theClass.isInstance(value)) { |
858 | 44951 | omartinez | try {
|
859 | value = this.getDataTypesManager().coerce(dataType.getType(), value);
|
||
860 | } catch (CoercionException e) {
|
||
861 | 45581 | fdiaz | throw new IllegalArgumentException( |
862 | "Can't convert to " + theClass.getSimpleName()
|
||
863 | + " from '" + value.getClass().getSimpleName()
|
||
864 | + "' with value '" + value.toString() + "'."); |
||
865 | 44951 | omartinez | } |
866 | } |
||
867 | 45581 | fdiaz | if (featureAttributeDescriptor.getType() == DataTypes.GEOMETRY) {
|
868 | if (value != null) { |
||
869 | Geometry geom = (Geometry) value; |
||
870 | if (geom.getProjection() == null) { |
||
871 | IProjection proj = ((DefaultFeatureAttributeDescriptor) featureAttributeDescriptor).getSRS(this.storeRef);
|
||
872 | 44022 | jjdelcerro | geom.setProjection(proj); |
873 | } |
||
874 | } |
||
875 | 41335 | jjdelcerro | } |
876 | return value;
|
||
877 | 40435 | jjdelcerro | } |
878 | |||
879 | 44297 | jjdelcerro | @Override
|
880 | public byte[] getByteArray(String name) { |
||
881 | return this.getByteArray(this.data.getType().getIndex(name)); |
||
882 | } |
||
883 | |||
884 | @Override
|
||
885 | public byte[] getByteArray(int index) { |
||
886 | return (byte[]) this.get(index); |
||
887 | } |
||
888 | |||
889 | @Override
|
||
890 | 40435 | jjdelcerro | public Object[] getArray(String name) { |
891 | return this.getArray(this.data.getType().getIndex(name)); |
||
892 | } |
||
893 | |||
894 | 44297 | jjdelcerro | @Override
|
895 | 40435 | jjdelcerro | public Object[] getArray(int index) { |
896 | return (Object[]) this.get(index); |
||
897 | } |
||
898 | |||
899 | 44297 | jjdelcerro | @Override
|
900 | 40435 | jjdelcerro | public boolean getBoolean(String name) { |
901 | return this.getBoolean(this.data.getType().getIndex(name)); |
||
902 | } |
||
903 | |||
904 | 44297 | jjdelcerro | @Override
|
905 | 40435 | jjdelcerro | public boolean getBoolean(int index) { |
906 | 45581 | fdiaz | Boolean value = ((Boolean) this.get(index, Boolean.class, DataTypes.BOOLEAN)); |
907 | 40435 | jjdelcerro | if (value == null) { |
908 | return false; |
||
909 | } |
||
910 | 44297 | jjdelcerro | return value;
|
911 | 40435 | jjdelcerro | } |
912 | |||
913 | 44297 | jjdelcerro | @Override
|
914 | 40435 | jjdelcerro | public byte getByte(String name) { |
915 | return this.getByte(this.data.getType().getIndex(name)); |
||
916 | } |
||
917 | |||
918 | 44297 | jjdelcerro | @Override
|
919 | 40435 | jjdelcerro | public byte getByte(int index) { |
920 | 45581 | fdiaz | Byte value = ((Byte) this.get(index, Byte.class, DataTypes.BYTE)); |
921 | 40435 | jjdelcerro | if (value == null) { |
922 | return 0; |
||
923 | } |
||
924 | 44297 | jjdelcerro | return value;
|
925 | 40435 | jjdelcerro | } |
926 | |||
927 | 44297 | jjdelcerro | @Override
|
928 | 45425 | jjdelcerro | public java.sql.Date getDate(String name) { |
929 | 40435 | jjdelcerro | return this.getDate(this.data.getType().getIndex(name)); |
930 | } |
||
931 | |||
932 | 44297 | jjdelcerro | @Override
|
933 | 45425 | jjdelcerro | public java.sql.Date getDate(int index) { |
934 | 45581 | fdiaz | java.sql.Date value = ((java.sql.Date) this.get(index, java.sql.Date.class, DataTypes.DATE));
|
935 | 44767 | jjdelcerro | return value;
|
936 | } |
||
937 | 40435 | jjdelcerro | |
938 | 44767 | jjdelcerro | @Override
|
939 | 45425 | jjdelcerro | public java.sql.Time getTime(String name) { |
940 | 44767 | jjdelcerro | return this.getTime(this.data.getType().getIndex(name)); |
941 | } |
||
942 | |||
943 | @Override
|
||
944 | 45425 | jjdelcerro | public java.sql.Time getTime(int index) { |
945 | 45581 | fdiaz | java.sql.Time value = ((java.sql.Time) this.get(index, java.sql.Time.class, DataTypes.TIME));
|
946 | 40435 | jjdelcerro | return value;
|
947 | } |
||
948 | |||
949 | 44297 | jjdelcerro | @Override
|
950 | 45425 | jjdelcerro | public java.sql.Timestamp getTimestamp(String name) { |
951 | 44767 | jjdelcerro | return this.getTimestamp(this.data.getType().getIndex(name)); |
952 | } |
||
953 | |||
954 | @Override
|
||
955 | 45425 | jjdelcerro | public java.sql.Timestamp getTimestamp(int index) { |
956 | 45581 | fdiaz | java.sql.Timestamp value = ((java.sql.Timestamp) this.get(index, java.sql.Timestamp.class, DataTypes.TIMESTAMP));
|
957 | 44767 | jjdelcerro | return value;
|
958 | } |
||
959 | |||
960 | @Override
|
||
961 | 40435 | jjdelcerro | public double getDouble(String name) { |
962 | return this.getDouble(this.data.getType().getIndex(name)); |
||
963 | } |
||
964 | |||
965 | 44297 | jjdelcerro | @Override
|
966 | 40435 | jjdelcerro | public double getDouble(int index) { |
967 | 43729 | fdiaz | |
968 | 45581 | fdiaz | Double value = ((Double) this.get(index, Double.class, DataTypes.DOUBLE)); |
969 | 40435 | jjdelcerro | if (value == null) { |
970 | return 0; |
||
971 | } |
||
972 | 44297 | jjdelcerro | return value;
|
973 | 40435 | jjdelcerro | } |
974 | |||
975 | 44297 | jjdelcerro | @Override
|
976 | 44669 | jjdelcerro | public BigDecimal getDecimal(String name) { |
977 | return this.getDecimal(this.data.getType().getIndex(name)); |
||
978 | } |
||
979 | |||
980 | @Override
|
||
981 | public BigDecimal getDecimal(int index) { |
||
982 | 45581 | fdiaz | BigDecimal value = ((BigDecimal) this.get(index, BigDecimal.class, DataTypes.DECIMAL)); |
983 | 44669 | jjdelcerro | return value;
|
984 | } |
||
985 | |||
986 | @Override
|
||
987 | 40435 | jjdelcerro | public Feature getFeature(String name) { |
988 | return this.getFeature(this.data.getType().getIndex(name)); |
||
989 | } |
||
990 | |||
991 | 44297 | jjdelcerro | @Override
|
992 | 40435 | jjdelcerro | public Feature getFeature(int index) { |
993 | return (Feature) this.get(index); |
||
994 | } |
||
995 | |||
996 | 44297 | jjdelcerro | @Override
|
997 | 40435 | jjdelcerro | public float getFloat(String name) { |
998 | return this.getFloat(this.data.getType().getIndex(name)); |
||
999 | } |
||
1000 | |||
1001 | 44297 | jjdelcerro | @Override
|
1002 | 40435 | jjdelcerro | public float getFloat(int index) { |
1003 | 45581 | fdiaz | Float value = ((Float) this.get(index, Float.class, DataTypes.FLOAT)); |
1004 | 40435 | jjdelcerro | if (value == null) { |
1005 | return 0; |
||
1006 | } |
||
1007 | 44297 | jjdelcerro | return value;
|
1008 | 40435 | jjdelcerro | } |
1009 | |||
1010 | 44297 | jjdelcerro | @Override
|
1011 | 40435 | jjdelcerro | public Geometry getGeometry(String name) { |
1012 | return this.getGeometry(this.data.getType().getIndex(name)); |
||
1013 | } |
||
1014 | |||
1015 | 44297 | jjdelcerro | @Override
|
1016 | 40435 | jjdelcerro | public Geometry getGeometry(int index) { |
1017 | 45581 | fdiaz | return (Geometry) this.get(index, Geometry.class, DataTypes.GEOMETRY); |
1018 | 40435 | jjdelcerro | } |
1019 | |||
1020 | 44297 | jjdelcerro | @Override
|
1021 | 40435 | jjdelcerro | public int getInt(String name) { |
1022 | return this.getInt(this.data.getType().getIndex(name)); |
||
1023 | } |
||
1024 | |||
1025 | 44297 | jjdelcerro | @Override
|
1026 | 40435 | jjdelcerro | public int getInt(int index) { |
1027 | 45581 | fdiaz | Integer value = ((Integer) this.get(index, Integer.class, DataTypes.INT)); |
1028 | 40435 | jjdelcerro | if (value == null) { |
1029 | return 0; |
||
1030 | } |
||
1031 | 44297 | jjdelcerro | return value;
|
1032 | 40435 | jjdelcerro | } |
1033 | |||
1034 | 44297 | jjdelcerro | @Override
|
1035 | 40435 | jjdelcerro | public long getLong(String name) { |
1036 | return this.getLong(this.data.getType().getIndex(name)); |
||
1037 | } |
||
1038 | |||
1039 | 44297 | jjdelcerro | @Override
|
1040 | 40435 | jjdelcerro | public long getLong(int index) { |
1041 | 45581 | fdiaz | Long value = ((Long) this.get(index, Long.class, DataTypes.LONG)); |
1042 | 40435 | jjdelcerro | if (value == null) { |
1043 | return 0; |
||
1044 | } |
||
1045 | 44297 | jjdelcerro | return value;
|
1046 | 40435 | jjdelcerro | } |
1047 | |||
1048 | 44297 | jjdelcerro | @Override
|
1049 | 40435 | jjdelcerro | public String getString(String name) { |
1050 | return this.getString(this.data.getType().getIndex(name)); |
||
1051 | } |
||
1052 | |||
1053 | 44297 | jjdelcerro | @Override
|
1054 | 40435 | jjdelcerro | public String getString(int index) { |
1055 | 45581 | fdiaz | return (String) this.get(index, String.class, DataTypes.STRING); |
1056 | 40435 | jjdelcerro | } |
1057 | |||
1058 | 44297 | jjdelcerro | @Override
|
1059 | 40435 | jjdelcerro | public Object getContextValue(String name) { |
1060 | name = name.toLowerCase(); |
||
1061 | if (name.equals("store")) { |
||
1062 | return this.getStore(); |
||
1063 | } |
||
1064 | |||
1065 | if (name.equals("featuretype")) { |
||
1066 | return this.data.getType(); |
||
1067 | } |
||
1068 | |||
1069 | if (name.equals("feature")) { |
||
1070 | return this; |
||
1071 | } |
||
1072 | |||
1073 | throw new IllegalArgumentException(name); |
||
1074 | } |
||
1075 | |||
1076 | 44297 | jjdelcerro | @Override
|
1077 | 40435 | jjdelcerro | public Iterator getDataNames() { |
1078 | class DataNamesIterator implements Iterator { |
||
1079 | 45581 | fdiaz | |
1080 | 40435 | jjdelcerro | Iterator attributeIteraror;
|
1081 | |||
1082 | DataNamesIterator(DefaultFeature feature) { |
||
1083 | this.attributeIteraror = feature.getType().iterator();
|
||
1084 | } |
||
1085 | |||
1086 | 44297 | jjdelcerro | @Override
|
1087 | 40435 | jjdelcerro | public boolean hasNext() { |
1088 | return this.attributeIteraror.hasNext(); |
||
1089 | } |
||
1090 | |||
1091 | 44297 | jjdelcerro | @Override
|
1092 | 40435 | jjdelcerro | public Object next() { |
1093 | return ((FeatureAttributeDescriptor) this.attributeIteraror |
||
1094 | .next()).getName(); |
||
1095 | } |
||
1096 | |||
1097 | 44297 | jjdelcerro | @Override
|
1098 | 40435 | jjdelcerro | public void remove() { |
1099 | throw new UnsupportedOperationException(); |
||
1100 | } |
||
1101 | |||
1102 | } |
||
1103 | return new DataNamesIterator(this); |
||
1104 | } |
||
1105 | |||
1106 | 44297 | jjdelcerro | @Override
|
1107 | 40435 | jjdelcerro | public Object getDataValue(String name) { |
1108 | name = name.toLowerCase(); |
||
1109 | 41542 | jjdelcerro | try {
|
1110 | return get(name);
|
||
1111 | } catch (IllegalArgumentException ex) { |
||
1112 | 45581 | fdiaz | if ("defaultgeometry".equalsIgnoreCase(name)) { |
1113 | 41542 | jjdelcerro | return this.getDefaultGeometry(); |
1114 | } |
||
1115 | throw ex;
|
||
1116 | } |
||
1117 | 40435 | jjdelcerro | } |
1118 | |||
1119 | 44297 | jjdelcerro | @Override
|
1120 | 40435 | jjdelcerro | public Iterator getDataValues() { |
1121 | class DataValuesIterator implements Iterator { |
||
1122 | 45581 | fdiaz | |
1123 | 40435 | jjdelcerro | DefaultFeature feature; |
1124 | int current = 0; |
||
1125 | |||
1126 | DataValuesIterator(DefaultFeature feature) { |
||
1127 | this.feature = feature;
|
||
1128 | } |
||
1129 | |||
1130 | 44297 | jjdelcerro | @Override
|
1131 | 40435 | jjdelcerro | public boolean hasNext() { |
1132 | return current < feature.getType().size() - 1; |
||
1133 | } |
||
1134 | |||
1135 | 44297 | jjdelcerro | @Override
|
1136 | 40435 | jjdelcerro | public Object next() { |
1137 | return feature.get(current++);
|
||
1138 | } |
||
1139 | |||
1140 | 44297 | jjdelcerro | @Override
|
1141 | 40435 | jjdelcerro | public void remove() { |
1142 | throw new UnsupportedOperationException(); |
||
1143 | } |
||
1144 | |||
1145 | } |
||
1146 | return new DataValuesIterator(this); |
||
1147 | } |
||
1148 | |||
1149 | 44297 | jjdelcerro | @Override
|
1150 | 40435 | jjdelcerro | public boolean hasContextValue(String name) { |
1151 | name = name.toLowerCase(); |
||
1152 | if (name.equals("store")) { |
||
1153 | return true; |
||
1154 | } |
||
1155 | |||
1156 | if (name.equals("featuretype")) { |
||
1157 | return true; |
||
1158 | } |
||
1159 | |||
1160 | 44297 | jjdelcerro | return name.equals("feature"); |
1161 | 40435 | jjdelcerro | } |
1162 | |||
1163 | 44297 | jjdelcerro | @Override
|
1164 | 40435 | jjdelcerro | public boolean hasDataValue(String name) { |
1165 | 45218 | omartinez | return this.hasValue(name); |
1166 | 40435 | jjdelcerro | } |
1167 | 43729 | fdiaz | |
1168 | 44767 | jjdelcerro | // @Override
|
1169 | // public Time getTime(int index) {
|
||
1170 | // return ((Time) this.get(index,Time.class,DataTypes.INSTANT));
|
||
1171 | // }
|
||
1172 | //
|
||
1173 | // @Override
|
||
1174 | // public Time getTime(String name) {
|
||
1175 | // return this.getInstant(this.data.getType().getIndex(name));
|
||
1176 | // }
|
||
1177 | //
|
||
1178 | // @Override
|
||
1179 | // public Instant getInstant(int index) {
|
||
1180 | // return ((Instant) this.get(index,Instant.class,DataTypes.INSTANT));
|
||
1181 | // }
|
||
1182 | //
|
||
1183 | // @Override
|
||
1184 | // public Instant getInstant(String name) {
|
||
1185 | // return this.getInstant(this.data.getType().getIndex(name));
|
||
1186 | // }
|
||
1187 | //
|
||
1188 | // @Override
|
||
1189 | // public Interval getInterval(int index) {
|
||
1190 | // return ((Interval) this.get(index,Interval.class,DataTypes.INTERVAL));
|
||
1191 | // }
|
||
1192 | //
|
||
1193 | // @Override
|
||
1194 | // public Interval getInterval(String name) {
|
||
1195 | // return this.getInterval(this.data.getType().getIndex(name));
|
||
1196 | // }
|
||
1197 | //
|
||
1198 | 44297 | jjdelcerro | @Override
|
1199 | 40435 | jjdelcerro | public DynObject getAsDynObject() {
|
1200 | 42775 | jjdelcerro | DynObjectFeatureFacade facade = new DynObjectFeatureFacade(this); |
1201 | 40435 | jjdelcerro | return facade;
|
1202 | } |
||
1203 | |||
1204 | 44297 | jjdelcerro | @Override
|
1205 | 40435 | jjdelcerro | public String toString() { |
1206 | 45581 | fdiaz | StringBuilder builder = new StringBuilder(); |
1207 | FeatureAttributeDescriptor[] attributeDescriptors
|
||
1208 | = getType().getAttributeDescriptors(); |
||
1209 | 40435 | jjdelcerro | for (int i = 0; i < attributeDescriptors.length; i++) { |
1210 | String name = attributeDescriptors[i].getName();
|
||
1211 | 44607 | jjdelcerro | Object value = get(name);
|
1212 | builder.append(value); |
||
1213 | 40435 | jjdelcerro | if (i < attributeDescriptors.length - 1) { |
1214 | 44297 | jjdelcerro | builder.append(", ");
|
1215 | 40435 | jjdelcerro | } |
1216 | } |
||
1217 | 44297 | jjdelcerro | return builder.toString();
|
1218 | 40435 | jjdelcerro | } |
1219 | 40867 | jbadia | |
1220 | 45581 | fdiaz | /**
|
1221 | 40435 | jjdelcerro | * @return the inserted
|
1222 | */
|
||
1223 | public boolean isInserted() { |
||
1224 | return inserted;
|
||
1225 | } |
||
1226 | |||
1227 | /**
|
||
1228 | * @param inserted the inserted to set
|
||
1229 | */
|
||
1230 | public void setInserted(boolean inserted) { |
||
1231 | this.inserted = inserted;
|
||
1232 | 45640 | jjdelcerro | // this.data.setNew(!inserted);
|
1233 | 40435 | jjdelcerro | } |
1234 | |||
1235 | 45581 | fdiaz | @Override
|
1236 | 40435 | jjdelcerro | public EvaluatorData getEvaluatorData() {
|
1237 | return this; |
||
1238 | } |
||
1239 | 43983 | jjdelcerro | |
1240 | 45013 | jjdelcerro | @Override
|
1241 | 43983 | jjdelcerro | public int size() { |
1242 | return this.data.getType().size(); |
||
1243 | } |
||
1244 | 45581 | fdiaz | |
1245 | 43983 | jjdelcerro | public boolean isEmpty() { |
1246 | return false; |
||
1247 | } |
||
1248 | |||
1249 | public Iterator<String> iterator() { |
||
1250 | final Iterator<FeatureAttributeDescriptor> x = this.data.getType().iterator(); |
||
1251 | return new Iterator<String>() { |
||
1252 | @Override
|
||
1253 | public boolean hasNext() { |
||
1254 | return x.hasNext();
|
||
1255 | } |
||
1256 | |||
1257 | @Override
|
||
1258 | public String next() { |
||
1259 | return x.next().getName();
|
||
1260 | } |
||
1261 | }; |
||
1262 | } |
||
1263 | 45581 | fdiaz | |
1264 | 43983 | jjdelcerro | public boolean containsKey(String key) { |
1265 | 45581 | fdiaz | return this.data.getType().get(key) != null; |
1266 | 43983 | jjdelcerro | } |
1267 | 44346 | jjdelcerro | |
1268 | @Override
|
||
1269 | public String getLabelOfValue(String name) { |
||
1270 | FeatureAttributeDescriptor attrdesc = this.data.getType().getAttributeDescriptor(name);
|
||
1271 | 45581 | fdiaz | if (attrdesc == null) { |
1272 | throw new IllegalArgumentException("Attribute name '" + name + "' not found in the feature."); |
||
1273 | 44346 | jjdelcerro | } |
1274 | Object value = this.get(attrdesc.getIndex()); |
||
1275 | String label = attrdesc.getLabelOfValue(value);
|
||
1276 | return label;
|
||
1277 | } |
||
1278 | 45581 | fdiaz | |
1279 | 44858 | jjdelcerro | @Override
|
1280 | public void setExtraValue(String name, Object value) { |
||
1281 | 45581 | fdiaz | if (this.extraValues == null) { |
1282 | this.extraValues = new HashMap<>(); |
||
1283 | } |
||
1284 | this.extraValues.put(name, value);
|
||
1285 | 44858 | jjdelcerro | } |
1286 | 45581 | fdiaz | |
1287 | 45155 | omartinez | public Object getExtraColumnValue(String name) { |
1288 | 44779 | omartinez | Object value;
|
1289 | 45162 | omartinez | if (this.extraValues != null) { |
1290 | if (this.extraValues.containsKey(name)) { |
||
1291 | return this.extraValues.get(name); |
||
1292 | } |
||
1293 | 44858 | jjdelcerro | } |
1294 | 44829 | omartinez | FeatureExtraColumns columns = this.getType().getExtraColumns();
|
1295 | 44779 | omartinez | int index = columns.getIndexOf(name);
|
1296 | 45162 | omartinez | if (index < 0) { |
1297 | throw new RuntimeException("Not extra column value found"); |
||
1298 | } |
||
1299 | if (extraValuesData == null) { |
||
1300 | 44779 | omartinez | extraValuesData = new Object[columns.size()]; |
1301 | 45162 | omartinez | } |
1302 | EditableFeatureAttributeDescriptor attrdesc = columns.get(index); |
||
1303 | value = extraValuesData[index]; |
||
1304 | 45581 | fdiaz | if (value != null) { |
1305 | 45162 | omartinez | return value;
|
1306 | } |
||
1307 | value = this.getExtraValue(name);
|
||
1308 | extraValuesData[index] = value; |
||
1309 | if (value == null && !this.hasExtraValue(name)) { |
||
1310 | 45581 | fdiaz | if (attrdesc.getFeatureAttributeEmulator() != null) { |
1311 | 45218 | omartinez | value = attrdesc.getFeatureAttributeEmulator().get(this);
|
1312 | extraValuesData[index] = value; |
||
1313 | } |
||
1314 | 44778 | omartinez | } |
1315 | 45162 | omartinez | return value;
|
1316 | 45155 | omartinez | } |
1317 | |||
1318 | @Override
|
||
1319 | public Object getExtraValue(String name) { |
||
1320 | Object value = this.data.getExtraValue(name); |
||
1321 | 44773 | jjdelcerro | return value;
|
1322 | 44376 | jjdelcerro | } |
1323 | 45581 | fdiaz | |
1324 | 44773 | jjdelcerro | @Override
|
1325 | 44738 | jjdelcerro | public boolean hasExtraValue(String name) { |
1326 | 45155 | omartinez | return this.data.hasExtraValue(name); |
1327 | } |
||
1328 | |||
1329 | private boolean hasExtraColumnValue(String name) { |
||
1330 | 45581 | fdiaz | if (this.extraValues != null) { |
1331 | if (this.extraValues.containsKey(name)) { |
||
1332 | return true; |
||
1333 | } |
||
1334 | 44858 | jjdelcerro | } |
1335 | 44829 | omartinez | FeatureExtraColumns columns = this.getType().getExtraColumns();
|
1336 | 44779 | omartinez | int index = columns.getIndexOf(name);
|
1337 | 45581 | fdiaz | if (index >= 0) { |
1338 | return true; |
||
1339 | 44779 | omartinez | } |
1340 | 45155 | omartinez | return false; |
1341 | 44738 | jjdelcerro | } |
1342 | 45581 | fdiaz | |
1343 | 44376 | jjdelcerro | @Override
|
1344 | 45218 | omartinez | public boolean hasValue(String name) { |
1345 | name = name.toLowerCase(); |
||
1346 | 45581 | fdiaz | return this.data.getType().getIndex(name) >= 0 |
1347 | || hasExtraValue(name) |
||
1348 | || hasExtraColumnValue(name); |
||
1349 | 45218 | omartinez | } |
1350 | 45581 | fdiaz | |
1351 | 45218 | omartinez | @Override
|
1352 | 44376 | jjdelcerro | public Object getExtraValue(int index) { |
1353 | return this.data.getExtraValue(index); |
||
1354 | } |
||
1355 | |||
1356 | 45425 | jjdelcerro | @Override
|
1357 | public JsonObject toJson() {
|
||
1358 | JsonObjectBuilder builder = this.toJsonBuilder();
|
||
1359 | return builder.build();
|
||
1360 | } |
||
1361 | 45581 | fdiaz | |
1362 | 45425 | jjdelcerro | @Override
|
1363 | public JsonObjectBuilder toJsonBuilder() {
|
||
1364 | 44655 | jjdelcerro | JsonObjectBuilder builder = Json.createObjectBuilder(); |
1365 | 45425 | jjdelcerro | Date date;
|
1366 | Geometry geom; |
||
1367 | 44655 | jjdelcerro | FeatureType ft = this.getType();
|
1368 | for (FeatureAttributeDescriptor desc : ft) {
|
||
1369 | if (desc.isComputed()) {
|
||
1370 | continue;
|
||
1371 | } |
||
1372 | 45581 | fdiaz | switch (desc.getType()) {
|
1373 | 44655 | jjdelcerro | case DataTypes.GEOMETRY:
|
1374 | 45425 | jjdelcerro | geom = this.getGeometry(desc.getIndex());
|
1375 | 45581 | fdiaz | if (geom != null) { |
1376 | 45425 | jjdelcerro | builder.add(desc.getName(), geom.convertToHexWKBQuietly()); |
1377 | 44655 | jjdelcerro | } |
1378 | break;
|
||
1379 | case DataTypes.BOOLEAN:
|
||
1380 | builder.add(desc.getName(), this.getBoolean(desc.getIndex()));
|
||
1381 | break;
|
||
1382 | case DataTypes.BYTE:
|
||
1383 | builder.add(desc.getName(), this.getByte(desc.getIndex()));
|
||
1384 | break;
|
||
1385 | case DataTypes.INT:
|
||
1386 | builder.add(desc.getName(), this.getInt(desc.getIndex()));
|
||
1387 | break;
|
||
1388 | case DataTypes.LONG:
|
||
1389 | builder.add(desc.getName(), this.getLong(desc.getIndex()));
|
||
1390 | break;
|
||
1391 | case DataTypes.DOUBLE:
|
||
1392 | builder.add(desc.getName(), this.getDouble(desc.getIndex()));
|
||
1393 | break;
|
||
1394 | case DataTypes.FLOAT:
|
||
1395 | builder.add(desc.getName(), this.getFloat(desc.getIndex()));
|
||
1396 | break;
|
||
1397 | case DataTypes.DATE:
|
||
1398 | // Format date as ISO 8601
|
||
1399 | 45425 | jjdelcerro | date = this.getDate(desc.getIndex());
|
1400 | 45581 | fdiaz | if (date == null) { |
1401 | 45003 | jjdelcerro | builder.addNull(desc.getName()); |
1402 | } else {
|
||
1403 | 45023 | fdiaz | LocalDateTime localDateTime = LocalDateTime.ofInstant(new Date(date.getTime()).toInstant(), ZoneId.systemDefault()); |
1404 | 45425 | jjdelcerro | String value = DateTimeFormatter.ISO_DATE.format(localDateTime);
|
1405 | builder.add(desc.getName(), value); |
||
1406 | } |
||
1407 | break;
|
||
1408 | case DataTypes.TIMESTAMP:
|
||
1409 | // Format date as ISO 8601
|
||
1410 | date = this.getTimestamp(desc.getIndex());
|
||
1411 | 45581 | fdiaz | if (date == null) { |
1412 | 45425 | jjdelcerro | builder.addNull(desc.getName()); |
1413 | } else {
|
||
1414 | LocalDateTime localDateTime = LocalDateTime.ofInstant(new Date(date.getTime()).toInstant(), ZoneId.systemDefault()); |
||
1415 | 45023 | fdiaz | String value = DateTimeFormatter.ISO_DATE_TIME.format(localDateTime);
|
1416 | 45003 | jjdelcerro | builder.add(desc.getName(), value); |
1417 | } |
||
1418 | 44655 | jjdelcerro | break;
|
1419 | 45425 | jjdelcerro | case DataTypes.TIME:
|
1420 | // Format date as ISO 8601
|
||
1421 | date = this.getTime(desc.getIndex());
|
||
1422 | 45581 | fdiaz | if (date == null) { |
1423 | 45425 | jjdelcerro | builder.addNull(desc.getName()); |
1424 | } else {
|
||
1425 | LocalDateTime localDateTime = LocalDateTime.ofInstant(new Date(date.getTime()).toInstant(), ZoneId.systemDefault()); |
||
1426 | String value = DateTimeFormatter.ISO_TIME.format(localDateTime);
|
||
1427 | builder.add(desc.getName(), value); |
||
1428 | } |
||
1429 | break;
|
||
1430 | 44655 | jjdelcerro | default:
|
1431 | 45581 | fdiaz | builder.add(desc.getName(), this.getStringOrDefault(desc.getIndex(), "")); |
1432 | 44655 | jjdelcerro | } |
1433 | 45581 | fdiaz | } |
1434 | 45425 | jjdelcerro | return builder;
|
1435 | 44655 | jjdelcerro | } |
1436 | 44376 | jjdelcerro | |
1437 | 44923 | jjdelcerro | @Override
|
1438 | public List<String> getKeys() { |
||
1439 | 45581 | fdiaz | List<String> l = new ArrayList<>(); |
1440 | for (FeatureAttributeDescriptor descriptor : this.getType()) { |
||
1441 | l.add(descriptor.getName()); |
||
1442 | } |
||
1443 | return l;
|
||
1444 | 44923 | jjdelcerro | } |
1445 | |||
1446 | 40435 | jjdelcerro | } |