1 | /* | |
2 | * $Id: XmlParser.java 3373 2008-05-12 16:21:24Z xlv $ | |
3 | * | |
4 | * Copyright 2001, 2002 by Bruno Lowagie. | |
5 | * | |
6 | * The contents of this file are subject to the Mozilla Public License Version 1.1 | |
7 | * (the "License"); you may not use this file except in compliance with the License. | |
8 | * You may obtain a copy of the License at http://www.mozilla.org/MPL/ | |
9 | * | |
10 | * Software distributed under the License is distributed on an "AS IS" basis, | |
11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |
12 | * for the specific language governing rights and limitations under the License. | |
13 | * | |
14 | * The Original Code is 'iText, a free JAVA-PDF library'. | |
15 | * | |
16 | * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by | |
17 | * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie. | |
18 | * All Rights Reserved. | |
19 | * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer | |
20 | * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved. | |
21 | * | |
22 | * Contributor(s): all the names of the contributors are added in the source code | |
23 | * where applicable. | |
24 | * | |
25 | * Alternatively, the contents of this file may be used under the terms of the | |
26 | * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the | |
27 | * provisions of LGPL are applicable instead of those above. If you wish to | |
28 | * allow use of your version of this file only under the terms of the LGPL | |
29 | * License and not to allow others to use your version of this file under | |
30 | * the MPL, indicate your decision by deleting the provisions above and | |
31 | * replace them with the notice and other provisions required by the LGPL. | |
32 | * If you do not delete the provisions above, a recipient may use your version | |
33 | * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE. | |
34 | * | |
35 | * This library is free software; you can redistribute it and/or modify it | |
36 | * under the terms of the MPL as stated above or under the terms of the GNU | |
37 | * Library General Public License as published by the Free Software Foundation; | |
38 | * either version 2 of the License, or any later version. | |
39 | * | |
40 | * This library is distributed in the hope that it will be useful, but WITHOUT | |
41 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
42 | * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more | |
43 | * details. | |
44 | * | |
45 | * If you didn't download this code from the following link, you should check if | |
46 | * you aren't using an obsolete version: | |
47 | * http://www.lowagie.com/iText/ | |
48 | */ | |
49 | ||
50 | package com.lowagie.text.xml; | |
51 | ||
52 | import com.lowagie.text.DocListener; | |
53 | import com.lowagie.text.ExceptionConverter; | |
54 | import org.xml.sax.InputSource; | |
55 | import org.xml.sax.SAXException; | |
56 | ||
57 | import javax.xml.parsers.ParserConfigurationException; | |
58 | import javax.xml.parsers.SAXParser; | |
59 | import javax.xml.parsers.SAXParserFactory; | |
60 | import java.io.IOException; | |
61 | import java.io.InputStream; | |
62 | import java.io.Reader; | |
63 | import java.util.HashMap; | |
64 | ||
65 | /** | |
66 | * This class can be used to parse an XML file. | |
67 | */ | |
68 | ||
69 | public class XmlParser { | |
70 | ||
71 | /** | |
72 | * This is the instance of the parser. | |
73 | */ | |
74 | protected SAXParser parser; | |
75 | ||
76 | /** | |
77 | * Constructs an XmlParser. | |
78 | */ | |
79 | ||
80 | public XmlParser() { | |
81 | try { | |
82 | parser = SAXParserFactory.newInstance().newSAXParser(); | |
83 | } catch (ParserConfigurationException | SAXException pce) { | |
84 | throw new ExceptionConverter(pce); | |
85 | } | |
86 | } | |
87 | ||
88 | /** | |
89 | * Parses a given file. | |
90 | * | |
91 | * @param document The document that will listen to the parser | |
92 | * @param is The InputStream with the contents | |
93 | */ | |
94 | ||
95 | public void go(DocListener document, InputSource is) { | |
96 | try { | |
97 |
1
1. go : removed call to javax/xml/parsers/SAXParser::parse → NO_COVERAGE |
parser.parse(is, new SAXiTextHandler(document)); |
98 | } catch (SAXException | IOException se) { | |
99 | throw new ExceptionConverter(se); | |
100 | } | |
101 | } | |
102 | ||
103 | /** | |
104 | * Parses a given file. | |
105 | * | |
106 | * @param document The document that will listen to the parser | |
107 | * @param is The input source with the content | |
108 | * @param tagmap A user defined tagmap | |
109 | */ | |
110 | ||
111 | public void go(DocListener document, InputSource is, String tagmap) { | |
112 | try { | |
113 |
1
1. go : removed call to javax/xml/parsers/SAXParser::parse → NO_COVERAGE |
parser.parse(is, new SAXmyHandler(document, new TagMap(tagmap))); |
114 | } catch (SAXException | IOException se) { | |
115 | throw new ExceptionConverter(se); | |
116 | } | |
117 | } | |
118 | ||
119 | /** | |
120 | * Parses a given file. | |
121 | * | |
122 | * @param document The document that will listen to the parser | |
123 | * @param is the input source with the content | |
124 | * @param tagmap an inputstream to a user defined tagmap | |
125 | */ | |
126 | ||
127 | public void go(DocListener document, InputSource is, InputStream tagmap) { | |
128 | try { | |
129 |
1
1. go : removed call to javax/xml/parsers/SAXParser::parse → NO_COVERAGE |
parser.parse(is, new SAXmyHandler(document, new TagMap(tagmap))); |
130 | } catch (SAXException | IOException se) { | |
131 | throw new ExceptionConverter(se); | |
132 | } | |
133 | } | |
134 | ||
135 | /** | |
136 | * Parses a given file. | |
137 | * | |
138 | * @param document The document that will listen to the parser | |
139 | * @param is the input source with the content | |
140 | * @param tagmap a user defined tagmap | |
141 | */ | |
142 | ||
143 | public void go(DocListener document, InputSource is, HashMap tagmap) { | |
144 | try { | |
145 |
1
1. go : removed call to javax/xml/parsers/SAXParser::parse → NO_COVERAGE |
parser.parse(is, new SAXmyHandler(document, tagmap)); |
146 | } catch (SAXException | IOException se) { | |
147 | throw new ExceptionConverter(se); | |
148 | } | |
149 | } | |
150 | ||
151 | /** | |
152 | * Parses a given file. | |
153 | * | |
154 | * @param document The document that will listen to the parser | |
155 | * @param file The path to a file with the content | |
156 | */ | |
157 | ||
158 | public void go(DocListener document, String file) { | |
159 | try { | |
160 |
1
1. go : removed call to javax/xml/parsers/SAXParser::parse → NO_COVERAGE |
parser.parse(file, new SAXiTextHandler(document)); |
161 | } catch (SAXException | IOException se) { | |
162 | throw new ExceptionConverter(se); | |
163 | } | |
164 | } | |
165 | ||
166 | /** | |
167 | * Parses a given file. | |
168 | * | |
169 | * @param document the document that will listen to the parser | |
170 | * @param file the path to a file with the content | |
171 | * @param tagmap a user defined tagmap | |
172 | */ | |
173 | ||
174 | public void go(DocListener document, String file, String tagmap) { | |
175 | try { | |
176 |
1
1. go : removed call to javax/xml/parsers/SAXParser::parse → NO_COVERAGE |
parser.parse(file, new SAXmyHandler(document, new TagMap(tagmap))); |
177 | } catch (SAXException | IOException se) { | |
178 | throw new ExceptionConverter(se); | |
179 | } | |
180 | } | |
181 | ||
182 | /** | |
183 | * Parses a given file. | |
184 | * | |
185 | * @param document The document that will listen to the parser | |
186 | * @param file the path to a file with the content | |
187 | * @param tagmap a user defined tagmap | |
188 | */ | |
189 | ||
190 | public void go(DocListener document, String file, HashMap tagmap) { | |
191 | try { | |
192 |
1
1. go : removed call to javax/xml/parsers/SAXParser::parse → NO_COVERAGE |
parser.parse(file, new SAXmyHandler(document, tagmap)); |
193 | } catch (SAXException | IOException se) { | |
194 | throw new ExceptionConverter(se); | |
195 | } | |
196 | } | |
197 | ||
198 | /** | |
199 | * Parses a given file that validates with the iText DTD and writes the content to a document. | |
200 | * | |
201 | * @param document The document that will listen to the parser | |
202 | * @param is the input source with the content | |
203 | */ | |
204 | ||
205 | public static void parse(DocListener document, InputSource is) { | |
206 | XmlParser xmlParser = new XmlParser(); | |
207 |
1
1. parse : removed call to com/lowagie/text/xml/XmlParser::go → NO_COVERAGE |
xmlParser.go(document, is); |
208 | } | |
209 | ||
210 | /** | |
211 | * Parses a given file that validates with the iText DTD and writes the content to a document. | |
212 | * | |
213 | * @param document The document that will listen to the parser | |
214 | * @param is The input source with the content | |
215 | * @param tagmap a user defined tagmap | |
216 | */ | |
217 | ||
218 | public static void parse(DocListener document, InputSource is, String tagmap) { | |
219 | XmlParser xmlParser = new XmlParser(); | |
220 |
1
1. parse : removed call to com/lowagie/text/xml/XmlParser::go → NO_COVERAGE |
xmlParser.go(document, is, tagmap); |
221 | } | |
222 | ||
223 | /** | |
224 | * Parses a given file and writes the content to a document, using a certain tagmap. | |
225 | * | |
226 | * @param document The document that will listen to the parser | |
227 | * @param is The input source with the content | |
228 | * @param tagmap a user defined tagmap | |
229 | */ | |
230 | ||
231 | public static void parse(DocListener document, InputSource is, HashMap tagmap) { | |
232 | XmlParser xmlParser = new XmlParser(); | |
233 |
1
1. parse : removed call to com/lowagie/text/xml/XmlParser::go → NO_COVERAGE |
xmlParser.go(document, is, tagmap); |
234 | } | |
235 | ||
236 | /** | |
237 | * Parses a given file that validates with the iText DTD and writes the content to a document. | |
238 | * | |
239 | * @param document The document that will listen to the parser | |
240 | * @param file The path to a file with the content | |
241 | */ | |
242 | ||
243 | public static void parse(DocListener document, String file) { | |
244 | XmlParser xmlParser = new XmlParser(); | |
245 |
1
1. parse : removed call to com/lowagie/text/xml/XmlParser::go → NO_COVERAGE |
xmlParser.go(document, file); |
246 | } | |
247 | ||
248 | /** | |
249 | * Parses a given file that validates with the iText DTD and writes the content to a document. | |
250 | * | |
251 | * @param document The document that will listen to the parser | |
252 | * @param file The path to a file with the content | |
253 | * @param tagmap A user defined tagmap | |
254 | */ | |
255 | ||
256 | public static void parse(DocListener document, String file, String tagmap) { | |
257 | XmlParser xmlParser = new XmlParser(); | |
258 |
1
1. parse : removed call to com/lowagie/text/xml/XmlParser::go → NO_COVERAGE |
xmlParser.go(document, file, tagmap); |
259 | } | |
260 | ||
261 | /** | |
262 | * Parses a given file and writes the content to a document, using a certain tagmap. | |
263 | * | |
264 | * @param document The document that will listen to the parser | |
265 | * @param file The path to a file with the content | |
266 | * @param tagmap A user defined tagmap | |
267 | */ | |
268 | ||
269 | public static void parse(DocListener document, String file, HashMap tagmap) { | |
270 | XmlParser xmlParser = new XmlParser(); | |
271 |
1
1. parse : removed call to com/lowagie/text/xml/XmlParser::go → NO_COVERAGE |
xmlParser.go(document, file, tagmap); |
272 | } | |
273 | ||
274 | /** | |
275 | * Parses a given file that validates with the iText DTD and writes the content to a document. | |
276 | * | |
277 | * @param document The document that will listen to the parser | |
278 | * @param is The input source with the content | |
279 | */ | |
280 | ||
281 | public static void parse(DocListener document, InputStream is) { | |
282 | XmlParser xmlParser = new XmlParser(); | |
283 |
1
1. parse : removed call to com/lowagie/text/xml/XmlParser::go → NO_COVERAGE |
xmlParser.go(document, new InputSource(is)); |
284 | } | |
285 | ||
286 | /** | |
287 | * Parses a given file that validates with the iText DTD and writes the content to a document. | |
288 | * | |
289 | * @param document The document that will listen to the parser | |
290 | * @param is The input stream with the content | |
291 | * @param tagmap A user defined tagmap | |
292 | */ | |
293 | ||
294 | public static void parse(DocListener document, InputStream is, String tagmap) { | |
295 | XmlParser xmlParser = new XmlParser(); | |
296 |
1
1. parse : removed call to com/lowagie/text/xml/XmlParser::go → NO_COVERAGE |
xmlParser.go(document, new InputSource(is), tagmap); |
297 | } | |
298 | ||
299 | /** | |
300 | * Parses a given file and writes the content to a document, using a certain tagmap. | |
301 | * | |
302 | * @param document The document that will listen to the parser | |
303 | * @param is The InputStream with the content | |
304 | * @param tagmap A user defined tagmap | |
305 | */ | |
306 | ||
307 | public static void parse(DocListener document, InputStream is, HashMap tagmap) { | |
308 | XmlParser xmlParser = new XmlParser(); | |
309 |
1
1. parse : removed call to com/lowagie/text/xml/XmlParser::go → NO_COVERAGE |
xmlParser.go(document, new InputSource(is), tagmap); |
310 | } | |
311 | ||
312 | /** | |
313 | * Parses a given file that validates with the iText DTD and writes the content to a document. | |
314 | * | |
315 | * @param document The document that will listen to the parser | |
316 | * @param is The reader that reads the content | |
317 | */ | |
318 | ||
319 | public static void parse(DocListener document, Reader is) { | |
320 | XmlParser xmlParser = new XmlParser(); | |
321 |
1
1. parse : removed call to com/lowagie/text/xml/XmlParser::go → NO_COVERAGE |
xmlParser.go(document, new InputSource(is)); |
322 | } | |
323 | ||
324 | /** | |
325 | * Parses a given file that validates with the iText DTD and writes the content to a document. | |
326 | * | |
327 | * @param document The document that will listen to the parser | |
328 | * @param is The reader that reads the content | |
329 | * @param tagmap A user defined tagmap | |
330 | */ | |
331 | ||
332 | public static void parse(DocListener document, Reader is, String tagmap) { | |
333 | XmlParser xmlParser = new XmlParser(); | |
334 |
1
1. parse : removed call to com/lowagie/text/xml/XmlParser::go → NO_COVERAGE |
xmlParser.go(document, new InputSource(is), tagmap); |
335 | } | |
336 | ||
337 | /** | |
338 | * Parses a given file and writes the content to a document, using a certain tagmap. | |
339 | * | |
340 | * @param document The document that will listen to the parser | |
341 | * @param is The reader that reads the content | |
342 | * @param tagmap A user defined tagmap | |
343 | */ | |
344 | ||
345 | public static void parse(DocListener document, Reader is, HashMap tagmap) { | |
346 | XmlParser xmlParser = new XmlParser(); | |
347 |
1
1. parse : removed call to com/lowagie/text/xml/XmlParser::go → NO_COVERAGE |
xmlParser.go(document, new InputSource(is), tagmap); |
348 | } | |
349 | } | |
Mutations | ||
97 |
1.1 |
|
113 |
1.1 |
|
129 |
1.1 |
|
145 |
1.1 |
|
160 |
1.1 |
|
176 |
1.1 |
|
192 |
1.1 |
|
207 |
1.1 |
|
220 |
1.1 |
|
233 |
1.1 |
|
245 |
1.1 |
|
258 |
1.1 |
|
271 |
1.1 |
|
283 |
1.1 |
|
296 |
1.1 |
|
309 |
1.1 |
|
321 |
1.1 |
|
334 |
1.1 |
|
347 |
1.1 |