root / trunk / libraries / libArcIMS / src / org / gvsig / remoteClient / arcims / utils / ArcImsValueFactory.java @ 8109
History | View | Annotate | Download (3.54 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2006 Prodevelop 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 |
* Prodevelop Integraci?n de Tecnolog?as SL
|
34 |
* Conde Salvatierra de ?lava , 34-10
|
35 |
* 46004 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963 510 612
|
39 |
* +34 963 510 968
|
40 |
* gis@prodevelop.es
|
41 |
* http://www.prodevelop.es
|
42 |
*/
|
43 |
|
44 |
package org.gvsig.remoteClient.arcims.utils; |
45 |
|
46 |
import com.hardcode.gdbms.engine.values.Value; |
47 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
48 |
|
49 |
import java.text.ParseException; |
50 |
|
51 |
import java.util.Date; |
52 |
|
53 |
|
54 |
/**
|
55 |
* Class that will generate convenient Value objects using ArcIMS
|
56 |
* types.
|
57 |
* @author jsanz
|
58 |
*/
|
59 |
public class ArcImsValueFactory extends ValueFactory { |
60 |
public static Value createValueByType(String text, int type, char delDec) |
61 |
throws ParseException { |
62 |
Value value; |
63 |
|
64 |
switch (type) {
|
65 |
case FieldInformation.BOOLEAN:
|
66 |
value = ValueFactory.createValue(Boolean.valueOf(text).booleanValue());
|
67 |
|
68 |
break;
|
69 |
|
70 |
case FieldInformation.SHAPE:
|
71 |
case FieldInformation.STRING:
|
72 |
value = ValueFactory.createValue(text); |
73 |
|
74 |
break;
|
75 |
|
76 |
case FieldInformation.DATE:
|
77 |
|
78 |
//This tipe is changed to use miliseconds as source of the value
|
79 |
if (text != null) { |
80 |
value = ValueFactory.createValue(new Date(Long.parseLong(text))); |
81 |
} else {
|
82 |
value = ValueFactory.createNullValue(); |
83 |
} |
84 |
|
85 |
break;
|
86 |
|
87 |
case FieldInformation.FLOAT:
|
88 |
|
89 |
if (text != null) { |
90 |
value = ValueFactory.createValue(Float.parseFloat(text.replace(
|
91 |
delDec, '.')));
|
92 |
} else {
|
93 |
value = ValueFactory.createNullValue(); |
94 |
} |
95 |
|
96 |
break;
|
97 |
|
98 |
case FieldInformation.DOUBLE:
|
99 |
|
100 |
if (text != null) { |
101 |
value = ValueFactory.createValue(Double.parseDouble(
|
102 |
text.replace(delDec, '.')));
|
103 |
} else {
|
104 |
value = ValueFactory.createNullValue(); |
105 |
} |
106 |
|
107 |
break;
|
108 |
|
109 |
case FieldInformation.SMALLINT:
|
110 |
value = ValueFactory.createValue(Short.parseShort(text));
|
111 |
|
112 |
break;
|
113 |
|
114 |
case FieldInformation.BIGINT:
|
115 |
value = ValueFactory.createValue(Long.parseLong(text));
|
116 |
|
117 |
break;
|
118 |
|
119 |
case FieldInformation.ID:
|
120 |
case FieldInformation.INTEGER:
|
121 |
value = ValueFactory.createValue(Integer.parseInt(text));
|
122 |
|
123 |
break;
|
124 |
|
125 |
default:
|
126 |
value = ValueFactory.createValue(text); |
127 |
} |
128 |
|
129 |
return value;
|
130 |
} |
131 |
} |