Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libGPE / src / org / gvsig / gpe / GPEManager.java @ 28113

History | View | Annotate | Download (9.08 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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 2
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
*/
22

    
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 {Iver T.I.}   {Task}
26
*/
27
 
28
package org.gvsig.gpe;
29

    
30
import java.io.File;
31
import java.io.FileInputStream;
32
import java.io.FileNotFoundException;
33
import java.io.IOException;
34
import java.lang.reflect.InvocationTargetException;
35
import java.net.URI;
36
import java.util.ArrayList;
37
import java.util.Enumeration;
38
import java.util.Hashtable;
39
import java.util.Iterator;
40
import java.util.Properties;
41

    
42
import org.gvsig.gpe.exceptions.ParserCreationException;
43
import org.gvsig.gpe.exceptions.ParserMimetypeNotSupportedException;
44
import org.gvsig.gpe.exceptions.ParserNotRegisteredException;
45
import org.gvsig.gpe.exceptions.WriterHandlerCreationException;
46
import org.gvsig.gpe.exceptions.WriterHandlerNotRegisteredException;
47
import org.gvsig.gpe.parser.GPEParser;
48
import org.gvsig.gpe.writer.GPEWriterHandler;
49
import org.gvsig.gpe.writer.GPEWriterHandlerImplementor;
50
import org.gvsig.gpe.writer.IGPEWriterHandlerImplementor;
51

    
52
/**
53
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
54
 */
55
public interface GPEManager {
56
        
57
        /**
58
         * Adds a new GPE parser
59
         * @param name
60
         * Driver name. It must be written like FORMAT VERSION
61
         * @param description
62
         * Driver description. Just a descriptive text
63
         * @param clazz
64
         * The parser class        
65
         * @throws ParserNotRegisteredException 
66
         * @throws GPEParserRegisterException
67
         */
68
        public void addGpeParser(String name, String description,Class clazz) throws ParserNotRegisteredException; 
69
                        
70
        /**
71
         * Adds a new GPE parser
72
         * @param clazz
73
         * The parser class        
74
         * @throws ParserNotRegisteredException 
75
         * @throws GPEParserRegisterException
76
         */
77
        public void addGpeParser(Class clazz) throws ParserNotRegisteredException; 
78
                        
79
        /**
80
         * It loads the parsers of a parsers file. The file is
81
         * a properties file. Every line has the structure: 
82
         * Parser=Parser class
83
         * @param file
84
         * File that contains the parsers list
85
         * @throws IOException 
86
         * @throws FileNotFoundException 
87
         * @throws ParserNotRegisteredException 
88
         */
89
        public void addParsersFile(File file) throws FileNotFoundException, IOException;
90
                
91
        /**
92
         * It loads the writers of a writers file. The file is
93
         * a properties file. Every line has the structure: 
94
         * Writer=Parser class
95
         * @param file
96
         * File that contains the writers list
97
         * @throws IOException 
98
         * @throws FileNotFoundException 
99
         */
100
        public void addWritersFile(File file) throws FileNotFoundException, IOException;
101
                        
102
        /**
103
         * @return all the registered parsers
104
         */
105
        public GPEParser[] getAllParsers();
106
                                
107
        /**
108
         * Adds a new GPEWriterHandlerImplementor
109
         * @param name
110
         * Driver name. It must be written like FORMAT VERSION
111
         * @param description
112
         * Driver description. Just a descriptive text
113
         * @param clazz
114
         * The parser class        
115
         * @throws WriterHandlerNotRegisteredException 
116
         * @throws GPEWriterHandlerRegisterException 
117
         */
118
        public void addGpeWriterHandler(String name, String description,Class clazz) throws WriterHandlerNotRegisteredException;
119
        
120
        /**
121
         * Adds a new GPEWriterHandlerImplementor
122
         * @param clazz
123
         * The parser class        
124
         * @throws WriterHandlerNotRegisteredException 
125
         * @throws GPEWriterHandlerRegisterException 
126
         */
127
        public void addGpeWriterHandler(Class clazz) throws WriterHandlerNotRegisteredException;
128
        
129
        /**
130
         * Create a new parser from a name
131
         * @param name
132
         * GPEParser name
133
         * @param contenHandler
134
         * Application contenHandler usett to throw the parsing events
135
         * @param errorHandler
136
         * Application errror handler used to put errors and warnings
137
         * @throws ParserCreationException 
138
         * @throws GPEParserCreationException 
139
         */
140
        public GPEParser createParser(String name) throws ParserCreationException;
141
                
142
        /**
143
         * Create a new parser from a name
144
         * @param name
145
         * GPEParser name
146
         * @param contenHandler
147
         * Application contenHandler usett to throw the parsing events
148
         * @param errorHandler
149
         * Application errror handler used to put errors and warnings
150
         * @throws ParserCreationException 
151
         * @throws GPEParserCreationException 
152
         */
153
        public GPEParser createParserByClass(String prefferredImplClassName) throws ParserCreationException;
154
                
155
        /**
156
         * Create a new parser from a mime type. Each parser has a method
157
         * named {@link GPEParser#getFormat()} that returns the mimetype
158
         * that the parser can read. One parser only supports one mimetype.
159
         * <p>
160
         * This method retrieve all the parsers and returns the first
161
         * parser that is able to read the mimetype. If there are more
162
         * parsers that can open the file will not be used.
163
         * </p>
164
         * @param mimeType
165
         * The mimetype of the file to open
166
         * @return
167
         * A parser that can parse the mimetype.
168
         * @throws ParserCreationException
169
         * If it is not possible to create a parser
170
         * @see 
171
         * <a href="http://www.iana.org/assignments/media-types/">http://www.iana.org/assignments/media-types/</a>
172
         */
173
        public GPEParser createParserByMimeType(String mimeType) throws ParserCreationException;
174
                
175
        /**
176
         * Gets the parser that can open the file (if it exists)
177
         * @param uri
178
         * File to open
179
         * @return
180
         * Null if the driver doesn't exist
181
         * @throws GPEParserCreationException 
182
         * @throws NoSuchMethodException 
183
         * @throws InvocationTargetException 
184
         * @throws IllegalAccessException 
185
         * @throws InstantiationException 
186
         * @throws SecurityException 
187
         * @throws IllegalArgumentException 
188
         */
189
        public GPEParser createParser(URI uri) throws ParserCreationException;
190
                        
191
        /**
192
         * Create a new content writer from a name
193
         * @param name
194
         * GPEWriterHandler name
195
         * GPEParser name
196
         * @param contenHandler
197
         * Application contenHandler usett to throw the parsing events
198
         * @param errorHandler
199
         * Application errror handler used to put errors and warnings
200
         * @throws GPEWriterHandlerCreationException         
201
         */
202
        public GPEWriterHandler createWriter(String name) throws WriterHandlerCreationException;
203
        
204
        /**
205
         * Create a new writer from a class name. This method can be used 
206
         * if the class name is known but, the common method to get a writer
207
         * is using the mime type.     * 
208
         * @param prefferredImplClassName
209
         * The name of the class that implements {@link GPEWriterHandler}
210
         * @return
211
         * A writer for a concrete format.
212
         * @throws WriterHandlerCreationException
213
         * If it is not possible to create a writer
214
         */
215
        public GPEWriterHandler createWriterByClass(String prefferredImplClassName) throws WriterHandlerCreationException; 
216
                
217
        /**
218
         * Create a new writer from a mime type. Each writer has a method
219
         * named {@link GPEWriterHandler#getFormat()} that returns the mimetype
220
         * that the writer can write. One writer only supports one mimetype.
221
         * <p>
222
         * This method retrieve all the writers and returns the first
223
         * one that is able to write the mimetype. If there are more
224
         * writer that can write the format will not be used.
225
         * </p>
226
         * @param mimeType
227
         * The mimetype of the file to write
228
         * @return
229
         * A writer that can write the mimetype.
230
         * @throws WriterHandlerCreationException
231
         * If it is not possible to create a writer
232
         * @see 
233
         * <a href="http://www.iana.org/assignments/media-types/">http://www.iana.org/assignments/media-types/</a>
234
         */
235
        public GPEWriterHandler createWriterByMimeType(String mimeType) throws WriterHandlerCreationException;
236
        
237
        /**
238
         * Gets all the writers that can 
239
         * @param format
240
         * @return
241
         */
242
        public ArrayList getWriterHandlerByFormat(String format);
243
                
244
        /**
245
         * Return true if exists a driver that can open the file
246
         * @param uri
247
         * File to open
248
         * @return
249
         * true if the driver exists
250
         */
251
        public boolean accept(URI uri);        
252
        
253
        /**
254
         * Returns an iterator with the name of all the properties that 
255
         * has been established.
256
         */
257
        public Iterator getKeys();
258
                
259
        
260
        /**
261
         * Gets a String property
262
         * @param key
263
         * Property name
264
         * @return
265
         */
266
        public String getStringProperty(String key);
267
        
268
        /**
269
         * Gets a int property
270
         * @param key
271
         * Property name
272
         * @return
273
         * The int property or -1
274
         */
275
        public int getIntPropertyProperty(String key);
276
        
277
        /**
278
         * Gets a boolean property. If the property doesn't exist
279
         * it returns false.
280
         * @param key
281
         * Property name
282
         * @return
283
         * The boolean property or false
284
         */
285
        public boolean getBooleanProperty(String key);
286
        
287
        /**
288
         * Gets a property
289
         * @param key
290
         * Property name
291
         * @return
292
         */
293
        public Object getProperty(String key);
294
        
295
        /**
296
         * Sets a property
297
         * @param key
298
         * @param value
299
         */
300
        public void setProperty(String key, Object value);
301
}
302