Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libDataSourceBaseDrivers / src / org / gvsig / data / datastores / vectorial / file / dgn / DGNDataExplorer.java @ 20607

History | View | Annotate | Download (2.23 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.INewDataStoreParameters;
9
import org.gvsig.data.datastores.vectorial.file.DataExplorerFile;
10
import org.gvsig.data.datastores.vectorial.file.exception.FileNotFoundException;
11
import org.gvsig.data.exception.InitializeWriterException;
12
import org.gvsig.data.exception.OpenException;
13
import org.gvsig.data.exception.ReadException;
14
import org.gvsig.data.vectorial.IFeatureType;
15
import org.gvsig.data.vectorial.INewFeatureStoreParameters;
16

    
17
public class DGNDataExplorer extends DataExplorerFile {
18

    
19
    public static String DATASOURCE_NAME="DGNDataExplorer";
20

    
21
        protected DGNDataExplorerParameters parameters;
22
        protected File path;
23

    
24

    
25
        public IDataStoreParameters[] list() throws ReadException {
26
                if (!this.path.exists()){
27
                        new FileNotFoundException(this.getName()+": Path not found '"+this.path+"'",new Exception());
28
                }
29
//                DataManager dsm=DataManager.getManager();
30

    
31
                String files[] = this.path.list();
32
                int i;
33
                File theFile;
34
                ArrayList fileList = new ArrayList();
35
                IDataStoreParameters dsp = null;
36

    
37
                for (i=0;i<files.length;i++){
38
                        theFile = new File(this.path,files[i]);
39

    
40
                        if (this.isValid(theFile)){
41
                                dsp= this.newParameter(theFile);
42

    
43

    
44
                                fileList.add(dsp);
45

    
46
                        }
47

    
48

    
49
                }
50
                IDataStoreParameters[] x = new IDataStoreParameters[1];
51
                x[0]=dsp;
52
                return (IDataStoreParameters[])fileList.toArray(x);
53
        }
54

    
55
        protected IDataStoreParameters newParameter(File file){
56
                DGNStoreParameters param = new DGNStoreParameters();
57
                param.setFile(file);
58
                return param;
59
        }
60

    
61
        protected boolean isValid(String file){
62
                return this.isValid(new File(file));
63

    
64
        }
65

    
66
        protected boolean isValid(File file){
67
                if (!file.exists()){
68
                        return false;
69
                }
70
                return (file.getName().toLowerCase().endsWith(".dgn"));
71
        }
72

    
73
        public String getName() {
74
                return this.DATASOURCE_NAME;
75
        }
76

    
77
        public void init(IDataExplorerParameters parameters) {
78
                this.parameters = (DGNDataExplorerParameters)parameters;
79
                this.path = this.parameters.getSource();
80
        }
81

    
82
        public IFeatureType[] getFeatureTypes(IDataStoreParameters dsp) throws ReadException {
83
                return new IFeatureType[] {DGNStore.newFeatureType()};
84
        }
85

    
86

    
87

    
88
}