Revision 21841 branches/Mobile_Compatible_Hito_1/libFMap/src-file/org/gvsig/data/datastores/vectorial/file/shp_jni/simplify/DbfDiskDataSource.java

View differences:

DbfDiskDataSource.java
3 3
import java.io.File;
4 4
import java.io.IOException;
5 5
import java.sql.Types;
6
import java.util.Date;
6 7

  
7 8
import org.apache.log4j.Logger;
8 9
import org.gvsig.compatible.StringUtil;
9 10
import org.gvsig.data.datastores.vectorial.file.shp_util.DBFDataSource;
10 11
import org.gvsig.exceptions.DriverException;
11 12

  
12
import com.hardcode.driverManager.Driver;
13
import com.hardcode.gdbms.engine.values.Value;
14
import com.hardcode.gdbms.engine.values.ValueFactory;
15

  
16 13
import es.prodevelop.gvsig.mobile.fmap.driver.vect.shp.ShpReader;
17 14

  
15

  
18 16
/**
19 17
 * This class implements a JNI-based DataSource which is based on a DBF file not
20 18
 * loaded into memory.
......
211 209
		return fieldCount;
212 210
	}
213 211

  
214
	private Value getValueOfItsType(int fieldindex, int row) {
212
	private Object getValueOfItsType(int fieldindex, int row) {
215 213

  
216
		Value resp = ValueFactory.createNullValue();
214
		Object resp = null;
217 215

  
218 216
		int type = fieldTypes[fieldindex];
219 217
		switch (type) {
220 218

  
221 219
		case Types.DOUBLE:
222
			double val = -81.112;
220
			double val = 0;
223 221
			try {
224 222
				val = ShpReader.getDbfNumberFieldValue(fileHandler, row,
225 223
						fieldindex);
226 224
			} catch (Throwable th) {
227 225
				logger.debug("Error: " + th.getMessage());
228 226
			}
229
			resp = ValueFactory.createValue(val);
227
			resp = new Double(val);
230 228
			break;
231 229

  
232 230
		case Types.VARCHAR:
233
			resp = ValueFactory.createValue(ShpReader.getDbfStringFieldValue(
234
					fileHandler, row, fieldindex));
231
			resp = ShpReader.getDbfStringFieldValue(fileHandler, row, fieldindex);
235 232
			break;
236 233

  
237 234
		case Types.DATE:
238 235

  
239
			resp = ValueFactory.createValue(ShpReader.getDbfStringFieldValue(
240
					fileHandler, row, fieldindex));
236
			resp = Date.parse(ShpReader.getDbfStringFieldValue(fileHandler, row, fieldindex));
241 237
			break;
242 238

  
243 239
		case Types.BOOLEAN:
244 240

  
245
			resp = ValueFactory.createValue(ShpReader.getDbfBooleanFieldValue(
246
					fileHandler, row, fieldindex));
241
			resp = new Boolean(ShpReader.getDbfBooleanFieldValue(fileHandler, row, fieldindex));
247 242
			break;
248 243
		}
249 244

  
250 245
		return resp;
251 246
	}
252 247

  
253
	/**
254
	 * Gets a row of this data source.
255
	 * 
256
	 * @param rowind
257
	 *            the index of the row of interest
258
	 * @return the row as an array of values
259
	 */
260
	public Value[] getRow(long rowind) throws DriverException {
261
		Value[] resp = new Value[fieldCount];
262
		for (int i = 0; i < fieldCount; i++) {
263
			resp[i] = getValueOfItsType(i, (int) rowind);
264
		}
265
		return resp;
266
	}
248
//	/**
249
//	 * Gets a row of this data source.
250
//	 * 
251
//	 * @param rowind
252
//	 *            the index of the row of interest
253
//	 * @return the row as an array of values
254
//	 */
255
//	public Value[] getRow(long rowind) throws DriverException {
256
//		Value[] resp = new Value[fieldCount];
257
//		for (int i = 0; i < fieldCount; i++) {
258
//			resp[i] = getValueOfItsType(i, (int) rowind);
259
//		}
260
//		return resp;
261
//	}
267 262

  
268 263
	/**
269 264
	 * @return an array with all the field names
......
300 295
		return false;
301 296
	}
302 297

  
303
	/**
304
	 * @return the associated driver, currently unused.
305
	 */
306
	public Driver getDriver() {
307
		logger.warn("Method getDriver() returned NULL.");
308
		return null;
309
	}
298
//	/**
299
//	 * @return the associated driver, currently unused.
300
//	 */
301
//	public Driver getDriver() {
302
//		logger.warn("Method getDriver() returned NULL.");
303
//		return null;
304
//	}
310 305

  
311 306
	/**
312 307
	 * Reloads the data source (stops and starts)
......
326 321
	 * 
327 322
	 * @return the value of the given row and field
328 323
	 */
329
	public Value getFieldValue(long arg0, int arg1) throws DriverException {
324
	public Object getFieldValue(long arg0, int arg1) throws DriverException {
330 325
		return getValueOfItsType(arg1, (int) arg0);
331 326
	}
332 327

  

Also available in: Unified diff