Revision 44673 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

View differences:

FeatureAttributeDescriptor.java
25 25

  
26 26
import java.math.MathContext;
27 27
import java.text.DateFormat;
28
import java.util.Locale;
28 29

  
29 30
import org.cresques.cts.IProjection;
30 31

  
......
39 40
import org.gvsig.tools.dataTypes.CoercionContext;
40 41

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

  
55
    public static final int INT_MAX_PRECISION = 10; // max int 2147483647.
56
    public static final int INT_DEFAULT_PRECISION = INT_MAX_PRECISION;
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();
57 86

  
58
    public static final int LONG_MAX_PRECISION = 19; // max long 9223372036854775807.
59
    public static final int LONG_DEFAULT_PRECISION = LONG_MAX_PRECISION;
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();
60 93

  
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;
94
  public String getDataProfileName();
66 95

  
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;
96
  public DataProfile getDataProfile();
72 97

  
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
84
	 * 						A new copy of this
85
	 */
86
	public FeatureAttributeDescriptor getCopy();
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();
87 108

  
88
	/**
89
	 * Returns the name of this attribute's data type.
90
	 *
91
	 * @return
92
	 * 		a string containing the name of this attribute's data type.
93
	 */
94
	public String getDataTypeName();
109
  /**
110
   * Return true if the attribitute support the "size". Only String and
111
   * ByteArray support size.
112
   *
113
   * @return
114
   */
115
  public boolean supportSize();
95 116

  
96
        public String getDataProfileName();
97
        
98
        public DataProfile getDataProfile();
99
        
100
	/**
101
	 * Returns a number that indicates the size of this attribute. See the
102
	 * documentation for the various constants of {@link DataTypes}
103
	 * for how to interpret this value. As an example, when the data type is
104
	 * {@link DataTypes#STRING}, this value indicates the maximum length of the string.
105
	 *
106
	 * @return
107
	 * 		an <code>int</code> indicating the size of the attribute.
108
	 */
109
	public int getSize();
117
  /**
118
   * For attributes of type {@link DataTypes#DECIMAL}, this returns the maximum
119
   * number of digits. For other types, this must always return zero.
120
   *
121
   * @return
122
   */
123
  public int getPrecision();
110 124

  
111
	/**
112
	 * For attributes of type {@link DataTypes#DECIMAL}, this returns the maximum 
113
   * number of digits.
114
   * For other types, this must always return zero.
115
   * 
116
   * @return 
117
	 */
118
	public int getPrecision();
125
  /**
126
   * Return true if the attribitute support the "precision". Only numeric types
127
   * support precision.
128
   *
129
   * @return
130
   */
131
  public boolean supportPrecision();
119 132

  
120
	/**
121
	 * For attributes of type {@link DataTypes#DECIMAL}, this returns the maximum 
122
   * number of digits after the decimal point.
123
   * For other types, this must always return zero.
124
   * 
125
   * @return 
126
	 */
127
	public int getScale();
133
  /**
134
   * For attributes of type {@link DataTypes#DECIMAL}, this returns the maximum
135
   * number of digits after the decimal point. For other types, this must always
136
   * return zero.
137
   *
138
   * @return
139
   */
140
  public int getScale();
128 141

  
129 142
  /**
130
	 * For attributes of type {@link DataTypes#DECIMAL}, this returns the MathContext
131
   * associated to this.
132
   * For other types return {@link MathContext#UNLIMITED}.
133
   * 
134
   * @return 
135
	 */
143
   * Return true if the attribitute support the "scale". Only float, double and
144
   * Decimal support scale.
145
   *
146
   * @return
147
   */
148
  public boolean supportScale();
149

  
150
  /**
151
   * For attributes of type {@link DataTypes#DECIMAL}, this returns the
152
   * MathContext associated to this. For other types return
153
   * {@link MathContext#UNLIMITED}.
154
   *
155
   * @return
156
   */
136 157
  public MathContext getMathContext();
137
  
138
	/**
139
	 * Return a CoercionContext for this attribute.
140
   * 
158

  
159
  /**
160
   * Return a CoercionContext for this attribute.
161
   *
141 162
   * @return the CoercionContext
142
	 */
163
   */
143 164
  public CoercionContext getCoercionContext();
144
  
165

  
145 166
  /**
146 167
   * Return a Coercion to convert a value to the type of this attribute.
147
   * 
168
   *
148 169
   * @return the Coercion.
149 170
   */
150 171
  public Coercion getCoercion();
