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

History | View | Annotate | Download (4.86 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 java.util.Collection;
27
import org.gvsig.tools.dataTypes.impl.coercion.CoerceToLocale;
28
import org.gvsig.tools.util.LabeledValue;
29

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

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

    
46
  public static final int PRECISION_NONE = -1; 
47

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

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

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

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

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

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

    
76
  public static final int STRING_DEFAULT_SIZE = 50;
77
  
78
  public static final int LOCALE_DEFAULT_SIZE = CoerceToLocale.LOCALE_DEFAULT_SIZE;
79
  
80
  
81
  // Tree-state boolean values
82
  public static final int UNKNOWN = 0;
83
  public static final int YES = 1;
84
  public static final int NO = 2;
85
  
86
  public interface NumberPrecisionAndScale {
87
    public int getPrecision();
88
    
89
    public int getScale();
90
  }
91
  
92
  public boolean isObject();
93

    
94
  public boolean isDynObject();
95

    
96
  public boolean isContainer();
97

    
98
  public boolean isNumeric();
99

    
100
  public String getName();
101
  
102
  public DataType addAlias(String alias);
103
  
104
  public Collection<String> getAlias();
105

    
106
  public int getType();
107

    
108
  public Class getDefaultClass();
109

    
110
  public String getSubtype();
111

    
112
  public Coercion getCoercion();
113

    
114
//        public void setCoercion(Coercion coercion);
115
  public void addCoercion(Coercion coercion);
116

    
117
  public Object coerce(Object value) throws CoercionException;
118

    
119
  public Object coerce(Object value, CoercionContext context) throws CoercionException;
120

    
121
  public String getIconName();
122

    
123
  @Override
124
  public DataType clone() throws CloneNotSupportedException;
125

    
126
  public boolean supportSize();
127
  
128
  public boolean supportPrecision();
129
  
130
  public boolean supportScale();
131

    
132
  public int getMaxPrecision();
133
  
134
  public int getDefaultPrecision();
135
  
136
  public int getDefaultScale();
137
  
138
  public int getDefaultSize();
139
  
140
  public DataType setDefaultSize(int size);
141
  
142
  public boolean isPredefinedPrecision();
143
  
144
  public boolean isFloatingPoint();
145
  
146
  public NumberPrecisionAndScale fixPrecisionAndScale(int precision, int scale);
147
  
148
  public int getFlags();
149
}