root / trunk / libraries / libGPE / src / org / gvsig / gpe / GPEParser.java @ 11178
History | View | Annotate | Download (5.09 KB)
1 |
package org.gvsig.gpe; |
---|---|
2 |
import java.io.File; |
3 |
import java.io.FileNotFoundException; |
4 |
import java.io.IOException; |
5 |
|
6 |
import org.gvsig.gpe.writers.GPEWriterHandler; |
7 |
|
8 |
|
9 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
10 |
*
|
11 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
12 |
*
|
13 |
* This program is free software; you can redistribute it and/or
|
14 |
* modify it under the terms of the GNU General Public License
|
15 |
* as published by the Free Software Foundation; either version 2
|
16 |
* of the License, or (at your option) any later version.
|
17 |
*
|
18 |
* This program is distributed in the hope that it will be useful,
|
19 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21 |
* GNU General Public License for more details.
|
22 |
*
|
23 |
* You should have received a copy of the GNU General Public License
|
24 |
* along with this program; if not, write to the Free Software
|
25 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
26 |
*
|
27 |
* For more information, contact:
|
28 |
*
|
29 |
* Generalitat Valenciana
|
30 |
* Conselleria d'Infraestructures i Transport
|
31 |
* Av. Blasco Ib??ez, 50
|
32 |
* 46010 VALENCIA
|
33 |
* SPAIN
|
34 |
*
|
35 |
* +34 963862235
|
36 |
* gvsig@gva.es
|
37 |
* www.gvsig.gva.es
|
38 |
*
|
39 |
* or
|
40 |
*
|
41 |
* IVER T.I. S.A
|
42 |
* Salamanca 50
|
43 |
* 46005 Valencia
|
44 |
* Spain
|
45 |
*
|
46 |
* +34 963163400
|
47 |
* dac@iver.es
|
48 |
*/
|
49 |
/* CVS MESSAGES:
|
50 |
*
|
51 |
* $Id: GPEParser.java 11178 2007-04-13 07:17:57Z jorpiell $
|
52 |
* $Log$
|
53 |
* Revision 1.6 2007-04-13 07:17:54 jorpiell
|
54 |
* Add the writting tests for the simple geometries
|
55 |
*
|
56 |
* Revision 1.5 2007/04/12 17:06:42 jorpiell
|
57 |
* First GML writing tests
|
58 |
*
|
59 |
* Revision 1.4 2007/04/12 10:21:29 jorpiell
|
60 |
* Add the getWriter() method
|
61 |
*
|
62 |
* Revision 1.3 2007/04/11 11:18:15 csanchez
|
63 |
* Actualizacion protoripo libGPE
|
64 |
*
|
65 |
* Revision 1.2 2007/04/11 08:46:21 csanchez
|
66 |
* Actualizacion protoripo libGPE
|
67 |
*
|
68 |
* Revision 1.1 2007/04/11 08:19:32 csanchez
|
69 |
* actualizacion
|
70 |
*
|
71 |
*
|
72 |
*/
|
73 |
/**
|
74 |
* @author Carlos S?nchez Peri??n (sanchez_carper@gva.es)
|
75 |
*/
|
76 |
|
77 |
|
78 |
public abstract class GPEParser { |
79 |
private GPEErrorHandler errorHandler;
|
80 |
private GPEContentHandler contentHandler;
|
81 |
private File parserFile = null; |
82 |
private Object prueba; |
83 |
|
84 |
/**
|
85 |
*
|
86 |
* AQUI SE IMPLEMENTA LA BASE PARA PODER PARSEAR CUALQUIER FICHERO:
|
87 |
* -COMPROBAR SI EXISTE
|
88 |
* -COMPROBAR CODIFICACI?N DEL XML
|
89 |
* -ABRIR EN MODO LECTURA CON LA CODIFICACI?N CORRECTA
|
90 |
* -CREAR EL PARSER DE XML ?"XSOM"?
|
91 |
* -DETECTAR FORMATO FICHERO Y VERSI?N ?"EST? REGISTRADO"?
|
92 |
* -SI EXISTE, LLAMADA AL PARSER DEL FORMATO CONCRETO
|
93 |
*
|
94 |
**/
|
95 |
public GPEParser(GPEContentHandler contents, GPEErrorHandler errors){
|
96 |
this.contentHandler = contents;
|
97 |
this.errorHandler=errors;
|
98 |
} |
99 |
|
100 |
|
101 |
public void parse(File file) throws Exception{ |
102 |
|
103 |
// /***** para lectura en modo texto ****/
|
104 |
// GPEXMLReader.open();
|
105 |
// FileReader reader = null;
|
106 |
// try {
|
107 |
// reader = new FileReader(this.parserFile);
|
108 |
// } catch (FileNotFoundException e) {
|
109 |
// // TODO llamada a ??GPEErrorHandler?? para tratar la excepci?n o lanzamos desde aqu?
|
110 |
// // Fichero no existe.
|
111 |
// }
|
112 |
// BufferedReader br = new BufferedReader(reader);
|
113 |
// char[] buffer = new char[100];
|
114 |
// try {
|
115 |
// br.read(buffer);
|
116 |
// } catch (IOException e) {
|
117 |
// // TODO llamada a ??GPEErrorHandler?? para tratar la excepci?n o lanzamos desde aqu?
|
118 |
// // Error de lectura del buffer
|
119 |
// }
|
120 |
// StringBuffer st = new StringBuffer(new String(buffer));
|
121 |
//
|
122 |
// // We find the encoding at the begining of the file
|
123 |
//
|
124 |
// String searchText = "encoding=\"";
|
125 |
// int index = st.indexOf(searchText);
|
126 |
//
|
127 |
// // If it find the encoding, it takes the new encoding, else it takes the default encoding "UTF-8"
|
128 |
// if (index>-1) {
|
129 |
// st.delete(0, index+searchText.length());
|
130 |
// encoding = st.substring(0, st.indexOf("\""));
|
131 |
// }
|
132 |
//
|
133 |
// // make GML parser with the good enconding
|
134 |
// XMLSchemaParser parser = new XMLSchemaParser();
|
135 |
//
|
136 |
// // setImput(file,encoding): it sets the encoding to read with the KXML parser
|
137 |
// try {
|
138 |
// parser.setInput(new FileInputStream(m_File), encoding);
|
139 |
// } catch (FileNotFoundException e) {
|
140 |
// // TODO Auto-generated catch block
|
141 |
// throw new GMLException(m_File.getName(),e);
|
142 |
// } catch (XmlPullParserException e) {
|
143 |
// // TODO Auto-generated catch block
|
144 |
// throw new GMLException(m_File.getName(),e);
|
145 |
// }
|
146 |
// return parser;
|
147 |
|
148 |
} |
149 |
|
150 |
/**
|
151 |
* Return if the driver can open the file
|
152 |
* @param file
|
153 |
* File to open
|
154 |
* @return
|
155 |
* True if the driver is able to open it
|
156 |
*/
|
157 |
public abstract boolean accept(File file); |
158 |
|
159 |
/**
|
160 |
* Return an array with all the formats that the driver
|
161 |
* is able to read/write
|
162 |
* @return
|
163 |
*/
|
164 |
public abstract String[] getFormats(); |
165 |
|
166 |
/**
|
167 |
* Gets the writer that will be used for the consumer
|
168 |
* application to create the outputformat
|
169 |
* @param format
|
170 |
* Format to create the file
|
171 |
* @param file
|
172 |
* Output file
|
173 |
* @throws FileNotFoundException
|
174 |
* If the file doesn't exist
|
175 |
*/
|
176 |
public abstract GPEWriterHandler getWriter(String format,File file) throws IOException ; |
177 |
|
178 |
/**
|
179 |
* @return the contentHandler
|
180 |
*/
|
181 |
public GPEContentHandler getContentHandler() {
|
182 |
return contentHandler;
|
183 |
} |
184 |
|
185 |
|
186 |
/**
|
187 |
* @return the errorHandler
|
188 |
*/
|
189 |
public GPEErrorHandler getErrorHandler() {
|
190 |
return errorHandler;
|
191 |
} |
192 |
|
193 |
|
194 |
} |