151
  
152
	/**
153
	 * For attributes of type {@link DataTypes#OBJECT},
154
	 * this returns the Java {@link Class} object that class or interface that
155
	 * all values of this attribute can be cast to.
156
	 */
157
	public Class getObjectClass();
158 172

  
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
	public int getMinimumOccurrences();
173
  /**
174
   * Returns the rounding mode to use when a value is converted to the
175
   * attribute's data type. It will only be used for Float, Double and Decimal
176
   * data types.
177
   *
178
   * @return
179
   */
180
  public int getRoundMode();
167 181

  
168
	/**
169
	 * Returns the maximum number of occurrences of this attribute on a given
170
	 * feature.  The vast majority of data sources and data consumers will only
171
	 * function with this value being one.  A value of {@link Integer#MAX_VALUE}
172
	 * indicates that the maximum number of occurrences is unbounded.
173
	 */
174
	public int getMaximumOccurrences();
182
  /**
183
   * Returns the Locale associated with this attribute. It is usually used to
184
   * format and recognize dates and decimal numbers. The default Locale will be
185
   * <code>Locale. ENGLISH</code>
186
   *
187
   * @return
188
   */
189
  public Locale getLocale();
175 190

  
176
	/**
177
	 * Returns {@code true} if this attribute forms all or part of the unique identifying
178
	 * value for the feature it is contained by.  The primary key attributes uniquely
179
	 * identify this feature from other features of the same type.  This is different
180
	 * from the {@linkplain Feature#getReference()}, which must uniquely identify
181
	 * the {@link Feature} among all feature types.
182
	 */
183
	public boolean isPrimaryKey();
191
  /**
192
   * For attributes of type {@link DataTypes#OBJECT}, this returns the Java
193
   * {@link Class} object that class or interface that all values of this
194
   * attribute can be cast to.
195
   *
196
   * @return
197
   */
198
  public Class getObjectClass();
184 199

  
185
	/**
186
	 * Indicates whether this attribute accepts null values.
187
	 *
188
	 * @return
189
	 * 		true if this attribute can be null, false if not.
190
	 */
191
	public boolean allowNull();
200
  /**
201
   * Returns the minimum number of occurrences of this attribute on a given
202
   * feature. The vast majority of data sources and data consumers will only
203
   * function with this value being zero or one. If the minimum number of
204
   * occurrences is zero, this is equivalent, in SQL terms, to the attribute
205
   * being nillable.
206
   *
207
   * @return
208
   */
209
  public int getMinimumOccurrences();
192 210

  
193
	/**
194
	 * Returns an evaluator that will be used to calculate
195
	 * the value of this attribute
196
	 */
197
	public Evaluator getEvaluator();
211
  /**
212
   * Returns the maximum number of occurrences of this attribute on a given
213
   * feature.The vast majority of data sources and data consumers will only
214
   * function with this value being one. A value of {@link Integer#MAX_VALUE}
215
   * indicates that the maximum number of occurrences is unbounded.
216
   *
217
   * @return
218
   */
219
  public int getMaximumOccurrences();
198 220

  
199
	/**
200
	 * If this attribute is a {@link Geometry}, this method returns its
201
	 * Spatial Reference System.
202
	 *
203
	 * @return
204
	 * 		the SRS if this attribute is a {@link Geometry}, otherwise this method returns null.
205
	 */
206
	public IProjection getSRS();
221
  /**
222
   * Returns {@code true} if this attribute forms all or part of the unique
223
   * identifying value for the feature it is contained by. The primary key
224
   * attributes uniquely identify this feature from other features of the same
225
   * type. This is different from the {@linkplain Feature#getReference()}, which
226
   * must uniquely identify the {@link Feature} among all feature types.
227
   *
228
   * @return
229
   */
230
  public boolean isPrimaryKey();
207 231

  
208
	    /**
209
     * If this attribute is a {@link Geometry}, this method returns the specific
210
     * geometry type,
211
     * as defined in {@link Geometry.TYPES}.
212
     * 
213
     * @return
214
     *         One of {@link Geometry.TYPES}
215
     * @deprecated use {@link #getGeomType()} instead. To be removed in gvSIG
216
     *             2.1.
217
     */
218
	public int getGeometryType();
232
  /**
233
   * Indicates whether this attribute accepts null values.
234
   *
235
   * @return true if this attribute can be null, false if not.
236
   */
237
  public boolean allowNull();
