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

History | View | Annotate | Download (3.59 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.util.LabeledValue;
27

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

    
30
  public static final int BYTE_MAX_PRECISION = 3; // max byte 255
31
  public static final int BYTE_DEFAULT_PRECISION = BYTE_MAX_PRECISION;
32

    
33
  public static final int INT_MAX_PRECISION = 10; // max int 2147483647.
34
  public static final int INT_DEFAULT_PRECISION = INT_MAX_PRECISION;
35

    
36
  public static final int LONG_MAX_PRECISION = 19; // max long 9223372036854775807.
37
  public static final int LONG_DEFAULT_PRECISION = LONG_MAX_PRECISION;
38

    
39
  // IEEE 754 Single-precision floating-point
40
  // https://en.m.wikipedia.org/wiki/Single-precision_floating-point_format
41
  public static final int FLOAT_MAX_PRECISION = 8; // 24bits
42
  public static final int FLOAT_DEFAULT_PRECISION = FLOAT_MAX_PRECISION;
43
  public static final int FLOAT_DEFAULT_SCALE = 3;
44

    
45
  // IEEE 754 Double-precision floating-point
46
  // https://en.m.wikipedia.org/wiki/Double-precision_floating-point_format
47
  public static final int DOUBLE_MAX_PRECISION = 16; // 54bits
48
  public static final int DOUBLE_DEFAULT_PRECISION = DOUBLE_MAX_PRECISION;
49
  public static final int DOUBLE_DEFAULT_SCALE = 8;
50

    
51
  // La precision de un BigDecimal es la de un BigInteger, que esta 
52
  // en 2^500000000, vamos a dejarla en que es algo mas de 2^5000000, siendo
53
  // consciente de que algunos proveedores no podran suportarla y la recortaran.
54
  public static final int DECIMAL_MAX_PRECISION = 2000000;
55
  public static final int DECIMAL_DEFAULT_PRECISION = 20;
56
  public static final int DECIMAL_DEFAULT_SCALE = 3;
57

    
58
  
59
  public interface NumberPrecisionAndScale {
60
    public int getPrecision();
61
    
62
    public int getScale();
63
  }
64
  
65
  public boolean isObject();
66

    
67
  public boolean isDynObject();
68

    
69
  public boolean isContainer();
70

    
71
  public boolean isNumeric();
72

    
73
  public String getName();
74

    
75
  public int getType();
76

    
77
  public Class getDefaultClass();
78

    
79
  public String getSubtype();
80

    
81
  public Coercion getCoercion();
82

    
83
//        public void setCoercion(Coercion coercion);
84
  public void addCoercion(Coercion coercion);
85

    
86
  public Object coerce(Object value) throws CoercionException;
87

    
88
  public Object coerce(Object value, CoercionContext context) throws CoercionException;
89

    
90
  public String getIconName();
91

    
92
  @Override
93
  public DataType clone() throws CloneNotSupportedException;
94

    
95
  public boolean supportSize();
96
  
97
  public boolean supportPrecision();
98
  
99
  public boolean supportScale();
100

    
101
  public int getMaxPrecision();
102
  
103
  public int getDefaultPrecision();
104
  
105
  public int getDefaultScale();
106
  
107
  public boolean isFixedPrecision();
108
  
109
  public NumberPrecisionAndScale fixPrecisionAndScale(int precision, int scale);
110
}