svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.api / src / main / java / org / gvsig / fmap / dal / DataServerExplorer.java @ 44259
History | View | Annotate | Download (6.32 KB)
1 | 40559 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | *
|
||
4 | * Copyright (C) 2007-2013 gvSIG Association.
|
||
5 | *
|
||
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 3
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
19 | * MA 02110-1301, USA.
|
||
20 | *
|
||
21 | * For any additional information, do not hesitate to contact us
|
||
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | */
|
||
24 | 40435 | jjdelcerro | package org.gvsig.fmap.dal; |
25 | |||
26 | 44160 | jjdelcerro | import java.io.Closeable; |
27 | 42879 | jjdelcerro | import java.io.File; |
28 | 44160 | jjdelcerro | import java.io.IOException; |
29 | import java.io.InputStream; |
||
30 | import java.io.OutputStream; |
||
31 | 44189 | jjdelcerro | import java.net.URL; |
32 | 40435 | jjdelcerro | import java.util.List; |
33 | |||
34 | import org.gvsig.fmap.dal.exception.DataException; |
||
35 | 44189 | jjdelcerro | import static org.gvsig.tools.dataTypes.DataTypes.URL; |
36 | 40435 | jjdelcerro | import org.gvsig.tools.dispose.Disposable; |
37 | 44253 | jjdelcerro | import org.gvsig.tools.util.ResourcesStorage.Resource; |
38 | 40435 | jjdelcerro | |
39 | /**
|
||
40 | * DataServerExplorer is an abstraction for any type of data server. It allows
|
||
41 | * connecting to the server and browsing its contents.
|
||
42 | *
|
||
43 | * More specifically, this interface provides a list of the available data
|
||
44 | * stores in a server.
|
||
45 | */
|
||
46 | 43020 | jjdelcerro | public interface DataServerExplorer extends Disposable, DataFactoryUnit { |
47 | 40435 | jjdelcerro | |
48 | 44253 | jjdelcerro | public interface DataResource extends Resource { |
49 | @Override
|
||
50 | 44189 | jjdelcerro | public URL getURL(); |
51 | |||
52 | 44253 | jjdelcerro | @Override
|
53 | 44160 | jjdelcerro | public boolean exists(); |
54 | |||
55 | 44253 | jjdelcerro | @Override
|
56 | 44160 | jjdelcerro | public InputStream asInputStream() throws IOException; |
57 | |||
58 | 44253 | jjdelcerro | @Override
|
59 | 44160 | jjdelcerro | public OutputStream asOutputStream() throws IOException; |
60 | |||
61 | 44253 | jjdelcerro | @Override
|
62 | 44160 | jjdelcerro | public void close(); |
63 | } |
||
64 | |||
65 | 44157 | jjdelcerro | /**
|
66 | * Returns the DataServerExplorer's name
|
||
67 | *
|
||
68 | * @return String containing this DataServerExplorer's name
|
||
69 | */
|
||
70 | public String getProviderName(); |
||
71 | 40435 | jjdelcerro | |
72 | 44157 | jjdelcerro | /**
|
73 | * Indicates whether this DataServerExplorer can create a new DataStore in
|
||
74 | * the server.
|
||
75 | *
|
||
76 | * @return true if this DataServerExplorer can be created or false
|
||
77 | * otherwise.
|
||
78 | */
|
||
79 | public boolean canAdd(); |
||
80 | 40435 | jjdelcerro | |
81 | 44157 | jjdelcerro | /**
|
82 | * Indicates whether this DataServerExplorer can create a new DataStore in
|
||
83 | * the server, given the store name.
|
||
84 | *
|
||
85 | * @param storeName store name.
|
||
86 | *
|
||
87 | * @return true if this DataServerExplorer can create a new store or false
|
||
88 | * otherwise.
|
||
89 | *
|
||
90 | * @throws DataException
|
||
91 | */
|
||
92 | public boolean canAdd(String storeName) |
||
93 | throws DataException;
|
||
94 | 40435 | jjdelcerro | |
95 | 44157 | jjdelcerro | /**
|
96 | * Provides a list of available stores in the server.
|
||
97 | *
|
||
98 | * @return list of DataStoreParameters
|
||
99 | *
|
||
100 | * @throws DataException
|
||
101 | */
|
||
102 | public List list() throws DataException; |
||
103 | 40435 | jjdelcerro | |
104 | 44157 | jjdelcerro | public DataStoreParameters get(String name) throws DataException; |
105 | 40435 | jjdelcerro | |
106 | 44157 | jjdelcerro | public static final int MODE_ALL = 0; |
107 | public static final int MODE_FEATURE = 1; |
||
108 | public static final int MODE_GEOMETRY = 2; |
||
109 | public static final int MODE_RASTER = 4; |
||
110 | 40435 | jjdelcerro | |
111 | 44157 | jjdelcerro | /**
|
112 | * Provides a list of available stores in the server of a type.
|
||
113 | *
|
||
114 | * @param mode , filter store from a type: {@link #MODE_ALL},
|
||
115 | * {@link #MODE_FEATURE}, {@link #MODE_FEATURE_GEOMETRY},
|
||
116 | * {@link #MODE_RASTER}
|
||
117 | *
|
||
118 | * @return list of DataStoreParameters
|
||
119 | *
|
||
120 | * @throws DataException
|
||
121 | */
|
||
122 | public List list(int mode) throws DataException; |
||
123 | 40435 | jjdelcerro | |
124 | 44157 | jjdelcerro | /**
|
125 | * Creates a new DataStore in this server.
|
||
126 | *
|
||
127 | * @param parameters , an instance of DataStoreParameters from
|
||
128 | * {@link DataServerExplorer#getAddParameters(String)} that describes the
|
||
129 | * new DataStore.
|
||
130 | * @param overwrite if the store already exists
|
||
131 | *
|
||
132 | * @return true if the DataStoreParameters were successfully added, false
|
||
133 | * otherwise.
|
||
134 | *
|
||
135 | * @throws DataException
|
||
136 | */
|
||
137 | public boolean add(String provider, NewDataStoreParameters parameters, boolean overwrite) |
||
138 | throws DataException;
|
||
139 | 40435 | jjdelcerro | |
140 | 44157 | jjdelcerro | /**
|
141 | * Removes a store from the server given its DataStoreParameters. If the
|
||
142 | * store is a file then this method deletes the file, if it is a table in a
|
||
143 | * database then this method drops the table, and so on.
|
||
144 | *
|
||
145 | * @param parameters
|
||
146 | * @throws DataException
|
||
147 | */
|
||
148 | void remove(DataStoreParameters parameters) throws DataException; |
||
149 | 40435 | jjdelcerro | |
150 | 44157 | jjdelcerro | /**
|
151 | * Given the store's name, returns its parameters for creation.
|
||
152 | *
|
||
153 | * @param storeName
|
||
154 | *
|
||
155 | * @return parameters to create a store
|
||
156 | *
|
||
157 | * @throws DataException
|
||
158 | */
|
||
159 | public NewDataStoreParameters getAddParameters(String storeName) |
||
160 | throws DataException;
|
||
161 | 40435 | jjdelcerro | |
162 | 44157 | jjdelcerro | /**
|
163 | * Returns this DataServerExplorer parameters
|
||
164 | *
|
||
165 | * @return an instance of DataServerExplorerParameters containing this
|
||
166 | * DataServerExplorer parameters.
|
||
167 | */
|
||
168 | public DataServerExplorerParameters getParameters();
|
||
169 | 40435 | jjdelcerro | |
170 | 44157 | jjdelcerro | /**
|
171 | * Return the list of provider names that this server allow.
|
||
172 | *
|
||
173 | * @return List of provider names
|
||
174 | */
|
||
175 | public List getDataStoreProviderNames(); |
||
176 | |||
177 | /**
|
||
178 | * Return the file resource associated to this name and store. If the
|
||
179 | * resource not exists or the explorer don't support this opperation return
|
||
180 | * null.
|
||
181 | *
|
||
182 | * @param dataStore
|
||
183 | * @param resourceName
|
||
184 | * @return file resource or null
|
||
185 | * @throws DataException
|
||
186 | 44160 | jjdelcerro | * @deprecated use getResource
|
187 | 44157 | jjdelcerro | */
|
188 | public File getResourcePath(DataStore dataStore, String resourceName) throws DataException; |
||
189 | |||
190 | 44160 | jjdelcerro | /**
|
191 | * Return the DataResource associated to this name and store. If the
|
||
192 | * resource not exists or the explorer don't support this opperation return
|
||
193 | * null.
|
||
194 | *
|
||
195 | * @param dataStore
|
||
196 | * @param resourceName
|
||
197 | * @return the DataResource or null
|
||
198 | * @throws DataException
|
||
199 | */
|
||
200 | public DataResource getResource(DataStore dataStore, String resourceName) throws DataException; |
||
201 | 40435 | jjdelcerro | } |