Revision 9767 trunk/libraries/libGDBMS/src/main/java/com/hardcode/gdbms/engine/data/driver/AbstractJDBCDriver.java
AbstractJDBCDriver.java | ||
---|---|---|
55 | 55 |
import com.hardcode.gdbms.engine.data.db.JDBCSupport; |
56 | 56 |
import com.hardcode.gdbms.engine.values.Value; |
57 | 57 |
import com.hardcode.gdbms.engine.values.ValueWriter; |
58 |
import com.iver.cit.gvsig.fmap.drivers.FieldDescription; |
|
59 |
import com.iver.cit.gvsig.fmap.drivers.ITableDefinition; |
|
60 |
import com.iver.cit.gvsig.fmap.drivers.TableDefinition; |
|
58 | 61 |
import com.iver.cit.gvsig.fmap.edition.IWriteable; |
59 | 62 |
import com.iver.cit.gvsig.fmap.edition.IWriter; |
60 | 63 |
import com.iver.cit.gvsig.fmap.edition.writers.JdbcWriter; |
64 |
import com.iver.utiles.NumberUtilities; |
|
61 | 65 |
|
62 | 66 |
public abstract class AbstractJDBCDriver implements AlphanumericDBDriver, |
63 | 67 |
IWriteable { |
... | ... | |
281 | 285 |
public IWriter getWriter() { |
282 | 286 |
return jdbcWriter; |
283 | 287 |
} |
288 |
|
|
289 |
/** |
|
290 |
* Return the default tabledefinition (only |
|
291 |
* has field description values). |
|
292 |
* Each driver that inheret this class must overwrite |
|
293 |
* this. |
|
294 |
* |
|
295 |
* */ |
|
296 |
public ITableDefinition getTableDefinition(){ |
|
297 |
TableDefinition tableDef = new TableDefinition(); |
|
298 |
try { |
|
299 |
tableDef.setFieldsDesc(getFieldsDescription()); |
|
300 |
} catch (DriverException e) { |
|
301 |
throw new RuntimeException(e);//excepcion sin chequear |
|
302 |
} |
|
303 |
return tableDef; |
|
304 |
} |
|
305 |
|
|
306 |
|
|
307 |
/*azabala |
|
308 |
TODO Copypasteado de SelectableDataSource. |
|
309 |
?No estar?a mejor aqu?? |
|
310 |
* |
|
311 |
*/ |
|
312 |
private FieldDescription[] getFieldsDescription() throws DriverException |
|
313 |
{ |
|
314 |
int numFields = getFieldCount(); |
|
315 |
FieldDescription[] fieldsDescrip = new FieldDescription[numFields]; |
|
316 |
for (int i = 0; i < numFields; i++) { |
|
317 |
fieldsDescrip[i] = new FieldDescription(); |
|
318 |
int type = getFieldType(i); |
|
319 |
fieldsDescrip[i].setFieldType(type); |
|
320 |
fieldsDescrip[i].setFieldName(getFieldName(i)); |
|
321 |
fieldsDescrip[i].setFieldLength(getFieldWidth(i)); |
|
322 |
if (NumberUtilities.isNumeric(type)) |
|
323 |
{ |
|
324 |
if (!NumberUtilities.isNumericInteger(type)) |
|
325 |
// TODO: If there is a lost in precision, this should be changed. |
|
326 |
fieldsDescrip[i].setFieldDecimalCount(6); |
|
327 |
} |
|
328 |
else |
|
329 |
fieldsDescrip[i].setFieldDecimalCount(0); |
|
330 |
// TODO: ?DEFAULTVALUE? |
|
331 |
// fieldsDescrip[i].setDefaultValue(get) |
|
332 |
} |
|
333 |
return fieldsDescrip; |
|
334 |
} |
|
284 | 335 |
} |
Also available in: Unified diff