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