Statistics
| Revision:

gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.lib / src / main / java / org / gvsig / tools / dataTypes / DataType.java @ 2088

History | View | Annotate | Download (4.47 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 2
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.tools.dataTypes;
25

    
26
import org.gvsig.tools.dataTypes.impl.coercion.CoerceToLocale;
27
import org.gvsig.tools.util.LabeledValue;
28

    
29
public interface DataType extends LabeledValue<DataType>, org.gvsig.tools.lang.Cloneable {
30

    
31
  
32
  public static final int FLAG_NONE = 0;
33
  public static final int FLAG_NUMBER = 1; // byte, int, long, float, double, decimal
34
  public static final int FLAG_SUPPORT_PRECISION = 2; // byte, int, long, float, double, decimal
35
  public static final int FLAG_SUPPORT_SCALE = 4;     // float, double, decimal
36
  public static final int FLAG_PREDEFINED_PRECISION = 8;   // byte, int, long, float, double
37
  public static final int FLAG_SUPPORT_SIZE = 16;   // String, byte[]
38
  public static final int FLAG_FLOATING_POINT = 32;     // float, double
39
  
40
  /**
41
   * Without scale asigned
42
   */
43
  public static final int SCALE_NONE = -1; 
44

    
45
  public static final int PRECISION_NONE = -1; 
46

    
47
  public static final int BYTE_MAX_PRECISION = 3; // max byte 255
48
  public static final int BYTE_DEFAULT_PRECISION = BYTE_MAX_PRECISION;
49

    
50
  public static final int INT_MAX_PRECISION = 10; // max int 2147483647.
51
  public static final int INT_DEFAULT_PRECISION = INT_MAX_PRECISION;
52

    
53
  public static final int LONG_MAX_PRECISION = 19; // max long 9223372036854775807.
54
  public static final int LONG_DEFAULT_PRECISION = LONG_MAX_PRECISION;
55

    
56
  // IEEE 754 Single-precision floating-point
57
  // https://en.m.wikipedia.org/wiki/Single-precision_floating-point_format
58
  public static final int FLOAT_MAX_PRECISION = 8; // 24bits
59
  public static final int FLOAT_DEFAULT_PRECISION = FLOAT_MAX_PRECISION;
60
  public static final int FLOAT_DEFAULT_SCALE = 3;
61

    
62
  // IEEE 754 Double-precision floating-point
63
  // https://en.m.wikipedia.org/wiki/Double-precision_floating-point_format
64
  public static final int DOUBLE_MAX_PRECISION = 16; // 54bits
65
  public static final int DOUBLE_DEFAULT_PRECISION = DOUBLE_MAX_PRECISION;
66
  public static final int DOUBLE_DEFAULT_SCALE = 8;
67

    
68
  // La precision de un BigDecimal es la de un BigInteger, que esta 
69
  // en 2^500000000, vamos a dejarla en que es algo mas de 2^5000000, siendo
70
  // consciente de que algunos proveedores no podran suportarla y la recortaran.
71
  public static final int DECIMAL_MAX_PRECISION = 2000000;
72
  public static final int DECIMAL_DEFAULT_PRECISION = 20;
73
  public static final int DECIMAL_DEFAULT_SCALE = 3;
74

    
75
  public static final int LOCALE_DEFAULT_SIZE = CoerceToLocale.LOCALE_DEFAULT_SIZE;
76
  
77
  public interface NumberPrecisionAndScale {
78
    public int getPrecision();
79
    
80
    public int getScale();
81
  }
82
  
83
  public boolean isObject();
84

    
85
  public boolean isDynObject();
86

    
87
  public boolean isContainer();
88

    
89
  public boolean isNumeric();
90

    
91
  public String getName();
92

    
93
  public int getType();
94

    
95
  public Class getDefaultClass();
96

    
97
  public String getSubtype();
98

    
99
  public Coercion getCoercion();
100

    
101
//        public void setCoercion(Coercion coercion);
102
  public void addCoercion(Coercion coercion);
103

    
104
  public Object coerce(Object value) throws CoercionException;
105

    
106
  public Object coerce(Object value, CoercionContext context) throws CoercionException;
107

    
108
  public String getIconName();
109

    
110
  @Override
111
  public DataType clone() throws CloneNotSupportedException;
112

    
113
  public boolean supportSize();
114
  
115
  public boolean supportPrecision();
116
  
117
  public boolean supportScale();
118

    
119
  public int getMaxPrecision();
120
  
121
  public int getDefaultPrecision();
122
  
123
  public int getDefaultScale();
124
  
125
  public boolean isPredefinedPrecision();
126
  
127
  public boolean isFloatingPoint();
128
  
129
  public NumberPrecisionAndScale fixPrecisionAndScale(int precision, int scale);
130
  
131
  public int getFlags();
132
}