Statistics
| Revision:

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 @ 44678

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.math.MathContext;
27
import java.text.DateFormat;
28
import java.util.Locale;
29

    
30
import org.cresques.cts.IProjection;
31

    
32
import org.gvsig.fmap.dal.DataTypes;
33
import org.gvsig.fmap.geom.Geometry;
34
import org.gvsig.fmap.geom.type.GeometryType;
35
import org.gvsig.timesupport.Interval;
36
import org.gvsig.tools.dataTypes.Coercion;
37
import org.gvsig.tools.dynobject.DynField_v2;
38
import org.gvsig.tools.evaluator.Evaluator;
39
import org.gvsig.tools.util.LabeledValue;
40
import org.gvsig.tools.dataTypes.CoercionContext;
41

    
42
/**
43
 * A feature attribute descriptor contains information about one of the
44
 * attributes in a feature, such as its name, data type or precision.
45
 *
46
 * @author gvSIG team
47
 * @version $Id$
48
 */
49
public interface FeatureAttributeDescriptor
50
        extends DynField_v2, LabeledValue<FeatureAttributeDescriptor> {
51

    
52
//  public static final int BYTE_MAX_PRECISION = 3; // max byte 255
53
//  public static final int BYTE_DEFAULT_PRECISION = BYTE_MAX_PRECISION;
54
//
55
//  public static final int INT_MAX_PRECISION = 10; // max int 2147483647.
56
//  public static final int INT_DEFAULT_PRECISION = INT_MAX_PRECISION;
57
//
58
//  public static final int LONG_MAX_PRECISION = 19; // max long 9223372036854775807.
59
//  public static final int LONG_DEFAULT_PRECISION = LONG_MAX_PRECISION;
60
//
61
//  // IEEE 754 Single-precision floating-point
62
//  // https://en.m.wikipedia.org/wiki/Single-precision_floating-point_format
63
//  public static final int FLOAT_MAX_PRECISION = 8; // 24bits
64
//  public static final int FLOAT_DEFAULT_PRECISION = FLOAT_MAX_PRECISION;
65
//  public static final int FLOAT_DEFAULT_SCALE = 3;
66
//
67
//  // IEEE 754 Double-precision floating-point
68
//  // https://en.m.wikipedia.org/wiki/Double-precision_floating-point_format
69
//  public static final int DOUBLE_MAX_PRECISION = 16; // 54bits
70
//  public static final int DOUBLE_DEFAULT_PRECISION = DOUBLE_MAX_PRECISION;
71
//  public static final int DOUBLE_DEFAULT_SCALE = 8;
72
//
73
//  // La precision de un BigDecimal es la de un BigInteger, que esta 
74
//  // en 2^500000000, vamos a dejarla en que es algo mas de 2^5000000, siendo
75
//  // consciente de que algunos proveedores no podran suportarla y la recortaran.
76
//  public static final int DECIMAL_MAX_PRECISION = 2000000;
77
//  public static final int DECIMAL_DEFAULT_PRECISION = 20;
78
//  public static final int DECIMAL_DEFAULT_SCALE = 3;
79
//
80
  /**
81
   * Returns a clone of this attribute descriptor
82
   *
83
   * @return FeatureAttributeDescriptor A new copy of this
84
   */
85
  public FeatureAttributeDescriptor getCopy();
86

    
87
  /**
88
   * Returns the name of this attribute's data type.
89
   *
90
   * @return a string containing the name of this attribute's data type.
91
   */
92
  public String getDataTypeName();
93

    
94
  public String getDataProfileName();
95

    
96
  public DataProfile getDataProfile();
97

    
98
  /**
99
   * Returns a number that indicates the size of this attribute. See the
100
   * documentation for the various constants of {@link DataTypes} for how to
101
   * interpret this value. As an example, when the data type is
102
   * {@link DataTypes#STRING}, this value indicates the maximum length of the
103
   * string.
104
   *
105
   * @return an <code>int</code> indicating the size of the attribute.
106
   */
107
  public int getSize();
108

    
109
  /**
110
   * For attributes of type {@link DataTypes#DECIMAL}, this returns the maximum
111
   * number of digits. For other types, this must always return zero.
112
   *
113
   * @return
114
   */
115
  public int getPrecision();
116

    
117
  /**
118
   * For attributes of type {@link DataTypes#DECIMAL}, this returns the maximum
119
   * number of digits after the decimal point. For other types, this must always
120
   * return zero.
121
   *
122
   * @return
123
   */
124
  public int getScale();
125

    
126
  /**
127
   * For attributes of type {@link DataTypes#DECIMAL}, this returns the
128
   * MathContext associated to this. For other types return
129
   * {@link MathContext#UNLIMITED}.
130
   *
131
   * @return
132
   */
133
  public MathContext getMathContext();
134

    
135
  /**
136
   * Return a CoercionContext for this attribute.
137
   *
138
   * @return the CoercionContext
139
   */
140
  public CoercionContext getCoercionContext();
141

    
142
  /**
143
   * Return a Coercion to convert a value to the type of this attribute.
144
   *
145
   * @return the Coercion.
146
   */
147
  public Coercion getCoercion();
148

    
149
  /**
150
   * Returns the rounding mode to use when a value is converted to the
151
   * attribute's data type. It will only be used for Float, Double and Decimal
152
   * data types.
153
   *
154
   * @return
155
   */
156
  public int getRoundMode();
157

    
158
  /**
159
   * Returns the Locale associated with this attribute. It is usually used to
160
   * format and recognize dates and decimal numbers. The default Locale will be
161
   * <code>Locale. ENGLISH</code>
162
   *
163
   * @return
164
   */
165
  public Locale getLocale();
166

    
167
  /**
168
   * For attributes of type {@link DataTypes#OBJECT}, this returns the Java
169
   * {@link Class} object that class or interface that all values of this
170
   * attribute can be cast to.
171
   *
172
   * @return
173
   */
174
  public Class getObjectClass();
175

    
176
  /**
177
   * Returns the minimum number of occurrences of this attribute on a given
178
   * feature. The vast majority of data sources and data consumers will only
179
   * function with this value being zero or one. If the minimum number of
180
   * occurrences is zero, this is equivalent, in SQL terms, to the attribute
181
   * being nillable.
182
   *
183
   * @return
184
   */
185
  public int getMinimumOccurrences();
186

    
187
  /**
188
   * Returns the maximum number of occurrences of this attribute on a given
189
   * feature.The vast majority of data sources and data consumers will only
190
   * function with this value being one. A value of {@link Integer#MAX_VALUE}
191
   * indicates that the maximum number of occurrences is unbounded.
192
   *
193
   * @return
194
   */
195
  public int getMaximumOccurrences();
196

    
197
  /**
198
   * Returns {@code true} if this attribute forms all or part of the unique
199
   * identifying value for the feature it is contained by. The primary key
200
   * attributes uniquely identify this feature from other features of the same
201
   * type. This is different from the {@linkplain Feature#getReference()}, which
202
   * must uniquely identify the {@link Feature} among all feature types.
203
   *
204
   * @return
205
   */
206
  public boolean isPrimaryKey();
207

    
208
  /**
209
   * Indicates whether this attribute accepts null values.
210
   *
211
   * @return true if this attribute can be null, false if not.
212
   */
213
  public boolean allowNull();
214

    
215
  /**
216
   * Returns an evaluator that will be used to calculate the value of this
217
   * attribute
218
   */
219
  public Evaluator getEvaluator();
220

    
221
  /**
222
   * If this attribute is a {@link Geometry}, this method returns its Spatial
223
   * Reference System.
224
   *
225
   * @return the SRS if this attribute is a {@link Geometry}, otherwise this
226
   * method returns null.
227
   */
228
  public IProjection getSRS();
229

    
230
  /**
231
   * If this attribute is a {@link Geometry}, this method returns the specific
232
   * geometry type, as defined in {@link Geometry.TYPES}.
233
   *
234
   * @return One of {@link Geometry.TYPES}
235
   * @deprecated use {@link #getGeomType()} instead. To be removed in gvSIG 2.1.
236
   */
237
  public int getGeometryType();
238

    
239
  /**
240
   * If this attribute is a {@link Geometry}, this method returns the specific
241
   * geometry subtype, as defined in {@link Geometry.SUBTYPES}.
242
   *
243
   * @return One of {@link Geometry.SUBTYPES}
244
   * @deprecated use {@link #getGeomType()} instead. To be removed in gvSIG 2.1.
245
   */
246
  public int getGeometrySubType();
247

    
248
  /**
249
   * Returns the {@link GeometryType} of the attribute if it is a geometry.
250
   *
251
   * @return the geometry type
252
   */
253
  public GeometryType getGeomType();
254

    
255
  /**
256
   * If this attribute is of type Date, then this method returns the date format
257
   * set by the data store.
258
   *
259
   * @return a date format
260
   */
261
  public DateFormat getDateFormat();
262

    
263
  /**
264
   * Return the default value coerced to the data type of attribute. Return null
265
   * if can't coerce.
266
   *
267
   * @return default value or null.
268
   */
269
  public Object getDefaultValueCoerced();
270

    
271
  /**
272
   * Returns this attribute relative position within the {@link Feature}.
273
   *
274
   * @return an index
275
   */
276
  public int getIndex();
277

    
278
  /**
279
   * Returns additional information of the attribute
280
   *
281
   * @return info
282
   *
283
   */
284
  public Object getAdditionalInfo(String infoName);
285

    
286
  /**
287
   * Returns if value is created automatically by the source
288
   */
289
  public boolean isAutomatic();
290

    
291
  /**
292
   * Gets if the attribute is a temporal attribute.
293
   *
294
   * @return <code>true</code> if is a temporal attribute
295
   */
296
  public boolean isTime();
297

    
298
  public Interval getInterval();
299

    
300
  /**
301
   * Return true if the attribute has and index in the table.
302
   *
303
   * @return true if indexed.
304
   */
305
  public boolean isIndexed();
306

    
307
  public boolean allowIndexDuplicateds();
308

    
309
  public boolean isIndexAscending();
310

    
311
  public boolean isForeingKey();
312

    
313
  public ForeingKey getForeingKey();
314

    
315
  /**
316
   * Gets if the attribute has a {@link FeatureAttributeGetter}.
317
   *
318
   * @return a FeatureAttributeGetter or null.
319
   * @deprecated use getFeatureAttributeGetterAndSetter
320
   */
321
  public FeatureAttributeGetter getFeatureAttributeGetter();
322

    
323
  /**
324
   * Sets the {@link FeatureAttributeGetter} that is used to update the
325
   * presentation of a field.
326
   *
327
   * @param featureAttributeGetter the {@link FeatureAttributeGetter} to set.
328
   * @deprecated use setFeatureAttributeGetterAndSetter
329
   */
330
  public void setFeatureAttributeGetter(FeatureAttributeGetter featureAttributeGetter);
331

    
332
  /**
333
   * Gets the attribute emulator associatted {@link FeatureAttributeEmulator} to
334
   * this attribute.
335
   *
336
   * @return a FeatureAttributeEmulator or null.
337
   */
338
  public FeatureAttributeEmulator getFeatureAttributeEmulator();
339

    
340
  /**
341
   * Return true if the attribute has an evaluator o an emulator.
342
   *
343
   * @return
344
   */
345
  public boolean isComputed();
346

    
347
  /**
348
   * Return the store associated to this attribute descriptor.
349
   *
350
   * @return the FeatureStore of the attribute descriptor.
351
   */
352
  public FeatureStore getStore();
353

    
354
  public FeatureType getFeatureType();
355

    
356
  public String[] getRequiredFieldNames();
357

    
358
  public void recentUsed();
359

    
360
  @Override
361
  public String getLocalizedShortLabel();
362

    
363
  @Override
364
  public String getLocalizedLabel();
365

    
366
  public String getLabelOfValue(Object value);
367

    
368
  public boolean hasOnlyMetadataChanges(FeatureAttributeDescriptor other);
369

    
370
  public boolean hasLabel();
371

    
372
  public boolean hasShortLabel();
373

    
374
  public boolean hasDescription();
375

    
376
  /**
377
   * Retrieve the value of the attribute "name".
378
   * 
379
   * @param name
380
   * @return 
381
   */
382
  public Object get(String name);
383
  
384
}