Statistics
| Revision:

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 @ 44276

History | View | Annotate | Download (6.26 KB)

1
/**
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
package org.gvsig.fmap.dal;
25

    
26
import java.io.File;
27
import java.util.List;
28

    
29
import org.gvsig.fmap.dal.exception.DataException;
30
import org.gvsig.tools.dispose.Disposable;
31
import org.gvsig.tools.util.ResourcesStorage.Resource;
32

    
33
/**
34
 * DataServerExplorer is an abstraction for any type of data server. It allows
35
 * connecting to the server and browsing its contents.
36
 *
37
 * More specifically, this interface provides a list of the available data
38
 * stores in a server.
39
 */
40
public interface DataServerExplorer extends Disposable, DataFactoryUnit {
41

    
42
//    public interface DataResource extends Resource {
43
//        @Override
44
//        public URL getURL();
45
//        
46
//        @Override
47
//        public boolean exists();
48
//        
49
//        @Override
50
//        public InputStream asInputStream() throws IOException;
51
//        
52
//        @Override
53
//        public OutputStream asOutputStream() throws IOException;
54
//        
55
//        @Override
56
//        public void close();
57
//    }
58
//    
59
    /**
60
     * Returns the DataServerExplorer's name
61
     *
62
     * @return String containing this DataServerExplorer's name
63
     */
64
    public String getProviderName();
65

    
66
    /**
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

    
75
    /**
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

    
89
    /**
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

    
98
    public DataStoreParameters get(String name) throws DataException;
99

    
100
    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

    
105
    /**
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

    
118
    /**
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

    
134
    /**
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

    
144
    /**
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

    
156
    /**
157
     * Returns this DataServerExplorer parameters
158
     *
159
     * @return an instance of DataServerExplorerParameters containing this
160
     * DataServerExplorer parameters.
161
     */
162
    public DataServerExplorerParameters getParameters();
163

    
164
    /**
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
     * @deprecated use getResource
181
     */
182
    public File getResourcePath(DataStore dataStore, String resourceName) throws DataException;
183

    
184
    /**
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 Resource getResource(DataStore dataStore, String resourceName) throws DataException;
195

    
196
    public List<Resource> getResources(DataStore dataStore, String resourceName) throws DataException;
197
}