Revision 11239 trunk/libraries/libGPE-GML/src/org/gvsig/gpe/xml/GPEXmlParser.java
GPEXmlParser.java | ||
---|---|---|
4 | 4 |
import java.io.FileNotFoundException; |
5 | 5 |
import java.io.IOException; |
6 | 6 |
import java.io.InputStream; |
7 |
import java.lang.reflect.InvocationTargetException; |
|
7 | 8 |
|
8 | 9 |
import org.gvsig.gpe.GPEContentHandler; |
9 | 10 |
import org.gvsig.gpe.GPEErrorHandler; |
10 | 11 |
import org.gvsig.gpe.GPEParser; |
11 | 12 |
import org.xmlpull.v1.XmlPullParser; |
13 |
import org.xmlpull.v1.XmlPullParserException; |
|
12 | 14 |
|
13 | 15 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
14 | 16 |
* |
... | ... | |
54 | 56 |
* |
55 | 57 |
* $Id$ |
56 | 58 |
* $Log$ |
57 |
* Revision 1.2 2007-04-12 11:47:15 jorpiell |
|
59 |
* Revision 1.3 2007-04-18 12:54:45 csanchez |
|
60 |
* Actualizacion protoripo libGPE |
|
61 |
* |
|
62 |
* Revision 1.2 2007/04/12 11:47:15 jorpiell |
|
58 | 63 |
* Add a getParser method |
59 | 64 |
* |
60 | 65 |
* Revision 1.1 2007/04/12 10:23:41 jorpiell |
... | ... | |
69 | 74 |
*/ |
70 | 75 |
public abstract class GPEXmlParser extends GPEParser { |
71 | 76 |
private InputStream inputStream = null; |
72 |
private XmlPullParser parser = null;
|
|
77 |
protected XmlPullParser parser = null;
|
|
73 | 78 |
|
74 | 79 |
public GPEXmlParser(GPEContentHandler contents, GPEErrorHandler errors) { |
75 | 80 |
super(contents, errors); |
... | ... | |
79 | 84 |
* (non-Javadoc) |
80 | 85 |
* @see org.gvsig.gpe.GPEParser#parse(java.io.File) |
81 | 86 |
*/ |
82 |
public void parse(File file) throws Exception{ |
|
83 |
inputStream = createInputStream(file); |
|
84 |
parser = GPEXmlParserFactory.getParser(); |
|
85 |
parser.setInput(getInputStream(), getEncoding()); |
|
87 |
public void parse(File file){ |
|
88 |
try { |
|
89 |
inputStream = createInputStream(file); |
|
90 |
parser = GPEXmlParserFactory.getParser(); |
|
91 |
parser.setInput(getInputStream(), getEncoding()); |
|
92 |
} // EL PARSER LANZAR? UN EVENTO AL ERRORHANDLER SEG?N EL ERROR RECOGIDO |
|
93 |
catch (FileNotFoundException e) { |
|
94 |
System.out.println("ERROR: Fichero "+ file.getName() +" no encontrado"); |
|
95 |
// TODO Bloque catch generado autom?ticamente |
|
96 |
} catch (IllegalArgumentException e) { |
|
97 |
System.out.println("ERROR: Argumento Incorrecto para KXML: "+ e.getMessage()); |
|
98 |
// TODO Bloque catch generado autom?ticamente |
|
99 |
} catch (SecurityException e) { |
|
100 |
System.out.println("ERROR: Fallo de seguridad en la clase KXML: "+ e.getMessage()); |
|
101 |
// TODO Bloque catch generado autom?ticamente |
|
102 |
} catch (InstantiationException e) { |
|
103 |
System.out.println("ERROR: Instancia de KXML incorrecta: "+ e.getMessage()); |
|
104 |
// TODO Bloque catch generado autom?ticamente |
|
105 |
} catch (IllegalAccessException e) { |
|
106 |
System.out.println("ERROR: Acceso Ilegal a memoria de KXML: "+ e.getMessage()); |
|
107 |
// TODO Bloque catch generado autom?ticamente |
|
108 |
} catch (InvocationTargetException e) { |
|
109 |
System.out.println("ERROR: Invocaci?n de KXML Incorrecta: "+ e.getMessage()); |
|
110 |
// TODO Bloque catch generado autom?ticamente |
|
111 |
} catch (NoSuchMethodException e) { |
|
112 |
System.out.println("ERROR: M?todo no implementado del parser KXML: "+ e.getMessage()); |
|
113 |
// TODO Bloque catch generado autom?ticamente |
|
114 |
} catch (ClassNotFoundException e) { |
|
115 |
System.out.println("ERROR: Clase KXML no encontrada: "+ e.getMessage()); |
|
116 |
// TODO Bloque catch generado autom?ticamente |
|
117 |
} catch (XmlPullParserException e) { |
|
118 |
System.out.println("ERROR: Excepci?n en el parser KXML: "+ e.getMessage()); |
|
119 |
// TODO Bloque catch generado autom?ticamente |
|
120 |
} catch (IOException e) { |
|
121 |
System.out.println("ERROR: No se puede leer/escribir la codificaci?n del fichero: "+ e.getMessage()); |
|
122 |
// TODO Bloque catch generado autom?ticamente |
|
123 |
} |
|
86 | 124 |
initParse(); |
87 | 125 |
} |
88 | 126 |
|
89 | 127 |
/** |
90 | 128 |
* Creates an input stream from a file. |
91 | 129 |
* @param file |
92 |
* @return |
|
130 |
* @return InputStream
|
|
93 | 131 |
* @throws FileNotFoundException |
94 | 132 |
*/ |
95 | 133 |
protected abstract InputStream createInputStream(File file) throws FileNotFoundException; |
96 | 134 |
|
97 | 135 |
/** |
98 | 136 |
* This method start the parse process. It is called |
99 |
* before the XML parser is initialized
|
|
137 |
* after the XML parser is initialized
|
|
100 | 138 |
*/ |
101 | 139 |
protected abstract void initParse(); |
102 | 140 |
|
Also available in: Unified diff