Revision 10627 trunk/libraries/libGDBMS/src/main/java/com/hardcode/gdbms/driver/shapefile/SHPDriver.java
SHPDriver.java | ||
---|---|---|
5 | 5 |
import java.io.IOException; |
6 | 6 |
|
7 | 7 |
import com.hardcode.gdbms.driver.dbf.DBFDriver; |
8 |
import com.hardcode.gdbms.driver.exceptions.CloseDriverException; |
|
9 |
import com.hardcode.gdbms.driver.exceptions.OpenDriverException; |
|
10 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
11 |
import com.hardcode.gdbms.driver.exceptions.WriteDriverException; |
|
8 | 12 |
import com.hardcode.gdbms.engine.data.DataSourceFactory; |
9 | 13 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
10 | 14 |
import com.hardcode.gdbms.engine.data.driver.SpatialFileDriver; |
... | ... | |
17 | 21 |
import com.vividsolutions.jts.geom.GeometryFactory; |
18 | 22 |
|
19 | 23 |
/** |
20 |
*
|
|
24 |
* |
|
21 | 25 |
*/ |
22 | 26 |
public class SHPDriver implements SpatialFileDriver{ |
23 | 27 |
|
24 | 28 |
private DBFDriver dbfDriver; |
25 | 29 |
private SHP shp; |
26 | 30 |
private String prefix; |
27 |
|
|
31 |
|
|
28 | 32 |
/** |
29 | 33 |
* @see com.hardcode.gdbms.engine.data.driver.FileDriver#open(java.io.File) |
30 | 34 |
*/ |
31 |
public void open(File file) throws IOException {
|
|
35 |
public void open(File file) throws OpenDriverException {
|
|
32 | 36 |
String fileName = file.getAbsolutePath().trim(); |
33 | 37 |
prefix = fileName.substring(0, fileName.length() - 4); |
34 | 38 |
dbfDriver = new DBFDriver(); |
... | ... | |
40 | 44 |
/** |
41 | 45 |
* @see com.hardcode.gdbms.engine.data.driver.FileDriver#close() |
42 | 46 |
*/ |
43 |
public void close() throws IOException {
|
|
47 |
public void close() throws CloseDriverException {
|
|
44 | 48 |
dbfDriver.close(); |
45 | 49 |
shp.close(); |
46 | 50 |
} |
... | ... | |
55 | 59 |
/** |
56 | 60 |
* @see com.hardcode.gdbms.engine.data.driver.FileDriver#writeFile(com.hardcode.gdbms.engine.data.file.FileDataWare, java.io.File) |
57 | 61 |
*/ |
58 |
public void writeFile(FileDataWare dataWare) throws DriverException { |
|
62 |
public void writeFile(FileDataWare dataWare) throws WriteDriverException {
|
|
59 | 63 |
throw new UnsupportedOperationException(); |
60 | 64 |
} |
61 | 65 |
|
62 | 66 |
/** |
63 | 67 |
* @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldValue(long, int) |
64 | 68 |
*/ |
65 |
public Value getFieldValue(long rowIndex, int fieldId) throws DriverException { |
|
69 |
public Value getFieldValue(long rowIndex, int fieldId) throws ReadDriverException {
|
|
66 | 70 |
return dbfDriver.getFieldValue(rowIndex, fieldId); |
67 | 71 |
} |
68 | 72 |
|
69 | 73 |
/** |
70 | 74 |
* @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldCount() |
71 | 75 |
*/ |
72 |
public int getFieldCount() throws DriverException { |
|
76 |
public int getFieldCount() throws ReadDriverException {
|
|
73 | 77 |
return dbfDriver.getFieldCount(); |
74 | 78 |
} |
75 | 79 |
|
76 | 80 |
/** |
77 | 81 |
* @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldName(int) |
78 | 82 |
*/ |
79 |
public String getFieldName(int fieldId) throws DriverException { |
|
83 |
public String getFieldName(int fieldId) throws ReadDriverException {
|
|
80 | 84 |
return dbfDriver.getFieldName(fieldId); |
81 | 85 |
} |
82 | 86 |
|
83 | 87 |
/** |
84 | 88 |
* @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getRowCount() |
85 | 89 |
*/ |
86 |
public long getRowCount() throws DriverException { |
|
90 |
public long getRowCount() throws ReadDriverException {
|
|
87 | 91 |
return dbfDriver.getRowCount(); |
88 | 92 |
} |
89 | 93 |
|
90 | 94 |
/** |
91 | 95 |
* @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldType(int) |
92 | 96 |
*/ |
93 |
public int getFieldType(int i) throws DriverException { |
|
97 |
public int getFieldType(int i) throws ReadDriverException {
|
|
94 | 98 |
return dbfDriver.getFieldType(i); |
95 | 99 |
} |
96 | 100 |
|
... | ... | |
109 | 113 |
} |
110 | 114 |
|
111 | 115 |
/** |
112 |
* @throws DriverException |
|
113 | 116 |
* @see com.hardcode.gdbms.engine.data.driver.SpatialDriver#getGeometry(long) |
114 | 117 |
*/ |
115 |
public Geometry getGeometry(long rowIndex) throws DriverException { |
|
118 |
public Geometry getGeometry(long rowIndex) throws ReadDriverException {
|
|
116 | 119 |
try { |
117 | 120 |
return new GeometryImpl(shp.getGeometry((int) rowIndex)); |
118 | 121 |
} catch (IOException e) { |
119 |
throw new DriverException(e);
|
|
122 |
throw new ReadDriverException(getName(),e);
|
|
120 | 123 |
} |
121 | 124 |
} |
122 | 125 |
|
123 | 126 |
/** |
124 | 127 |
* @see com.hardcode.gdbms.engine.data.driver.SpatialDriver#getJTSGeometry(long) |
125 | 128 |
*/ |
126 |
public com.vividsolutions.jts.geom.Geometry getJTSGeometry(long rowIndex) throws DriverException { |
|
129 |
public com.vividsolutions.jts.geom.Geometry getJTSGeometry(long rowIndex) throws ReadDriverException {
|
|
127 | 130 |
try { |
128 | 131 |
return shp.getGeometry((int) rowIndex).getJTSGeometry(); |
129 | 132 |
} catch (IOException e) { |
130 |
throw new DriverException(e);
|
|
133 |
throw new ReadDriverException(getName(),e);
|
|
131 | 134 |
} |
132 | 135 |
} |
133 | 136 |
|
134 |
public void createSource(String path, String[] fieldNames, int[] fieldTypes) throws IOException {
|
|
137 |
public void createSource(String path, String[] fieldNames, int[] fieldTypes) throws ReadDriverException {
|
|
135 | 138 |
throw new UnsupportedOperationException(); |
136 | 139 |
} |
137 | 140 |
|
138 | 141 |
public void setDataSourceFactory(DataSourceFactory dsf) { |
139 | 142 |
} |
140 | 143 |
|
141 |
public int getFieldWidth(int i) throws DriverException { |
|
144 |
public int getFieldWidth(int i) throws ReadDriverException {
|
|
142 | 145 |
return dbfDriver.getFieldWidth(i); |
143 | 146 |
} |
144 |
|
|
145 |
|
|
146 | 147 |
|
148 |
|
|
149 |
|
|
147 | 150 |
} |
Also available in: Unified diff