219 238

  
220
	    /**
221
     * If this attribute is a {@link Geometry}, this method returns the specific
222
     * geometry subtype,
223
     * as defined in {@link Geometry.SUBTYPES}.
224
     * 
225
     * @return
226
     *         One of {@link Geometry.SUBTYPES}
227
     * @deprecated use {@link #getGeomType()} instead. To be removed in gvSIG
228
     *             2.1.
229
     */
230
	public int getGeometrySubType();
239
  /**
240
   * Returns an evaluator that will be used to calculate the value of this
241
   * attribute
242
   */
243
  public Evaluator getEvaluator();
231 244

  
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();
245
  /**
246
   * If this attribute is a {@link Geometry}, this method returns its Spatial
247
   * Reference System.
248
   *
249
   * @return the SRS if this attribute is a {@link Geometry}, otherwise this
250
   * method returns null.
251
   */
252
  public IProjection getSRS();
238 253

  
239
	/**
240
	 * If this attribute is of type Date, then this method returns
241
	 * the date format set by the data store.
242
	 *
243
	 * @return
244
	 * 		a date format
245
	 */
246
	public DateFormat getDateFormat();
254
  /**
255
   * If this attribute is a {@link Geometry}, this method returns the specific
256
   * geometry type, as defined in {@link Geometry.TYPES}.
257
   *
258
   * @return One of {@link Geometry.TYPES}
259
   * @deprecated use {@link #getGeomType()} instead. To be removed in gvSIG 2.1.
260
   */
261
  public int getGeometryType();
247 262

  
248
        /**
249
         * Return the default value coerced to the data type of attribute.
250
         * Return null if can't coerce.
251
         * 
252
         * @return default value or null.
253
         */
254
        public Object getDefaultValueCoerced();
263
  /**
264
   * If this attribute is a {@link Geometry}, this method returns the specific
265
   * geometry subtype, as defined in {@link Geometry.SUBTYPES}.
266
   *
267
   * @return One of {@link Geometry.SUBTYPES}
268
   * @deprecated use {@link #getGeomType()} instead. To be removed in gvSIG 2.1.
269
   */
270
  public int getGeometrySubType();
255 271

  
256
	/**
257
	 * Returns this attribute relative position within the {@link Feature}.
258
	 *
259
	 * @return
260
	 * 		an index
261
	 */
262
	public int getIndex();
272
  /**
273
   * Returns the {@link GeometryType} of the attribute if it is a geometry.
274
   *
275
   * @return the geometry type
276
   */
277
  public GeometryType getGeomType();
263 278

  
264
	/**
265
	 * Returns additional information of the attribute
266
	 *
267
	 * @return info
268
	 *
269
	 */
270
	public Object getAdditionalInfo(String infoName);
279
  /**
280
   * If this attribute is of type Date, then this method returns the date format
281
   * set by the data store.
282
   *
283
   * @return a date format
284
   */
285
  public DateFormat getDateFormat();
271 286

  
272
	/**
273
	 * Returns if value is created automatically by the source
274
	 */
275
	public boolean isAutomatic();
287
  /**
288
   * Return the default value coerced to the data type of attribute. Return null
289
   * if can't coerce.
290
   *
291
   * @return default value or null.
292
   */
293
  public Object getDefaultValueCoerced();
276 294

  
277
	/**
278
	 * Gets if the attribute is a temporal attribute.
279
	 * @return
280
	 *         <code>true</code> if is a temporal attribute
281
	 */
282
	public boolean isTime();  
295
  /**
296
   * Returns this attribute relative position within the {@link Feature}.
297
   *
298
   * @return an index
299
   */
300
  public int getIndex();
283 301

  
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
        public boolean allowIndexDuplicateds();
293
        public boolean isIndexAscending();
294
        
295
        public boolean isForeingKey();
296
            
297
        public ForeingKey getForeingKey();
298
	/**
299
	 * Gets if the attribute has a {@link FeatureAttributeGetter}.
300
	 * @return
301
	 *             a FeatureAttributeGetter or null.
302
         * @deprecated use getFeatureAttributeGetterAndSetter
303
	 */
304
	public FeatureAttributeGetter getFeatureAttributeGetter();
305
	
306
	/**
307
	 * Sets the {@link FeatureAttributeGetter} that is used to update the 
308
	 * presentation of a field.
309
	 * @param featureAttributeGetter
310
	 *             the {@link FeatureAttributeGetter} to set.
311
         * @deprecated use setFeatureAttributeGetterAndSetter
312
	 */
