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 / FeatureAttributeDescriptor.java @ 45258
History | View | Annotate | Download (10.9 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.math.MathContext; |
27 |
import java.text.DateFormat; |
28 |
import java.util.Locale; |
29 |
import javax.json.JsonObject; |
30 |
import javax.json.JsonObjectBuilder; |
31 |
|
32 |
import org.cresques.cts.IProjection; |
33 |
import org.gvsig.expressionevaluator.Expression; |
34 |
|
35 |
import org.gvsig.fmap.dal.DataTypes; |
36 |
import org.gvsig.fmap.geom.Geometry; |
37 |
import org.gvsig.fmap.geom.type.GeometryType; |
38 |
import org.gvsig.timesupport.Interval; |
39 |
import org.gvsig.tools.dataTypes.Coercion; |
40 |
import org.gvsig.tools.dynobject.DynField_v2; |
41 |
import org.gvsig.tools.evaluator.Evaluator; |
42 |
import org.gvsig.tools.util.LabeledValue; |
43 |
import org.gvsig.tools.dataTypes.CoercionContext; |
44 |
import org.gvsig.tools.persistence.Persistent; |
45 |
|
46 |
/**
|
47 |
* A feature attribute descriptor contains information about one of the
|
48 |
* attributes in a feature, such as its name, data type or precision.
|
49 |
*
|
50 |
* @author gvSIG team
|
51 |
* @version $Id$
|
52 |
*/
|
53 |
public interface FeatureAttributeDescriptor |
54 |
extends DynField_v2, LabeledValue<FeatureAttributeDescriptor>, Persistent {
|
55 |
|
56 |
/**
|
57 |
* Returns a clone of this attribute descriptor
|
58 |
*
|
59 |
* @return FeatureAttributeDescriptor A new copy of this
|
60 |
*/
|
61 |
public FeatureAttributeDescriptor getCopy();
|
62 |
|
63 |
/**
|
64 |
* Returns the name of this attribute's data type.
|
65 |
*
|
66 |
* @return a string containing the name of this attribute's data type.
|
67 |
*/
|
68 |
public String getDataTypeName(); |
69 |
|
70 |
public String getDataProfileName(); |
71 |
|
72 |
public DataProfile getDataProfile();
|
73 |
|
74 |
/**
|
75 |
* Returns a number that indicates the size of this attribute. See the
|
76 |
* documentation for the various constants of {@link DataTypes} for how to
|
77 |
* interpret this value. As an example, when the data type is
|
78 |
* {@link DataTypes#STRING}, this value indicates the maximum length of the
|
79 |
* string.
|
80 |
*
|
81 |
* @return an <code>int</code> indicating the size of the attribute.
|
82 |
*/
|
83 |
public int getSize(); |
84 |
|
85 |
/**
|
86 |
* Return the designated column normal maximum width in characters.
|
87 |
*
|
88 |
* @return
|
89 |
*/
|
90 |
public int getDisplaySize(); |
91 |
|
92 |
/**
|
93 |
* For attributes of type {@link DataTypes#DECIMAL}, this returns the maximum
|
94 |
* number of digits. For other types, this must always return zero.
|
95 |
*
|
96 |
* @return
|
97 |
*/
|
98 |
public int getPrecision(); |
99 |
|
100 |
/**
|
101 |
* For attributes of type {@link DataTypes#DECIMAL}, this returns the maximum
|
102 |
* number of digits after the decimal point. For other types, this must always
|
103 |
* return zero.
|
104 |
*
|
105 |
* @return
|
106 |
*/
|
107 |
public int getScale(); |
108 |
|
109 |
/**
|
110 |
* For attributes of type {@link DataTypes#DECIMAL}, this returns the
|
111 |
* MathContext associated to this. For other types return
|
112 |
* {@link MathContext#UNLIMITED}.
|
113 |
*
|
114 |
* @return
|
115 |
*/
|
116 |
public MathContext getMathContext(); |
117 |
|
118 |
/**
|
119 |
* Return a CoercionContext for this attribute.
|
120 |
*
|
121 |
* @return the CoercionContext
|
122 |
*/
|
123 |
public CoercionContext getCoercionContext();
|
124 |
|
125 |
/**
|
126 |
* Return a Coercion to convert a value to the type of this attribute.
|
127 |
*
|
128 |
* @return the Coercion.
|
129 |
*/
|
130 |
public Coercion getCoercion();
|
131 |
|
132 |
/**
|
133 |
* Returns the rounding mode to use when a value is converted to the
|
134 |
* attribute's data type. It will only be used for Float, Double and Decimal
|
135 |
* data types.
|
136 |
*
|
137 |
* @return
|
138 |
*/
|
139 |
public int getRoundMode(); |
140 |
|
141 |
/**
|
142 |
* Returns the Locale associated with this attribute. It is usually used to
|
143 |
* format and recognize dates and decimal numbers. The default Locale will be
|
144 |
* <code>Locale. ENGLISH</code>
|
145 |
*
|
146 |
* @return
|
147 |
*/
|
148 |
public Locale getLocale(); |
149 |
|
150 |
/**
|
151 |
* For attributes of type {@link DataTypes#OBJECT}, this returns the Java
|
152 |
* {@link Class} object that class or interface that all values of this
|
153 |
* attribute can be cast to.
|
154 |
*
|
155 |
* @return
|
156 |
*/
|
157 |
public Class getObjectClass(); |
158 |
|
159 |
/**
|
160 |
* Returns the minimum number of occurrences of this attribute on a given
|
161 |
* feature. The vast majority of data sources and data consumers will only
|
162 |
* function with this value being zero or one. If the minimum number of
|
163 |
* occurrences is zero, this is equivalent, in SQL terms, to the attribute
|
164 |
* being nillable.
|
165 |
*
|
166 |
* @return
|
167 |
*/
|
168 |
public int getMinimumOccurrences(); |
169 |
|
170 |
/**
|
171 |
* Returns the maximum number of occurrences of this attribute on a given
|
172 |
* feature.The vast majority of data sources and data consumers will only
|
173 |
* function with this value being one. A value of {@link Integer#MAX_VALUE}
|
174 |
* indicates that the maximum number of occurrences is unbounded.
|
175 |
*
|
176 |
* @return
|
177 |
*/
|
178 |
public int getMaximumOccurrences(); |
179 |
|
180 |
/**
|
181 |
* Returns {@code true} if this attribute forms all or part of the unique
|
182 |
* identifying value for the feature it is contained by. The primary key
|
183 |
* attributes uniquely identify this feature from other features of the same
|
184 |
* type. This is different from the {@linkplain Feature#getReference()}, which
|
185 |
* must uniquely identify the {@link Feature} among all feature types.
|
186 |
*
|
187 |
* @return
|
188 |
*/
|
189 |
public boolean isPrimaryKey(); |
190 |
|
191 |
/**
|
192 |
* Indicates whether this attribute accepts null values.
|
193 |
*
|
194 |
* @return true if this attribute can be null, false if not.
|
195 |
*/
|
196 |
public boolean allowNull(); |
197 |
|
198 |
/**
|
199 |
* Returns an evaluator that will be used to calculate the value of this
|
200 |
* attribute
|
201 |
* @return
|
202 |
*/
|
203 |
public Evaluator getEvaluator();
|
204 |
|
205 |
/**
|
206 |
* If this attribute is a {@link Geometry}, this method returns its Spatial
|
207 |
* Reference System.
|
208 |
*
|
209 |
* @return the SRS if this attribute is a {@link Geometry}, otherwise this
|
210 |
* method returns null.
|
211 |
*/
|
212 |
public IProjection getSRS();
|
213 |
|
214 |
/**
|
215 |
* If this attribute is a {@link Geometry}, this method returns the specific
|
216 |
* geometry type, as defined in {@link Geometry.TYPES}.
|
217 |
*
|
218 |
* @return One of {@link Geometry.TYPES}
|
219 |
* @deprecated use {@link #getGeomType()} instead. To be removed in gvSIG 2.1.
|
220 |
*/
|
221 |
public int getGeometryType(); |
222 |
|
223 |
/**
|
224 |
* If this attribute is a {@link Geometry}, this method returns the specific
|
225 |
* geometry subtype, as defined in {@link Geometry.SUBTYPES}.
|
226 |
*
|
227 |
* @return One of {@link Geometry.SUBTYPES}
|
228 |
* @deprecated use {@link #getGeomType()} instead. To be removed in gvSIG 2.1.
|
229 |
*/
|
230 |
public int getGeometrySubType(); |
231 |
|
232 |
/**
|
233 |
* Returns the {@link GeometryType} of the attribute if it is a geometry.
|
234 |
*
|
235 |
* @return the geometry type
|
236 |
*/
|
237 |
public GeometryType getGeomType();
|
238 |
|
239 |
/**
|
240 |
* If this attribute is of type Date, then this method returns the date format
|
241 |
* set by the data store.
|
242 |
*
|
243 |
* @return a date format
|
244 |
*/
|
245 |
public DateFormat getDateFormat(); |
246 |
|
247 |
/**
|
248 |
* Return the default value coerced to the data type of attribute. Return null
|
249 |
* if can't coerce.
|
250 |
*
|
251 |
* @return default value or null.
|
252 |
*/
|
253 |
public Object getDefaultValueCoerced(); |
254 |
|
255 |
/**
|
256 |
* Returns this attribute relative position within the {@link Feature}.
|
257 |
*
|
258 |
* @return an index
|
259 |
*/
|
260 |
public int getIndex(); |
261 |
|
262 |
/**
|
263 |
* Returns additional information of the attribute
|
264 |
*
|
265 |
* @param infoName
|
266 |
* @return info
|
267 |
*
|
268 |
*/
|
269 |
public String getAdditionalInfo(String infoName); |
270 |
|
271 |
/**
|
272 |
* Returns if value is created automatically by the source
|
273 |
* @return
|
274 |
*/
|
275 |
public boolean isAutomatic(); |
276 |
|
277 |
/**
|
278 |
* Gets if the attribute is a temporal attribute.
|
279 |
*
|
280 |
* @return <code>true</code> if is a temporal attribute
|
281 |
*/
|
282 |
public boolean isTime(); |
283 |
|
284 |
public Interval getInterval();
|
285 |
|
286 |
/**
|
287 |
* Return true if the attribute has and index in the table.
|
288 |
*
|
289 |
* @return true if indexed.
|
290 |
*/
|
291 |
public boolean isIndexed(); |
292 |
|
293 |
public boolean allowIndexDuplicateds(); |
294 |
|
295 |
public boolean isIndexAscending(); |
296 |
|
297 |
public boolean isForeingKey(); |
298 |
|
299 |
public ForeingKey getForeingKey();
|
300 |
|
301 |
/**
|
302 |
* Gets if the attribute has a {@link FeatureAttributeGetter}.
|
303 |
*
|
304 |
* @return a FeatureAttributeGetter or null.
|
305 |
* @deprecated use getFeatureAttributeGetterAndSetter
|
306 |
*/
|
307 |
public FeatureAttributeGetter getFeatureAttributeGetter();
|
308 |
|
309 |
/**
|
310 |
* Sets the {@link FeatureAttributeGetter} that is used to update the
|
311 |
* presentation of a field.
|
312 |
*
|
313 |
* @param featureAttributeGetter the {@link FeatureAttributeGetter} to set.
|
314 |
* @deprecated use setFeatureAttributeGetterAndSetter
|
315 |
*/
|
316 |
public void setFeatureAttributeGetter(FeatureAttributeGetter featureAttributeGetter); |
317 |
|
318 |
/**
|
319 |
* Gets the attribute emulator associatted {@link FeatureAttributeEmulator} to
|
320 |
* this attribute.
|
321 |
*
|
322 |
* @return a FeatureAttributeEmulator or null.
|
323 |
*/
|
324 |
public FeatureAttributeEmulator getFeatureAttributeEmulator();
|
325 |
|
326 |
/**
|
327 |
* Return true if the attribute has an evaluator o an emulator.
|
328 |
*
|
329 |
* @return
|
330 |
*/
|
331 |
public boolean isComputed(); |
332 |
|
333 |
/**
|
334 |
* Return the store associated to this attribute descriptor.
|
335 |
*
|
336 |
* @return the FeatureStore of the attribute descriptor.
|
337 |
*/
|
338 |
public FeatureStore getStore();
|
339 |
|
340 |
public FeatureType getFeatureType();
|
341 |
|
342 |
public String[] getRequiredFieldNames(); |
343 |
|
344 |
public void recentUsed(); |
345 |
|
346 |
@Override
|
347 |
public String getLocalizedShortLabel(); |
348 |
|
349 |
@Override
|
350 |
public String getLocalizedLabel(); |
351 |
|
352 |
public String getLabelOfValue(Object value); |
353 |
|
354 |
public boolean hasOnlyMetadataChanges(FeatureAttributeDescriptor other); |
355 |
|
356 |
public boolean hasLabel(); |
357 |
|
358 |
public boolean hasShortLabel(); |
359 |
|
360 |
public boolean hasDescription(); |
361 |
|
362 |
/**
|
363 |
* Retrieve the value of the attribute "name".
|
364 |
*
|
365 |
* @param name
|
366 |
* @return
|
367 |
*/
|
368 |
public Object get(String name); |
369 |
|
370 |
public boolean hasConstantAvailableValues(); |
371 |
|
372 |
public boolean isAvoidCachingAvailableValues(); |
373 |
|
374 |
public Expression getAvailableValuesExpression(); |
375 |
|
376 |
public FeatureAttributeDescriptor setAvailableValuesExpression(String expression); |
377 |
|
378 |
public FeatureAttributeDescriptor setAvailableValuesExpression(Expression expression); |
379 |
|
380 |
public JsonObject toJson();
|
381 |
|
382 |
public JsonObjectBuilder toJsonBuilder();
|
383 |
|
384 |
public boolean isInAvailableValues(Object valueToCheck); |
385 |
|
386 |
} |