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