svn-gvsig-desktop / trunk / libraries / libFMap_dataFile / src / org / gvsig / data / datastores / vectorial / file / dgn / DGNDataExplorer.java @ 20744
History | View | Annotate | Download (2.01 KB)
1 |
package org.gvsig.data.datastores.vectorial.file.dgn; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
import java.util.ArrayList; |
5 |
|
6 |
import org.gvsig.data.IDataExplorerParameters; |
7 |
import org.gvsig.data.IDataStoreParameters; |
8 |
import org.gvsig.data.datastores.vectorial.file.FileExplorer; |
9 |
import org.gvsig.data.datastores.vectorial.file.exception.FileNotFoundException; |
10 |
import org.gvsig.data.exception.ReadException; |
11 |
import org.gvsig.data.vectorial.IFeatureType; |
12 |
|
13 |
public class DGNDataExplorer extends FileExplorer { |
14 |
|
15 |
public static String DATASOURCE_NAME="DGNDataExplorer"; |
16 |
|
17 |
protected DGNDataExplorerParameters parameters;
|
18 |
protected File path; |
19 |
|
20 |
|
21 |
public IDataStoreParameters[] list() throws ReadException { |
22 |
if (!this.path.exists()){ |
23 |
new FileNotFoundException(this.getName()+": Path not found '"+this.path+"'",new Exception()); |
24 |
} |
25 |
// DataManager dsm=DataManager.getManager();
|
26 |
|
27 |
String files[] = this.path.list(); |
28 |
int i;
|
29 |
File theFile;
|
30 |
ArrayList fileList = new ArrayList(); |
31 |
IDataStoreParameters dsp = null;
|
32 |
|
33 |
for (i=0;i<files.length;i++){ |
34 |
theFile = new File(this.path,files[i]); |
35 |
|
36 |
if (this.isValid(theFile)){ |
37 |
dsp= this.newParameter(theFile);
|
38 |
|
39 |
|
40 |
fileList.add(dsp); |
41 |
|
42 |
} |
43 |
|
44 |
|
45 |
} |
46 |
IDataStoreParameters[] x = new IDataStoreParameters[1]; |
47 |
x[0]=dsp;
|
48 |
return (IDataStoreParameters[])fileList.toArray(x); |
49 |
} |
50 |
|
51 |
protected IDataStoreParameters newParameter(File file){ |
52 |
DGNStoreParameters param = new DGNStoreParameters();
|
53 |
param.setFile(file); |
54 |
return param;
|
55 |
} |
56 |
|
57 |
protected boolean isValid(String file){ |
58 |
return this.isValid(new File(file)); |
59 |
|
60 |
} |
61 |
|
62 |
protected boolean isValid(File file){ |
63 |
if (!file.exists()){
|
64 |
return false; |
65 |
} |
66 |
return (file.getName().toLowerCase().endsWith(".dgn")); |
67 |
} |
68 |
|
69 |
public String getName() { |
70 |
return DATASOURCE_NAME;
|
71 |
} |
72 |
|
73 |
public void init(IDataExplorerParameters parameters) { |
74 |
this.parameters = (DGNDataExplorerParameters)parameters;
|
75 |
this.path = this.parameters.getSource(); |
76 |
} |
77 |
|
78 |
public IFeatureType[] getFeatureTypes(IDataStoreParameters dsp) throws ReadException { |
79 |
return new IFeatureType[] {DGNStore.newFeatureType()}; |
80 |
} |
81 |
|
82 |
|
83 |
|
84 |
} |