Revision 32369
branches/v2_0_0_prep/libraries/org.gvsig.arcims/src/org/gvsig/remoteclient/arcims/utils/ArcImsValueFactory.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2010 Prodevelop S.L. main development |
|
26 |
* http://www.prodevelop.es |
|
27 |
*/ |
|
28 |
|
|
29 |
package org.gvsig.remoteclient.arcims.utils; |
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
import java.text.ParseException; |
|
34 |
|
|
35 |
import java.util.Date; |
|
36 |
|
|
37 |
|
|
38 |
/** |
|
39 |
* Class that will generate convenient Value objects using ArcIMS |
|
40 |
* types. |
|
41 |
* @author jsanz |
|
42 |
*/ |
|
43 |
public class ArcImsValueFactory extends ValueFactory { |
|
44 |
public static Value createValueByType(String text, int type, char delDec) |
|
45 |
throws ParseException { |
|
46 |
Value value; |
|
47 |
|
|
48 |
switch (type) { |
|
49 |
case FieldInformation.BOOLEAN: |
|
50 |
value = ValueFactory.createValue(Boolean.valueOf(text).booleanValue()); |
|
51 |
|
|
52 |
break; |
|
53 |
|
|
54 |
case FieldInformation.SHAPE: |
|
55 |
case FieldInformation.STRING: |
|
56 |
value = ValueFactory.createValue(text); |
|
57 |
|
|
58 |
break; |
|
59 |
|
|
60 |
case FieldInformation.DATE: |
|
61 |
|
|
62 |
//This tipe is changed to use miliseconds as source of the value |
|
63 |
if (text != null) { |
|
64 |
value = ValueFactory.createValue(new Date(Long.parseLong(text))); |
|
65 |
} else { |
|
66 |
value = ValueFactory.createNullValue(); |
|
67 |
} |
|
68 |
|
|
69 |
break; |
|
70 |
|
|
71 |
case FieldInformation.FLOAT: |
|
72 |
|
|
73 |
if (text != null) { |
|
74 |
value = ValueFactory.createValue(Float.parseFloat(text.replace( |
|
75 |
delDec, '.'))); |
|
76 |
} else { |
|
77 |
value = ValueFactory.createNullValue(); |
|
78 |
} |
|
79 |
|
|
80 |
break; |
|
81 |
|
|
82 |
case FieldInformation.DOUBLE: |
|
83 |
|
|
84 |
if (text != null) { |
|
85 |
value = ValueFactory.createValue(Double.parseDouble( |
|
86 |
text.replace(delDec, '.'))); |
|
87 |
} else { |
|
88 |
value = ValueFactory.createNullValue(); |
|
89 |
} |
|
90 |
|
|
91 |
break; |
|
92 |
|
|
93 |
case FieldInformation.SMALLINT: |
|
94 |
value = ValueFactory.createValue(Short.parseShort(text)); |
|
95 |
|
|
96 |
break; |
|
97 |
|
|
98 |
case FieldInformation.BIGINT: |
|
99 |
value = ValueFactory.createValue(Long.parseLong(text)); |
|
100 |
|
|
101 |
break; |
|
102 |
|
|
103 |
case FieldInformation.ID: |
|
104 |
case FieldInformation.INTEGER: |
|
105 |
value = ValueFactory.createValue(Integer.parseInt(text)); |
|
106 |
|
|
107 |
break; |
|
108 |
|
|
109 |
default: |
|
110 |
value = ValueFactory.createValue(text); |
|
111 |
} |
|
112 |
|
|
113 |
return value; |
|
114 |
} |
|
115 |
} |
Also available in: Unified diff