Statistics
| Revision:

svn-gvsig-desktop / trunk / extSymbology / src / org / gvsig / symbology / fmap / labeling / lang / Symbol.java @ 18755

History | View | Annotate | Download (2.84 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.symbology.fmap.labeling.lang;
42

    
43
import com.hardcode.gdbms.engine.values.*;
44

    
45
public class Symbol {
46
        public static final int DATA_TYPE_NULL = 0;
47
        public static final int DATA_TYPE_INT = 1;
48
        public static final int DATA_TYPE_FLOATING = 2;
49
        public static final int DATA_TYPE_STRING = 3;
50
        public static final int DATA_TYPE_BOOLEAN = 4;
51
        public static final int DATA_TYPE_DATE = 5;
52
        
53
        
54
        private Object value;
55
        private int dataType;
56
        private String name;
57
        
58
        
59
        public Symbol(String name, int dataType, Object value) {
60
                this.name = name;
61
                this.value = value;
62
                this.dataType = dataType;
63
        }
64
        
65
        public int getDataType() {
66
                return dataType;
67
        }
68
        
69
        public Object getValue() {
70
                return value;
71
        }
72
        
73
        public String getName() {
74
                return name;
75
        }
76
        
77
        
78
        public static Symbol createVariableSymbolFromValue(String name, Value v) {
79
                int type = DATA_TYPE_NULL;
80
                Class valueClass = v.getClass();
81
                
82
                // STRINGS
83
                if (valueClass.equals(StringValue.class)) {
84
                        type = DATA_TYPE_STRING;
85
                }
86
                
87
                // INTEGERS
88
                else if (valueClass.equals(IntValue.class) ||
89
                                 valueClass.equals(LongValue.class) ||
90
                                 valueClass.equals(ByteValue.class) ||
91
                                 valueClass.equals(ShortValue.class)) {
92
                        type = DATA_TYPE_INT;
93
                }
94
                
95
                // FLOATING
96
                else if (valueClass.equals(FloatValue.class) ||
97
                                 valueClass.equals(DoubleValue.class)) {
98
                        type = DATA_TYPE_FLOATING;
99
                }
100
                
101
                // BOOLEAN
102
                else if (valueClass.equals(BooleanValue.class) ||
103
                                 valueClass.equals(BinaryValue.class)) {
104
                        type = DATA_TYPE_BOOLEAN;
105
                }
106
                
107
                // DATE
108
                else if (valueClass.equals(BooleanValue.class) ||
109
                                 valueClass.equals(BinaryValue.class)) {
110
                        type = DATA_TYPE_DATE;
111
                }
112
                
113
                return new Symbol(name, type, v);
114
        }
115
}