313
	public void setFeatureAttributeGetter(FeatureAttributeGetter featureAttributeGetter);
302
  /**
303
   * Returns additional information of the attribute
304
   *
305
   * @return info
306
   *
307
   */
308
  public Object getAdditionalInfo(String infoName);
314 309

  
315
     	/**
316
	 * Gets the attribute emulator associatted {@link FeatureAttributeEmulator} to this attribute.
317
	 * @return
318
	 *             a FeatureAttributeEmulator or null.
319
	 */
320
	public FeatureAttributeEmulator getFeatureAttributeEmulator();
321
        
322
        /**
323
         * Return true if the attribute has an evaluator o an emulator.
324
         * @return 
325
         */
326
        public boolean isComputed();
327
	
328
        /**
329
         * Return the store associated to this attribute descriptor.
330
         * 
331
         * @return the FeatureStore of the attribute descriptor.
332
         */
333
        public FeatureStore getStore();   
334
        
335
        public FeatureType getFeatureType();
336
            
337
        public String[] getRequiredFieldNames();
338
        
339
        public void recentUsed();
340
        
341
        @Override
342
        public String getLocalizedShortLabel();
310
  /**
311
   * Returns if value is created automatically by the source
312
   */
313
  public boolean isAutomatic();
343 314

  
344
        @Override
345
        public String getLocalizedLabel();
315
  /**
316
   * Gets if the attribute is a temporal attribute.
317
   *
318
   * @return <code>true</code> if is a temporal attribute
319
   */
320
  public boolean isTime();
346 321

  
347
        public String getLabelOfValue(Object value);
348
        
349
        public boolean hasOnlyMetadataChanges(FeatureAttributeDescriptor other);
350
        
351
        public boolean hasLabel();
352
        
353
        public boolean hasShortLabel();
354
        
355
        public boolean hasDescription();
356
        
322
  public Interval getInterval();
323

  
324
  /**
325
   * Return true if the attribute has and index in the table.
326
   *
327
   * @return true if indexed.
328
   */
329
  public boolean isIndexed();
330

  
331
  public boolean allowIndexDuplicateds();
332

  
333
  public boolean isIndexAscending();
334

  
335
  public boolean isForeingKey();
336

  
337
  public ForeingKey getForeingKey();
338

  
339
  /**
340
   * Gets if the attribute has a {@link FeatureAttributeGetter}.
341
   *
342
   * @return a FeatureAttributeGetter or null.
343
   * @deprecated use getFeatureAttributeGetterAndSetter
344
   */
345
  public FeatureAttributeGetter getFeatureAttributeGetter();
346

  
347
  /**
348
   * Sets the {@link FeatureAttributeGetter} that is used to update the
349
   * presentation of a field.
350
   *
351
   * @param featureAttributeGetter the {@link FeatureAttributeGetter} to set.
352
   * @deprecated use setFeatureAttributeGetterAndSetter
353
   */
354
  public void setFeatureAttributeGetter(FeatureAttributeGetter featureAttributeGetter);
355

  
356
  /**
357
   * Gets the attribute emulator associatted {@link FeatureAttributeEmulator} to
358
   * this attribute.
359
   *
360
   * @return a FeatureAttributeEmulator or null.
361
   */
362
  public FeatureAttributeEmulator getFeatureAttributeEmulator();
363

  
364
  /**
365
   * Return true if the attribute has an evaluator o an emulator.
366
   *
367
   * @return
368
   */
369
  public boolean isComputed();
370

  
371
  /**
372
   * Return the store associated to this attribute descriptor.
373
   *
374
   * @return the FeatureStore of the attribute descriptor.
375
   */
376
  public FeatureStore getStore();
377

  
378
  public FeatureType getFeatureType();
379

  
380
  public String[] getRequiredFieldNames();
381

  
382
  public void recentUsed();
383

  
384
  @Override
385
  public String getLocalizedShortLabel();
386

  
387
  @Override
388
  public String getLocalizedLabel();
389

  
390
  public String getLabelOfValue(Object value);
391

  
392
  public boolean hasOnlyMetadataChanges(FeatureAttributeDescriptor other);
393

  
394
  public boolean hasLabel();
395

  
396
  public boolean hasShortLabel();
397

  
398
  public boolean hasDescription();
399

  
400
  /**
401
   * Retrieve the value of the attribute "name".
402
   * 
403
   * @param name
404
   * @return 
405
   */
406
  public Object get(String name);
407
  
357 408
}

Also available in: Unified diff