Revision 43400 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.csv/src/main/java/org/gvsig/fmap/dal/store/csv/CSVFilesystemServerProvider.java
CSVFilesystemServerProvider.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import java.io.File; |
27 | 27 |
|
28 |
import org.gvsig.fmap.dal.DALLocator; |
|
29 |
import org.gvsig.fmap.dal.DataManager; |
|
30 | 28 |
import org.gvsig.fmap.dal.DataServerExplorer; |
31 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
32 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
|
33 |
import org.gvsig.fmap.dal.exception.CreateException; |
|
34 |
import org.gvsig.fmap.dal.exception.DataException; |
|
35 |
import org.gvsig.fmap.dal.exception.FileNotFoundException; |
|
36 |
import org.gvsig.fmap.dal.exception.RemoveException; |
|
37 | 29 |
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer; |
38 |
import org.gvsig.fmap.dal.resource.spi.ResourceProvider; |
|
39 | 30 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.impl.AbstractFilesystemServerExplorerProvider; |
40 | 31 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider; |
41 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices; |
|
42 | 32 |
|
43 | 33 |
public class CSVFilesystemServerProvider extends AbstractFilesystemServerExplorerProvider |
44 | 34 |
implements FilesystemServerExplorerProvider, ResourceConsumer { |
45 | 35 |
|
46 |
private FilesystemServerExplorerProviderServices serverExplorer; |
|
47 |
|
|
36 |
@Override |
|
48 | 37 |
public String getDataStoreProviderName() { |
49 | 38 |
return CSVStoreProvider.NAME; |
50 | 39 |
} |
51 | 40 |
|
41 |
@Override |
|
52 | 42 |
public int getMode() { |
53 | 43 |
return DataServerExplorer.MODE_FEATURE | DataServerExplorer.MODE_GEOMETRY; |
54 | 44 |
} |
55 | 45 |
|
46 |
@Override |
|
56 | 47 |
public boolean accept(File pathname) { |
57 | 48 |
return (pathname.getName().toLowerCase().endsWith(".csv")); |
58 | 49 |
} |
59 | 50 |
|
51 |
@Override |
|
60 | 52 |
public String getDescription() { |
61 | 53 |
return CSVStoreProvider.DESCRIPTION; |
62 | 54 |
} |
63 | 55 |
|
64 |
public DataStoreParameters getParameters(File file) throws DataException { |
|
65 |
DataManager manager = DALLocator.getDataManager(); |
|
66 |
CSVStoreParameters params = (CSVStoreParameters) manager |
|
67 |
.createStoreParameters(this |
|
68 |
.getDataStoreProviderName()); |
|
69 |
params.setFile(file); |
|
70 |
return params; |
|
71 |
} |
|
72 | 56 |
|
73 |
public boolean canCreate() { |
|
74 |
return false; |
|
75 |
} |
|
76 |
|
|
77 |
public boolean canCreate(NewDataStoreParameters parameters) { |
|
78 |
throw new UnsupportedOperationException(); |
|
79 |
} |
|
80 |
|
|
81 |
public void create(NewDataStoreParameters parameters, boolean overwrite) |
|
82 |
throws CreateException { |
|
83 |
throw new UnsupportedOperationException(); |
|
84 |
} |
|
85 |
|
|
86 |
public NewDataStoreParameters getCreateParameters() throws DataException { |
|
87 |
throw new UnsupportedOperationException(); |
|
88 |
} |
|
89 |
|
|
90 |
public void initialize( |
|
91 |
FilesystemServerExplorerProviderServices serverExplorer) { |
|
92 |
this.serverExplorer = serverExplorer; |
|
93 |
} |
|
94 |
|
|
95 |
public void remove(DataStoreParameters parameters) throws RemoveException { |
|
96 |
File file = ((CSVStoreParameters) parameters).getFile(); |
|
97 |
if (!file.exists()) { |
|
98 |
throw new RemoveException(this.getDataStoreProviderName(), |
|
99 |
new FileNotFoundException(file)); |
|
100 |
} |
|
101 |
if (!file.delete()) { |
|
102 |
// FIXME throws ??? |
|
103 |
} |
|
104 |
|
|
105 |
} |
|
106 |
|
|
107 |
public boolean closeResourceRequested(ResourceProvider resource) { |
|
108 |
// while it is using a resource anyone can't close it |
|
109 |
return false; |
|
110 |
} |
|
111 |
|
|
112 |
public void resourceChanged(ResourceProvider resource) { |
|
113 |
//Do nothing |
|
114 |
|
|
115 |
} |
|
116 |
|
|
117 |
|
|
118 | 57 |
} |
Also available in: Unified diff