Revision 11247 trunk/libraries/libGPE/src/org/gvsig/gpe/GPEParser.java
GPEParser.java | ||
---|---|---|
50 | 50 |
* |
51 | 51 |
* $Id$ |
52 | 52 |
* $Log$ |
53 |
* Revision 1.7 2007-04-14 16:06:13 jorpiell |
|
53 |
* Revision 1.8 2007-04-19 07:23:20 jorpiell |
|
54 |
* Add the add methods to teh contenhandler and change the register mode |
|
55 |
* |
|
56 |
* Revision 1.7 2007/04/14 16:06:13 jorpiell |
|
54 | 57 |
* The writer handler has been updated |
55 | 58 |
* |
56 | 59 |
* Revision 1.6 2007/04/13 07:17:54 jorpiell |
... | ... | |
81 | 84 |
public abstract class GPEParser { |
82 | 85 |
private GPEErrorHandler errorHandler; |
83 | 86 |
private GPEContentHandler contentHandler; |
84 |
private File parserFile = null; |
|
85 |
private Object prueba; |
|
86 | 87 |
|
87 | 88 |
/** |
88 |
* |
|
89 |
* AQUI SE IMPLEMENTA LA BASE PARA PODER PARSEAR CUALQUIER FICHERO: |
|
90 |
* -COMPROBAR SI EXISTE |
|
91 |
* -COMPROBAR CODIFICACI?N DEL XML |
|
92 |
* -ABRIR EN MODO LECTURA CON LA CODIFICACI?N CORRECTA |
|
93 |
* -CREAR EL PARSER DE XML ?"XSOM"? |
|
94 |
* -DETECTAR FORMATO FICHERO Y VERSI?N ?"EST? REGISTRADO"? |
|
95 |
* -SI EXISTE, LLAMADA AL PARSER DEL FORMATO CONCRETO |
|
96 |
* |
|
89 |
* All the GPE parser must implement a constructor without |
|
90 |
* arguments. |
|
97 | 91 |
**/ |
98 |
public GPEParser(GPEContentHandler contents, GPEErrorHandler errors){ |
|
99 |
this.contentHandler = contents; |
|
100 |
this.errorHandler=errors; |
|
92 |
public GPEParser(){ |
|
93 |
|
|
101 | 94 |
} |
102 | 95 |
|
103 |
|
|
104 |
public void parse(File file) throws Exception{ |
|
105 |
|
|
106 |
// /***** para lectura en modo texto ****/ |
|
107 |
// GPEXMLReader.open(); |
|
108 |
// FileReader reader = null; |
|
109 |
// try { |
|
110 |
// reader = new FileReader(this.parserFile); |
|
111 |
// } catch (FileNotFoundException e) { |
|
112 |
// // TODO llamada a ??GPEErrorHandler?? para tratar la excepci?n o lanzamos desde aqu? |
|
113 |
// // Fichero no existe. |
|
114 |
// } |
|
115 |
// BufferedReader br = new BufferedReader(reader); |
|
116 |
// char[] buffer = new char[100]; |
|
117 |
// try { |
|
118 |
// br.read(buffer); |
|
119 |
// } catch (IOException e) { |
|
120 |
// // TODO llamada a ??GPEErrorHandler?? para tratar la excepci?n o lanzamos desde aqu? |
|
121 |
// // Error de lectura del buffer |
|
122 |
// } |
|
123 |
// StringBuffer st = new StringBuffer(new String(buffer)); |
|
124 |
// |
|
125 |
// // We find the encoding at the begining of the file |
|
126 |
// |
|
127 |
// String searchText = "encoding=\""; |
|
128 |
// int index = st.indexOf(searchText); |
|
129 |
// |
|
130 |
// // If it find the encoding, it takes the new encoding, else it takes the default encoding "UTF-8" |
|
131 |
// if (index>-1) { |
|
132 |
// st.delete(0, index+searchText.length()); |
|
133 |
// encoding = st.substring(0, st.indexOf("\"")); |
|
134 |
// } |
|
135 |
// |
|
136 |
// // make GML parser with the good enconding |
|
137 |
// XMLSchemaParser parser = new XMLSchemaParser(); |
|
138 |
// |
|
139 |
// // setImput(file,encoding): it sets the encoding to read with the KXML parser |
|
140 |
// try { |
|
141 |
// parser.setInput(new FileInputStream(m_File), encoding); |
|
142 |
// } catch (FileNotFoundException e) { |
|
143 |
// // TODO Auto-generated catch block |
|
144 |
// throw new GMLException(m_File.getName(),e); |
|
145 |
// } catch (XmlPullParserException e) { |
|
146 |
// // TODO Auto-generated catch block |
|
147 |
// throw new GMLException(m_File.getName(),e); |
|
148 |
// } |
|
149 |
// return parser; |
|
150 |
|
|
96 |
/** |
|
97 |
* Method to parse a file. It have to be implemented by all |
|
98 |
* the GPE Parsers. It cannot to throw any exception and it |
|
99 |
* cannot to return any value. In a future it could be |
|
100 |
* implemented like a independent thread |
|
101 |
* @param contents |
|
102 |
* Application ContentHandler |
|
103 |
* @param errors |
|
104 |
* Application ErrorsHandler |
|
105 |
* @param file |
|
106 |
* File to open |
|
107 |
* @throws Exception |
|
108 |
*/ |
|
109 |
public void parse(GPEContentHandler contents, GPEErrorHandler errors, File file) { |
|
110 |
this.contentHandler = contents; |
|
111 |
this.errorHandler = errors; |
|
151 | 112 |
} |
152 | 113 |
|
153 | 114 |
/** |
... | ... | |
165 | 126 |
* @return |
166 | 127 |
*/ |
167 | 128 |
public abstract String[] getFormats(); |
168 |
|
|
129 |
|
|
169 | 130 |
/** |
170 |
* Gets the writer that will be used for the consumer |
|
171 |
* application to create the outputformat |
|
172 |
* @param format |
|
173 |
* Format to create the file |
|
174 |
* @throws FileNotFoundException |
|
175 |
* If the file doesn't exist |
|
131 |
* Return an array with all the versions that the driver |
|
132 |
* is able to read/write |
|
133 |
* @return |
|
176 | 134 |
*/ |
177 |
public abstract GPEWriterHandler getWriter(String format);
|
|
135 |
public abstract String[] getVersions();
|
|
178 | 136 |
|
179 | 137 |
/** |
180 | 138 |
* @return the contentHandler |
Also available in: Unified diff