Revision 10627 trunk/libraries/libGDBMS/src/main/java/com/hardcode/gdbms/engine/spatial/fmap/AbstractFMapFileDriver.java
AbstractFMapFileDriver.java | ||
---|---|---|
17 | 17 |
* |
18 | 18 |
* You should have received a copy of the GNU General Public License |
19 | 19 |
* along with this program; if not, write to the Free Software |
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
21 | 21 |
USA. |
22 | 22 |
* |
23 | 23 |
* For more information, contact: |
... | ... | |
46 | 46 |
|
47 | 47 |
import java.awt.geom.Rectangle2D; |
48 | 48 |
import java.io.File; |
49 |
import java.io.IOException; |
|
50 | 49 |
|
51 | 50 |
import com.hardcode.driverManager.DriverLoadException; |
51 |
import com.hardcode.gdbms.driver.exceptions.CloseDriverException; |
|
52 |
import com.hardcode.gdbms.driver.exceptions.InitializeDriverException; |
|
53 |
import com.hardcode.gdbms.driver.exceptions.OpenDriverException; |
|
54 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
55 |
import com.hardcode.gdbms.driver.exceptions.WriteDriverException; |
|
52 | 56 |
import com.hardcode.gdbms.engine.data.DataSource; |
53 | 57 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
54 | 58 |
import com.hardcode.gdbms.engine.data.driver.SpatialFileDriver; |
55 | 59 |
import com.hardcode.gdbms.engine.data.file.FileDataWare; |
56 | 60 |
import com.hardcode.gdbms.engine.spatial.Geometry; |
57 | 61 |
import com.hardcode.gdbms.engine.values.Value; |
62 |
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException; |
|
58 | 63 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
59 | 64 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
60 | 65 |
import com.iver.cit.gvsig.fmap.core.v02.FConverter; |
... | ... | |
69 | 74 |
private DataSource dataSource; |
70 | 75 |
|
71 | 76 |
/** |
77 |
* @throws OpenDriverException TODO |
|
72 | 78 |
* @see com.hardcode.gdbms.engine.data.driver.FileDriver#open(java.io.File) |
73 | 79 |
*/ |
74 |
public void open(VectorialFileAdapter adapter) throws IOException {
|
|
80 |
public void open(VectorialFileAdapter adapter) throws OpenDriverException {
|
|
75 | 81 |
try { |
76 | 82 |
this.adapter = adapter; |
77 | 83 |
adapter.start(); |
78 | 84 |
dataSource = adapter.getRecordset(); |
79 | 85 |
dataSource.start(); |
80 |
} catch (DriverIOException e) { |
|
81 |
throw new IOException(e.getMessage()); |
|
82 |
} catch (DriverException e) { |
|
83 |
throw new IOException(e.getMessage()); |
|
86 |
} catch (ReadDriverException e) { |
|
87 |
throw new OpenDriverException(getName(),e); |
|
84 | 88 |
} catch (DriverLoadException e) { |
85 |
throw new IOException(e.getMessage());
|
|
89 |
throw new OpenDriverException(getName(),e);
|
|
86 | 90 |
} |
87 | 91 |
} |
88 | 92 |
|
89 | 93 |
/** |
90 | 94 |
* @see com.hardcode.gdbms.engine.data.driver.FileDriver#close() |
91 | 95 |
*/ |
92 |
public void close() throws IOException {
|
|
96 |
public void close() throws CloseDriverException {
|
|
93 | 97 |
try{ |
94 | 98 |
adapter.stop(); |
95 | 99 |
dataSource.stop(); |
96 |
} catch (DriverIOException e) { |
|
97 |
throw new IOException(e.getMessage()); |
|
98 |
} catch (DriverException e) { |
|
99 |
throw new IOException(e.getMessage()); |
|
100 |
} catch (ReadDriverException e) { |
|
101 |
throw new CloseDriverException(getName(),e); |
|
100 | 102 |
} |
101 | 103 |
} |
102 | 104 |
|
103 | 105 |
/** |
104 | 106 |
* @see com.hardcode.gdbms.engine.data.driver.FileDriver#writeFile(com.hardcode.gdbms.engine.data.file.FileDataWare, java.io.File) |
105 | 107 |
*/ |
106 |
public void writeFile(FileDataWare dataWare) throws DriverException { |
|
108 |
public void writeFile(FileDataWare dataWare) throws WriteDriverException {
|
|
107 | 109 |
} |
108 | 110 |
|
109 | 111 |
/** |
110 | 112 |
* @see com.hardcode.gdbms.engine.data.driver.FileDriver#createSource(java.lang.String, java.lang.String[], int[]) |
111 | 113 |
*/ |
112 |
public void createSource(String path, String[] fieldNames, int[] fieldTypes) throws IOException {
|
|
114 |
public void createSource(String path, String[] fieldNames, int[] fieldTypes) throws ReadDriverException {
|
|
113 | 115 |
} |
114 | 116 |
|
115 | 117 |
/** |
116 | 118 |
* @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldValue(long, int) |
117 | 119 |
*/ |
118 |
public Value getFieldValue(long rowIndex, int fieldId) throws DriverException { |
|
120 |
public Value getFieldValue(long rowIndex, int fieldId) throws ReadDriverException {
|
|
119 | 121 |
return dataSource.getFieldValue(rowIndex, fieldId); |
120 | 122 |
} |
121 | 123 |
|
122 | 124 |
/** |
123 | 125 |
* @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldCount() |
124 | 126 |
*/ |
125 |
public int getFieldCount() throws DriverException { |
|
127 |
public int getFieldCount() throws ReadDriverException {
|
|
126 | 128 |
return dataSource.getFieldCount(); |
127 | 129 |
} |
128 | 130 |
|
129 | 131 |
/** |
130 | 132 |
* @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldName(int) |
131 | 133 |
*/ |
132 |
public String getFieldName(int fieldId) throws DriverException { |
|
134 |
public String getFieldName(int fieldId) throws ReadDriverException {
|
|
133 | 135 |
return dataSource.getFieldName(fieldId); |
134 | 136 |
} |
135 | 137 |
|
136 | 138 |
/** |
137 | 139 |
* @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getRowCount() |
138 | 140 |
*/ |
139 |
public long getRowCount() throws DriverException { |
|
141 |
public long getRowCount() throws ReadDriverException {
|
|
140 | 142 |
return dataSource.getRowCount(); |
141 | 143 |
} |
142 | 144 |
|
143 | 145 |
/** |
144 | 146 |
* @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldType(int) |
145 | 147 |
*/ |
146 |
public int getFieldType(int i) throws DriverException { |
|
148 |
public int getFieldType(int i) throws ReadDriverException {
|
|
147 | 149 |
return dataSource.getFieldType(i); |
148 | 150 |
} |
149 | 151 |
|
150 | 152 |
/** |
151 | 153 |
* @see com.hardcode.gdbms.engine.data.driver.SpatialDriver#getFullExtent() |
152 | 154 |
*/ |
153 |
public Rectangle2D getFullExtent() throws DriverException { |
|
154 |
try { |
|
155 |
return adapter.getFullExtent(); |
|
156 |
} catch (DriverIOException e) { |
|
157 |
throw new DriverException(e); |
|
158 |
} |
|
155 |
public Rectangle2D getFullExtent() throws ReadDriverException { |
|
156 |
return adapter.getFullExtent(); |
|
159 | 157 |
} |
160 | 158 |
|
161 | 159 |
/** |
162 | 160 |
* @see com.hardcode.gdbms.engine.data.driver.SpatialDriver#getGeometry(long) |
163 | 161 |
*/ |
164 |
public Geometry getGeometry(long rowIndex) throws DriverException { |
|
162 |
public Geometry getGeometry(long rowIndex) throws ReadDriverException {
|
|
165 | 163 |
try { |
166 | 164 |
return new FMapGeometry(adapter.getShape((int)rowIndex)); |
167 |
} catch (DriverIOException e) {
|
|
168 |
throw new DriverException(e);
|
|
165 |
} catch (ExpansionFileReadException e) {
|
|
166 |
throw new ReadDriverException(getName(),e);
|
|
169 | 167 |
} |
170 | 168 |
} |
171 | 169 |
|
172 | 170 |
/** |
173 | 171 |
* @see com.hardcode.gdbms.engine.data.driver.SpatialDriver#getJTSGeometry(long) |
174 | 172 |
*/ |
175 |
public com.vividsolutions.jts.geom.Geometry getJTSGeometry(long rowIndex) throws DriverException { |
|
173 |
public com.vividsolutions.jts.geom.Geometry getJTSGeometry(long rowIndex) throws ReadDriverException {
|
|
176 | 174 |
try { |
177 | 175 |
IGeometry ig = adapter.getShape((int)rowIndex); |
178 | 176 |
GeneralPathX gpx = new GeneralPathX(); |
179 | 177 |
gpx.append(ig.getPathIterator(null), true); |
180 | 178 |
return FConverter.java2d_to_jts(new FShapeGeneralPathX(gpx, ig.getGeometryType())); |
181 |
} catch (DriverIOException e) {
|
|
182 |
throw new DriverException(e);
|
|
179 |
} catch (ExpansionFileReadException e) {
|
|
180 |
throw new ReadDriverException(getName(),e);
|
|
183 | 181 |
} |
184 | 182 |
} |
185 |
|
|
183 |
|
|
186 | 184 |
protected VectorialAdapter getAdapter() { |
187 | 185 |
return adapter; |
188 | 186 |
} |
189 |
|
|
187 |
|
|
190 | 188 |
protected DataSource getDataSource() { |
191 | 189 |
return dataSource; |
192 | 190 |
} |
193 | 191 |
/** |
194 | 192 |
* @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldWidth(int) |
195 | 193 |
*/ |
196 |
public int getFieldWidth(int i) throws DriverException { |
|
194 |
public int getFieldWidth(int i) throws ReadDriverException {
|
|
197 | 195 |
return dataSource.getFieldWidth(i); |
198 | 196 |
} |
199 | 197 |
|
Also available in: Unified diff