Revision 1773
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/VectorialFileAdapter.java | ||
---|---|---|
209 | 209 |
File dataFile = ed.getDataFile(file); |
210 | 210 |
String driverName = ed.getDataDriverName(); |
211 | 211 |
|
212 |
DataSourceFactory.addFileDataSource(driverName, name,
|
|
212 |
LayerFactory.getDataSourceFactory().addFileDataSource(driverName, name,
|
|
213 | 213 |
dataFile.getAbsolutePath(), file.getAbsolutePath()); |
214 |
ds = DataSourceFactory.createRandomDataSource(name);
|
|
214 |
ds = LayerFactory.getDataSourceFactory().createRandomDataSource(name);
|
|
215 | 215 |
} else if (driver instanceof ReadDriver) { |
216 |
DataSourceFactory.addDataSource((ReadDriver)driver, name);
|
|
217 |
ds = DataSourceFactory.createRandomDataSource(name);
|
|
216 |
LayerFactory.getDataSourceFactory().addDataSource((ReadDriver)driver, name);
|
|
217 |
ds = LayerFactory.getDataSourceFactory().createRandomDataSource(name);
|
|
218 | 218 |
} else { |
219 | 219 |
return null; |
220 | 220 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLyrVect.java | ||
---|---|---|
313 | 313 |
} catch (com.hardcode.gdbms.engine.data.DriverException e) { |
314 | 314 |
// TODO Auto-generated catch block |
315 | 315 |
e.printStackTrace(); |
316 |
} catch (FieldNotFoundException e) { |
|
317 |
// TODO Auto-generated catch block |
|
318 |
e.printStackTrace(); |
|
319 | 316 |
} |
320 | 317 |
|
321 | 318 |
FLyrText layerText = new FLyrText(labels); |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/VectorialDBAdapter.java | ||
---|---|---|
173 | 173 |
public DataSource getRecordset(String name) throws DriverLoadException { |
174 | 174 |
if (driver instanceof ReadDriver) |
175 | 175 |
{ |
176 |
DataSourceFactory.addDataSource((ReadDriver)driver, name);
|
|
176 |
LayerFactory.getDataSourceFactory().addDataSource((ReadDriver)driver, name);
|
|
177 | 177 |
try { |
178 |
ds = DataSourceFactory.createRandomDataSource(name);
|
|
178 |
ds = LayerFactory.getDataSourceFactory().createRandomDataSource(name);
|
|
179 | 179 |
} catch (NoSuchTableException e) { |
180 | 180 |
throw new DriverLoadException(e); |
181 | 181 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/LayerFactory.java | ||
---|---|---|
85 | 85 |
private static String driversPath = "../FMap 03/drivers"; |
86 | 86 |
private static DriverManager driverManager; |
87 | 87 |
|
88 |
private static DataSourceFactory dataSourceFactory = new DataSourceFactory(); |
|
89 |
|
|
88 | 90 |
/** |
89 | 91 |
* Map en el que se guarda para cada fuente de datos a?adida al sistema, el |
90 | 92 |
* adaptador que la maneja. Ha de ser un TreeMap ya que esta clase define |
... | ... | |
383 | 385 |
logger.error(failures[i]); |
384 | 386 |
} |
385 | 387 |
|
386 |
DataSourceFactory.setDriverManager(driverManager);
|
|
388 |
dataSourceFactory.setDriverManager(driverManager);
|
|
387 | 389 |
} |
388 | 390 |
} |
389 | 391 |
|
... | ... | |
396 | 398 |
LayerFactory.driversPath = path; |
397 | 399 |
initializeDriverManager(); |
398 | 400 |
} |
401 |
|
|
402 |
/** |
|
403 |
* @return Returns the dataSourceFactory. |
|
404 |
*/ |
|
405 |
public static DataSourceFactory getDataSourceFactory() { |
|
406 |
return dataSourceFactory; |
|
407 |
} |
|
399 | 408 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/MemoryLabelAdapter.java | ||
---|---|---|
92 | 92 |
} |
93 | 93 |
|
94 | 94 |
/* (non-Javadoc) |
95 |
* @see com.iver.cit.gvsig.fmap.layers.VectorialAdapter#changeRecordsetName(java.lang.String) |
|
96 |
*/ |
|
97 |
public void changeRecordsetName(String newName) throws DriverException { |
|
98 |
try { |
|
99 |
if (ds == null) { |
|
100 |
try { |
|
101 |
ds = getRecordset(newName); |
|
102 |
} catch (DriverLoadException e1) { |
|
103 |
throw new DriverException(e1); |
|
104 |
} |
|
105 |
} |
|
106 |
|
|
107 |
DataSourceFactory.changeDataSourceName(dataSourceName, newName); |
|
108 |
} catch (NoSuchTableException e) { |
|
109 |
throw new RuntimeException( |
|
110 |
"No existe la tabla que hemos creado????"); |
|
111 |
} |
|
112 |
|
|
113 |
dataSourceName = newName; |
|
114 |
} |
|
115 |
|
|
116 |
/* (non-Javadoc) |
|
117 | 95 |
* @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#start() |
118 | 96 |
*/ |
119 | 97 |
public void start() throws DriverIOException { |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/SelectableDataSource.java | ||
---|---|---|
92 | 92 |
public String getDBMS() { |
93 | 93 |
return dataSource.getDBMS(); |
94 | 94 |
} |
95 |
|
|
95 |
|
|
96 | 96 |
/** |
97 |
* Devuelve el driver de la capa. |
|
98 |
* |
|
99 |
* @return ReadDriver. |
|
100 |
*/ |
|
101 |
public ReadDriver getDriver() { |
|
102 |
return dataSource.getDriver(); |
|
103 |
} |
|
104 |
|
|
105 |
/** |
|
106 | 97 |
* Devuelve el n?mero de campos. |
107 | 98 |
* |
108 | 99 |
* @return N?mero de campos. |
... | ... | |
124 | 115 |
* @throws FieldNotFoundException |
125 | 116 |
*/ |
126 | 117 |
public int getFieldIndexByName(String arg0) |
127 |
throws DriverException, FieldNotFoundException {
|
|
118 |
throws DriverException { |
|
128 | 119 |
return dataSource.getFieldIndexByName(arg0); |
129 | 120 |
} |
130 | 121 |
|
... | ... | |
277 | 268 |
*/ |
278 | 269 |
public void setName(String name) { |
279 | 270 |
try { |
280 |
DataSourceFactory.changeDataSourceName(dataSource.getName(), name);
|
|
271 |
LayerFactory.getDataSourceFactory().changeDataSourceName(dataSource.getName(), name);
|
|
281 | 272 |
} catch (NoSuchTableException e) { |
282 | 273 |
throw new RuntimeException("No se encuentra la tabla????"); |
283 | 274 |
} |
... | ... | |
316 | 307 |
/** |
317 | 308 |
* @see com.hardcode.gdbms.engine.data.ReadDriver#getFieldType(int) |
318 | 309 |
*/ |
319 |
public Class getFieldType(int i) throws DriverException {
|
|
310 |
public int getFieldType(int i) throws DriverException {
|
|
320 | 311 |
return dataSource.getFieldType(i); |
321 | 312 |
} |
322 | 313 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/dgn/DGNDriver.java | ||
---|---|---|
582 | 582 |
/* (non-Javadoc) |
583 | 583 |
* @see com.hardcode.gdbms.engine.data.ReadDriver#getFieldType(int) |
584 | 584 |
*/ |
585 |
public Class getFieldType(int arg0) throws DriverException { |
|
586 |
// TODO Auto-generated method stub |
|
587 |
return null; |
|
585 |
public int getFieldType(int arg0) throws DriverException { |
|
586 |
throw new RuntimeException("por implementar"); |
|
588 | 587 |
} |
589 | 588 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/dxf/DXFDriver.java | ||
---|---|---|
308 | 308 |
/* (non-Javadoc) |
309 | 309 |
* @see com.hardcode.gdbms.engine.data.ReadDriver#getFieldType(int) |
310 | 310 |
*/ |
311 |
public Class getFieldType(int arg0) throws DriverException { |
|
312 |
// TODO Auto-generated method stub |
|
313 |
return null; |
|
311 |
public int getFieldType(int arg0) throws DriverException { |
|
312 |
throw new RuntimeException("por implementar"); |
|
314 | 313 |
} |
315 | 314 |
|
316 | 315 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/DefaultDBDriver.java | ||
---|---|---|
143 | 143 |
return FShape.MULTI; |
144 | 144 |
} |
145 | 145 |
|
146 |
public Class getFieldType(int idField) throws com.hardcode.gdbms.engine.data.DriverException
|
|
146 |
public int getFieldType(int idField) throws com.hardcode.gdbms.engine.data.DriverException
|
|
147 | 147 |
{ |
148 | 148 |
String str = ""; |
149 | 149 |
try { |
... | ... | |
151 | 151 |
// adem?s nos saltamos el campo de geometry |
152 | 152 |
str = metaData.getColumnClassName(i); |
153 | 153 |
if (metaData.getColumnType(i) == Types.VARCHAR) |
154 |
return Value.VARCHAR;
|
|
154 |
return Types.VARCHAR;
|
|
155 | 155 |
if (metaData.getColumnType(i) == Types.FLOAT) |
156 |
return Value.FLOAT;
|
|
156 |
return Types.FLOAT;
|
|
157 | 157 |
if (metaData.getColumnType(i) == Types.DOUBLE) |
158 |
return Value.DOUBLE;
|
|
158 |
return Types.DOUBLE;
|
|
159 | 159 |
if (metaData.getColumnType(i) == Types.INTEGER) |
160 |
return Value.INTEGER;
|
|
160 |
return Types.INTEGER;
|
|
161 | 161 |
if (metaData.getColumnType(i) == Types.BIGINT) |
162 |
return Value.BIGINT;
|
|
162 |
return Types.BIGINT;
|
|
163 | 163 |
if (metaData.getColumnType(i) == Types.BIT) |
164 |
return Value.BIT;
|
|
164 |
return Types.BIT;
|
|
165 | 165 |
if (metaData.getColumnType(i) == Types.DATE) |
166 |
return Value.DATE;
|
|
166 |
return Types.DATE;
|
|
167 | 167 |
} catch (SQLException e) { |
168 |
throw new com.hardcode.gdbms.engine.data.DriverException("Tipo no soportado: " + str);
|
|
168 |
throw new com.hardcode.gdbms.engine.data.DriverException(e);
|
|
169 | 169 |
} |
170 |
return null; |
|
171 |
|
|
170 |
throw new com.hardcode.gdbms.engine.data.DriverException("Tipo no soportado: " + str); |
|
172 | 171 |
} |
173 | 172 |
/** |
174 | 173 |
* Obtiene el valor que se encuentra en la fila y columna indicada |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/shp/DbaseFileHeaderNIO.java | ||
---|---|---|
78 | 78 |
import java.nio.channels.ReadableByteChannel; |
79 | 79 |
import java.nio.channels.WritableByteChannel; |
80 | 80 |
|
81 |
import java.sql.Types; |
|
81 | 82 |
import java.util.Calendar; |
82 | 83 |
import java.util.Date; |
83 | 84 |
import java.util.logging.Level; |
... | ... | |
771 | 772 |
try { |
772 | 773 |
for (int i = 0, ii = sds.getFieldCount(); i < ii; i++) { |
773 | 774 |
|
774 |
Class type = sds.getFieldType(i);
|
|
775 |
int type = sds.getFieldType(i);
|
|
775 | 776 |
String colName = sds.getFieldName(i); |
776 | 777 |
|
777 | 778 |
///int fieldLen = ((DBFDriver)sds.getDriver()).getFieldLength(i); |
... | ... | |
782 | 783 |
// fieldLen = 255; |
783 | 784 |
// } |
784 | 785 |
// @todo respect field length |
785 |
if ((type == Value.DOUBLE) ||
|
|
786 |
(type == Value.FLOAT) ||
|
|
787 |
(type == Value.INTEGER))
|
|
786 |
if ((type == Types.DOUBLE) ||
|
|
787 |
(type == Types.FLOAT) ||
|
|
788 |
(type == Types.INTEGER))
|
|
788 | 789 |
|
789 | 790 |
header.addColumn(colName, 'N', Math.min(fieldLen, 10), |
790 | 791 |
decimales); |
791 |
if (type == Value.DATE)
|
|
792 |
if (type == Types.DATE)
|
|
792 | 793 |
header.addColumn(colName, 'D', fieldLen, 0); |
793 |
if (type == Value.BIT)
|
|
794 |
if (type == Types.BIT)
|
|
794 | 795 |
header.addColumn(colName, 'L', 1, 0); |
795 |
if ((type == Value.VARCHAR) ||
|
|
796 |
(type == Value.CHAR) ||
|
|
797 |
(type == Value.LONGVARCHAR))
|
|
796 |
if ((type == Types.VARCHAR) ||
|
|
797 |
(type == Types.CHAR) ||
|
|
798 |
(type == Types.LONGVARCHAR))
|
|
798 | 799 |
header.addColumn(colName, 'C', Math.min(254, fieldLen), |
799 | 800 |
0); |
800 | 801 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/MemoryDriver.java | ||
---|---|---|
49 | 49 |
import java.awt.geom.Rectangle2D; |
50 | 50 |
import java.io.File; |
51 | 51 |
import java.io.IOException; |
52 |
import java.sql.Types; |
|
52 | 53 |
import java.util.ArrayList; |
53 | 54 |
import java.util.Date; |
54 | 55 |
|
... | ... | |
199 | 200 |
/** |
200 | 201 |
* @see com.hardcode.gdbms.engine.data.ReadDriver#getFieldType(int) |
201 | 202 |
*/ |
202 |
public Class getFieldType(int i) throws DriverException {
|
|
203 |
public int getFieldType(int i) throws DriverException {
|
|
203 | 204 |
// TODO: Revisar esto. Por ejemplo, el long |
204 | 205 |
|
205 | 206 |
if (m_TableModel.getColumnClass(i) == String.class) |
206 |
return Value.VARCHAR;
|
|
207 |
return Types.VARCHAR;
|
|
207 | 208 |
if (m_TableModel.getColumnClass(i) == Float.class) |
208 |
return Value.FLOAT;
|
|
209 |
return Types.FLOAT;
|
|
209 | 210 |
if (m_TableModel.getColumnClass(i) == Double.class) |
210 |
return Value.DOUBLE;
|
|
211 |
return Types.DOUBLE;
|
|
211 | 212 |
if (m_TableModel.getColumnClass(i) == Integer.class) |
212 |
return Value.INTEGER;
|
|
213 |
return Types.INTEGER;
|
|
213 | 214 |
if (m_TableModel.getColumnClass(i) == Long.class) |
214 |
return Value.INTEGER;
|
|
215 |
return Types.INTEGER;
|
|
215 | 216 |
if (m_TableModel.getColumnClass(i) == Boolean.class) |
216 |
return Value.BIT;
|
|
217 |
return Types.BIT;
|
|
217 | 218 |
if (m_TableModel.getColumnClass(i) == Date.class) |
218 |
return Value.DATE;
|
|
219 |
return Types.DATE;
|
|
219 | 220 |
|
220 | 221 |
|
221 | 222 |
// return m_TableModel.getColumnClass(i); |
Also available in: Unified diff