root / branches / Mobile_Compatible_Hito_1 / libFMap_mobile_shp_driver / src-file / org / gvsig / data / datastores / vectorial / file / shp_mem / FieldDescription.java @ 21865
History | View | Annotate | Download (4.93 KB)
1 |
/*
|
---|---|
2 |
* Created on 27-oct-2005
|
3 |
*
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
5 |
*
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or
|
9 |
* modify it under the terms of the GNU General Public License
|
10 |
* as published by the Free Software Foundation; either version 2
|
11 |
* of the License, or (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License
|
19 |
* along with this program; if not, write to the Free Software
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
21 |
*
|
22 |
* For more information, contact:
|
23 |
*
|
24 |
* Generalitat Valenciana
|
25 |
* Conselleria d'Infraestructures i Transport
|
26 |
* Av. Blasco Ib??ez, 50
|
27 |
* 46010 VALENCIA
|
28 |
* SPAIN
|
29 |
*
|
30 |
* +34 963862235
|
31 |
* gvsig@gva.es
|
32 |
* www.gvsig.gva.es
|
33 |
*
|
34 |
* or
|
35 |
*
|
36 |
* IVER T.I. S.A
|
37 |
* Salamanca 50
|
38 |
* 46005 Valencia
|
39 |
* Spain
|
40 |
*
|
41 |
* +34 963163400
|
42 |
* dac@iver.es
|
43 |
*/
|
44 |
/************************************************
|
45 |
* *
|
46 |
* Modfied By: *
|
47 |
* Prodevelop Integraci?n de Tecnolog?as SL *
|
48 |
* Conde Salvatierra de ?lava , 34-10 *
|
49 |
* 46004 Valencia *
|
50 |
* Spain *
|
51 |
* *
|
52 |
* +34 963 510 612 *
|
53 |
* +34 963 510 968 *
|
54 |
* gis@prodevelop.es *
|
55 |
* http://www.prodevelop.es *
|
56 |
* *
|
57 |
* gvSIG Mobile Team 2006 *
|
58 |
* *
|
59 |
************************************************/
|
60 |
|
61 |
package org.gvsig.data.datastores.vectorial.file.shp_mem; |
62 |
|
63 |
import java.sql.Types; |
64 |
|
65 |
/**
|
66 |
* This class stores the metadata of a particular field
|
67 |
* @author iver
|
68 |
*
|
69 |
*/
|
70 |
public class FieldDescription { |
71 |
|
72 |
public static int stringToType(String strType) { |
73 |
int type = -1; |
74 |
if (strType.equals("String")) |
75 |
type = Types.VARCHAR;
|
76 |
if (strType.equals("Double")) |
77 |
type = Types.DOUBLE;
|
78 |
if (strType.equals("Integer")) |
79 |
type = Types.INTEGER;
|
80 |
if (strType.equals("Boolean")) |
81 |
type = Types.BOOLEAN;
|
82 |
if (strType.equals("Date")) |
83 |
type = Types.DATE;
|
84 |
|
85 |
if (type == -1) { |
86 |
throw new RuntimeException("Type not recognized: " + strType); |
87 |
} |
88 |
return type;
|
89 |
|
90 |
} |
91 |
|
92 |
public static String typeToString(int sqlType) { |
93 |
switch (sqlType) {
|
94 |
case Types.NUMERIC: |
95 |
case Types.BIGINT: |
96 |
case Types.INTEGER: |
97 |
case Types.SMALLINT: |
98 |
case Types.TINYINT: |
99 |
return "Integer"; |
100 |
|
101 |
case Types.BIT: |
102 |
return "Boolean"; |
103 |
|
104 |
case Types.CHAR: |
105 |
case Types.VARCHAR: |
106 |
case Types.LONGVARCHAR: |
107 |
return "String"; |
108 |
|
109 |
case Types.DATE: |
110 |
return "Date"; |
111 |
|
112 |
case Types.FLOAT: |
113 |
case Types.DOUBLE: |
114 |
case Types.DECIMAL: |
115 |
case Types.REAL: |
116 |
return "Double"; |
117 |
|
118 |
case Types.BINARY: |
119 |
case Types.VARBINARY: |
120 |
case Types.LONGVARBINARY: |
121 |
return "Binary"; |
122 |
|
123 |
case Types.TIMESTAMP: |
124 |
return "Timestamp"; |
125 |
|
126 |
case Types.TIME: |
127 |
return "Time"; |
128 |
|
129 |
case Types.OTHER: |
130 |
default:
|
131 |
throw new RuntimeException("Type not recognized: " + sqlType); |
132 |
} |
133 |
|
134 |
} |
135 |
|
136 |
/**
|
137 |
* Internal field name.
|
138 |
*/
|
139 |
private String fieldName; |
140 |
|
141 |
private String fieldAlias; |
142 |
|
143 |
private int fieldType; |
144 |
|
145 |
/**
|
146 |
* En campos num?ricos, numero de d?gitos a la izquierda del punto En campos
|
147 |
* de texto, numero de caracteres.
|
148 |
*/
|
149 |
private int fieldLength = 8; |
150 |
|
151 |
/**
|
152 |
* En campos num?ricos, numero de d?gitos a la derecha del punto.
|
153 |
*/
|
154 |
private int fieldDecimalCount = 0; |
155 |
|
156 |
/**
|
157 |
* @return Returns the fieldDecimalCount.
|
158 |
*/
|
159 |
public int getFieldDecimalCount() { |
160 |
return fieldDecimalCount;
|
161 |
} |
162 |
|
163 |
/**
|
164 |
* @param fieldDecimalCount
|
165 |
* The fieldDecimalCount to set.
|
166 |
*/
|
167 |
public void setFieldDecimalCount(int fieldDecimalCount) { |
168 |
this.fieldDecimalCount = fieldDecimalCount;
|
169 |
} |
170 |
|
171 |
/**
|
172 |
* @return Returns the fieldLength.
|
173 |
*/
|
174 |
public int getFieldLength() { |
175 |
return fieldLength;
|
176 |
} |
177 |
|
178 |
/**
|
179 |
* @param fieldLength
|
180 |
* The fieldLength to set.
|
181 |
*/
|
182 |
public void setFieldLength(int fieldLength) { |
183 |
this.fieldLength = fieldLength;
|
184 |
} |
185 |
|
186 |
/**
|
187 |
* @return Returns the fieldName.
|
188 |
*/
|
189 |
public String getFieldName() { |
190 |
return fieldName;
|
191 |
} |
192 |
|
193 |
/**
|
194 |
* @param fieldName
|
195 |
* The fieldName to set.
|
196 |
*/
|
197 |
public void setFieldName(String fieldName) { |
198 |
this.fieldName = fieldName;
|
199 |
this.fieldAlias = fieldName;
|
200 |
} |
201 |
|
202 |
/**
|
203 |
* @return Returns the fieldType.
|
204 |
*/
|
205 |
public int getFieldType() { |
206 |
return fieldType;
|
207 |
} |
208 |
|
209 |
/**
|
210 |
* @param fieldType
|
211 |
* The fieldType to set.
|
212 |
*/
|
213 |
public void setFieldType(int fieldType) { |
214 |
this.fieldType = fieldType;
|
215 |
} |
216 |
|
217 |
public String getFieldAlias() { |
218 |
return fieldAlias;
|
219 |
} |
220 |
|
221 |
public void setFieldAlias(String fieldAlias) { |
222 |
this.fieldAlias = fieldAlias;
|
223 |
} |
224 |
|
225 |
public FieldDescription cloneField() {
|
226 |
FieldDescription resul = new FieldDescription();
|
227 |
resul.fieldAlias = fieldAlias; |
228 |
resul.fieldName = fieldName; |
229 |
resul.fieldDecimalCount = fieldDecimalCount; |
230 |
resul.fieldType = fieldType; |
231 |
return resul;
|
232 |
} |
233 |
|
234 |
|
235 |
} |