root / trunk / extensions / extSymbology / src / org / gvsig / symbology / fmap / labeling / lang / Symbol.java @ 20768
History | View | Annotate | Download (3.3 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.BinaryValue; |
44 |
import com.hardcode.gdbms.engine.values.BooleanValue; |
45 |
import com.hardcode.gdbms.engine.values.ByteValue; |
46 |
import com.hardcode.gdbms.engine.values.DoubleValue; |
47 |
import com.hardcode.gdbms.engine.values.FloatValue; |
48 |
import com.hardcode.gdbms.engine.values.IntValue; |
49 |
import com.hardcode.gdbms.engine.values.LongValue; |
50 |
import com.hardcode.gdbms.engine.values.ShortValue; |
51 |
import com.hardcode.gdbms.engine.values.StringValue; |
52 |
import com.hardcode.gdbms.engine.values.Value; |
53 |
|
54 |
public class Symbol { |
55 |
public static final int DATA_TYPE_NULL = 0; |
56 |
public static final int DATA_TYPE_INT = 1; |
57 |
public static final int DATA_TYPE_FLOATING = 2; |
58 |
public static final int DATA_TYPE_STRING = 3; |
59 |
public static final int DATA_TYPE_BOOLEAN = 4; |
60 |
public static final int DATA_TYPE_DATE = 5; |
61 |
|
62 |
|
63 |
private Object value; |
64 |
private int dataType; |
65 |
private String name; |
66 |
|
67 |
|
68 |
public Symbol(String name, int dataType, Object value) { |
69 |
this.name = name;
|
70 |
this.value = value;
|
71 |
this.dataType = dataType;
|
72 |
} |
73 |
|
74 |
public int getDataType() { |
75 |
return dataType;
|
76 |
} |
77 |
|
78 |
public Object getValue() { |
79 |
return value;
|
80 |
} |
81 |
|
82 |
public String getName() { |
83 |
return name;
|
84 |
} |
85 |
|
86 |
|
87 |
public static Symbol createVariableSymbolFromValue(String name, Value v) { |
88 |
int type = DATA_TYPE_NULL;
|
89 |
Class valueClass = v.getClass();
|
90 |
|
91 |
// STRINGS
|
92 |
if (valueClass.equals(StringValue.class)) {
|
93 |
type = DATA_TYPE_STRING; |
94 |
} |
95 |
|
96 |
// INTEGERS
|
97 |
else if (valueClass.equals(IntValue.class) || |
98 |
valueClass.equals(LongValue.class) || |
99 |
valueClass.equals(ByteValue.class) || |
100 |
valueClass.equals(ShortValue.class)) { |
101 |
type = DATA_TYPE_INT; |
102 |
} |
103 |
|
104 |
// FLOATING
|
105 |
else if (valueClass.equals(FloatValue.class) || |
106 |
valueClass.equals(DoubleValue.class)) { |
107 |
type = DATA_TYPE_FLOATING; |
108 |
} |
109 |
|
110 |
// BOOLEAN
|
111 |
else if (valueClass.equals(BooleanValue.class) || |
112 |
valueClass.equals(BinaryValue.class)) { |
113 |
type = DATA_TYPE_BOOLEAN; |
114 |
} |
115 |
|
116 |
// DATE
|
117 |
else if (valueClass.equals(BooleanValue.class) || |
118 |
valueClass.equals(BinaryValue.class)) { |
119 |
type = DATA_TYPE_DATE; |
120 |
} |
121 |
|
122 |
return new Symbol(name, type, v); |
123 |
} |
124 |
} |