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 @ 44198
History | View | Annotate | Download (6.17 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 | |||
38 | /**
|
||
39 | * DataServerExplorer is an abstraction for any type of data server. It allows
|
||
40 | * connecting to the server and browsing its contents.
|
||
41 | *
|
||
42 | * More specifically, this interface provides a list of the available data
|
||
43 | * stores in a server.
|
||
44 | */
|
||
45 | 43020 | jjdelcerro | public interface DataServerExplorer extends Disposable, DataFactoryUnit { |
46 | 40435 | jjdelcerro | |
47 | 44160 | jjdelcerro | public interface DataResource extends Closeable { |
48 | 44189 | jjdelcerro | public URL getURL(); |
49 | |||
50 | 44160 | jjdelcerro | public boolean exists(); |
51 | |||
52 | public InputStream asInputStream() throws IOException; |
||
53 | |||
54 | public OutputStream asOutputStream() throws IOException; |
||
55 | |||
56 | public void close(); |
||
57 | } |
||
58 | |||
59 | 44157 | jjdelcerro | /**
|
60 | * Returns the DataServerExplorer's name
|
||
61 | *
|
||
62 | * @return String containing this DataServerExplorer's name
|
||
63 | */
|
||
64 | public String getProviderName(); |
||
65 | 40435 | jjdelcerro | |
66 | 44157 | jjdelcerro | /**
|
67 | * Indicates whether this DataServerExplorer can create a new DataStore in
|
||
68 | * the server.
|
||
69 | *
|
||
70 | * @return true if this DataServerExplorer can be created or false
|
||
71 | * otherwise.
|
||
72 | */
|
||
73 | public boolean canAdd(); |
||
74 | 40435 | jjdelcerro | |
75 | 44157 | jjdelcerro | /**
|
76 | * Indicates whether this DataServerExplorer can create a new DataStore in
|
||
77 | * the server, given the store name.
|
||
78 | *
|
||
79 | * @param storeName store name.
|
||
80 | *
|
||
81 | * @return true if this DataServerExplorer can create a new store or false
|
||
82 | * otherwise.
|
||
83 | *
|
||
84 | * @throws DataException
|
||
85 | */
|
||
86 | public boolean canAdd(String storeName) |
||
87 | throws DataException;
|
||
88 | 40435 | jjdelcerro | |
89 | 44157 | jjdelcerro | /**
|
90 | * Provides a list of available stores in the server.
|
||
91 | *
|
||
92 | * @return list of DataStoreParameters
|
||
93 | *
|
||
94 | * @throws DataException
|
||
95 | */
|
||
96 | public List list() throws DataException; |
||
97 | 40435 | jjdelcerro | |
98 | 44157 | jjdelcerro | public DataStoreParameters get(String name) throws DataException; |
99 | 40435 | jjdelcerro | |
100 | 44157 | jjdelcerro | public static final int MODE_ALL = 0; |
101 | public static final int MODE_FEATURE = 1; |
||
102 | public static final int MODE_GEOMETRY = 2; |
||
103 | public static final int MODE_RASTER = 4; |
||
104 | 40435 | jjdelcerro | |
105 | 44157 | jjdelcerro | /**
|
106 | * Provides a list of available stores in the server of a type.
|
||
107 | *
|
||
108 | * @param mode , filter store from a type: {@link #MODE_ALL},
|
||
109 | * {@link #MODE_FEATURE}, {@link #MODE_FEATURE_GEOMETRY},
|
||
110 | * {@link #MODE_RASTER}
|
||
111 | *
|
||
112 | * @return list of DataStoreParameters
|
||
113 | *
|
||
114 | * @throws DataException
|
||
115 | */
|
||
116 | public List list(int mode) throws DataException; |
||
117 | 40435 | jjdelcerro | |
118 | 44157 | jjdelcerro | /**
|
119 | * Creates a new DataStore in this server.
|
||
120 | *
|
||
121 | * @param parameters , an instance of DataStoreParameters from
|
||
122 | * {@link DataServerExplorer#getAddParameters(String)} that describes the
|
||
123 | * new DataStore.
|
||
124 | * @param overwrite if the store already exists
|
||
125 | *
|
||
126 | * @return true if the DataStoreParameters were successfully added, false
|
||
127 | * otherwise.
|
||
128 | *
|
||
129 | * @throws DataException
|
||
130 | */
|
||
131 | public boolean add(String provider, NewDataStoreParameters parameters, boolean overwrite) |
||
132 | throws DataException;
|
||
133 | 40435 | jjdelcerro | |
134 | 44157 | jjdelcerro | /**
|
135 | * Removes a store from the server given its DataStoreParameters. If the
|
||
136 | * store is a file then this method deletes the file, if it is a table in a
|
||
137 | * database then this method drops the table, and so on.
|
||
138 | *
|
||
139 | * @param parameters
|
||
140 | * @throws DataException
|
||
141 | */
|
||
142 | void remove(DataStoreParameters parameters) throws DataException; |
||
143 | 40435 | jjdelcerro | |
144 | 44157 | jjdelcerro | /**
|
145 | * Given the store's name, returns its parameters for creation.
|
||
146 | *
|
||
147 | * @param storeName
|
||
148 | *
|
||
149 | * @return parameters to create a store
|
||
150 | *
|
||
151 | * @throws DataException
|
||
152 | */
|
||
153 | public NewDataStoreParameters getAddParameters(String storeName) |
||
154 | throws DataException;
|
||
155 | 40435 | jjdelcerro | |
156 | 44157 | jjdelcerro | /**
|
157 | * Returns this DataServerExplorer parameters
|
||
158 | *
|
||
159 | * @return an instance of DataServerExplorerParameters containing this
|
||
160 | * DataServerExplorer parameters.
|
||
161 | */
|
||
162 | public DataServerExplorerParameters getParameters();
|
||
163 | 40435 | jjdelcerro | |
164 | 44157 | jjdelcerro | /**
|
165 | * Return the list of provider names that this server allow.
|
||
166 | *
|
||
167 | * @return List of provider names
|
||
168 | */
|
||
169 | public List getDataStoreProviderNames(); |
||
170 | |||
171 | /**
|
||
172 | * Return the file resource associated to this name and store. If the
|
||
173 | * resource not exists or the explorer don't support this opperation return
|
||
174 | * null.
|
||
175 | *
|
||
176 | * @param dataStore
|
||
177 | * @param resourceName
|
||
178 | * @return file resource or null
|
||
179 | * @throws DataException
|
||
180 | 44160 | jjdelcerro | * @deprecated use getResource
|
181 | 44157 | jjdelcerro | */
|
182 | public File getResourcePath(DataStore dataStore, String resourceName) throws DataException; |
||
183 | |||
184 | 44160 | jjdelcerro | /**
|
185 | * Return the DataResource associated to this name and store. If the
|
||
186 | * resource not exists or the explorer don't support this opperation return
|
||
187 | * null.
|
||
188 | *
|
||
189 | * @param dataStore
|
||
190 | * @param resourceName
|
||
191 | * @return the DataResource or null
|
||
192 | * @throws DataException
|
||
193 | */
|
||
194 | public DataResource getResource(DataStore dataStore, String resourceName) throws DataException; |
||
195 | 40435 | jjdelcerro | } |