1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
package org.apache.maven.plugin.invoker.model.io.xpp3; |
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
import java.io.IOException; |
15 | |
import java.io.InputStream; |
16 | |
import java.io.Reader; |
17 | |
import java.text.DateFormat; |
18 | |
import java.util.Locale; |
19 | |
import org.apache.maven.plugin.invoker.model.BuildJob; |
20 | |
import org.codehaus.plexus.util.ReaderFactory; |
21 | |
import org.codehaus.plexus.util.xml.pull.MXParser; |
22 | |
import org.codehaus.plexus.util.xml.pull.XmlPullParser; |
23 | |
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; |
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
@SuppressWarnings( "all" ) |
31 | 0 | public class BuildJobXpp3Reader |
32 | |
{ |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | 0 | private boolean addDefaultEntities = true; |
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
private boolean checkFieldWithDuplicate( XmlPullParser parser, String tagName, String alias, java.util.Set parsed ) |
66 | |
throws XmlPullParserException |
67 | |
{ |
68 | 0 | if ( !( parser.getName().equals( tagName ) || parser.getName().equals( alias ) ) ) |
69 | |
{ |
70 | 0 | return false; |
71 | |
} |
72 | 0 | if ( !parsed.add( tagName ) ) |
73 | |
{ |
74 | 0 | throw new XmlPullParserException( "Duplicated tag: '" + tagName + "'", parser, null ); |
75 | |
} |
76 | 0 | return true; |
77 | |
} |
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
private void checkUnknownAttribute( XmlPullParser parser, String attribute, String tagName, boolean strict ) |
90 | |
throws XmlPullParserException, IOException |
91 | |
{ |
92 | |
|
93 | 0 | if ( strict ) |
94 | |
{ |
95 | 0 | throw new XmlPullParserException( "Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser, null ); |
96 | |
} |
97 | 0 | } |
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
private void checkUnknownElement( XmlPullParser parser, boolean strict ) |
108 | |
throws XmlPullParserException, IOException |
109 | |
{ |
110 | 0 | if ( strict ) |
111 | |
{ |
112 | 0 | throw new XmlPullParserException( "Unrecognised tag: '" + parser.getName() + "'", parser, null ); |
113 | |
} |
114 | |
|
115 | 0 | for ( int unrecognizedTagCount = 1; unrecognizedTagCount > 0; ) |
116 | |
{ |
117 | 0 | int eventType = parser.next(); |
118 | 0 | if ( eventType == XmlPullParser.START_TAG ) |
119 | |
{ |
120 | 0 | unrecognizedTagCount++; |
121 | |
} |
122 | 0 | else if ( eventType == XmlPullParser.END_TAG ) |
123 | |
{ |
124 | 0 | unrecognizedTagCount--; |
125 | |
} |
126 | 0 | } |
127 | 0 | } |
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | |
public boolean getAddDefaultEntities() |
135 | |
{ |
136 | 0 | return addDefaultEntities; |
137 | |
} |
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
|
147 | |
|
148 | |
private boolean getBooleanValue( String s, String attribute, XmlPullParser parser ) |
149 | |
throws XmlPullParserException |
150 | |
{ |
151 | 0 | return getBooleanValue( s, attribute, parser, null ); |
152 | |
} |
153 | |
|
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
|
162 | |
|
163 | |
|
164 | |
private boolean getBooleanValue( String s, String attribute, XmlPullParser parser, String defaultValue ) |
165 | |
throws XmlPullParserException |
166 | |
{ |
167 | 0 | if ( s != null && s.length() != 0 ) |
168 | |
{ |
169 | 0 | return Boolean.valueOf( s ).booleanValue(); |
170 | |
} |
171 | 0 | if ( defaultValue != null ) |
172 | |
{ |
173 | 0 | return Boolean.valueOf( defaultValue ).booleanValue(); |
174 | |
} |
175 | 0 | return false; |
176 | |
} |
177 | |
|
178 | |
|
179 | |
|
180 | |
|
181 | |
|
182 | |
|
183 | |
|
184 | |
|
185 | |
|
186 | |
|
187 | |
|
188 | |
private byte getByteValue( String s, String attribute, XmlPullParser parser, boolean strict ) |
189 | |
throws XmlPullParserException |
190 | |
{ |
191 | 0 | if ( s != null ) |
192 | |
{ |
193 | |
try |
194 | |
{ |
195 | 0 | return Byte.valueOf( s ).byteValue(); |
196 | |
} |
197 | 0 | catch ( NumberFormatException nfe ) |
198 | |
{ |
199 | 0 | if ( strict ) |
200 | |
{ |
201 | 0 | throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a byte", parser, nfe ); |
202 | |
} |
203 | |
} |
204 | |
} |
205 | 0 | return 0; |
206 | |
} |
207 | |
|
208 | |
|
209 | |
|
210 | |
|
211 | |
|
212 | |
|
213 | |
|
214 | |
|
215 | |
|
216 | |
|
217 | |
private char getCharacterValue( String s, String attribute, XmlPullParser parser ) |
218 | |
throws XmlPullParserException |
219 | |
{ |
220 | 0 | if ( s != null ) |
221 | |
{ |
222 | 0 | return s.charAt( 0 ); |
223 | |
} |
224 | 0 | return 0; |
225 | |
} |
226 | |
|
227 | |
|
228 | |
|
229 | |
|
230 | |
|
231 | |
|
232 | |
|
233 | |
|
234 | |
|
235 | |
|
236 | |
private java.util.Date getDateValue( String s, String attribute, XmlPullParser parser ) |
237 | |
throws XmlPullParserException |
238 | |
{ |
239 | 0 | return getDateValue( s, attribute, null, parser ); |
240 | |
} |
241 | |
|
242 | |
|
243 | |
|
244 | |
|
245 | |
|
246 | |
|
247 | |
|
248 | |
|
249 | |
|
250 | |
|
251 | |
|
252 | |
private java.util.Date getDateValue( String s, String attribute, String dateFormat, XmlPullParser parser ) |
253 | |
throws XmlPullParserException |
254 | |
{ |
255 | 0 | if ( s != null ) |
256 | |
{ |
257 | 0 | String effectiveDateFormat = dateFormat; |
258 | 0 | if ( dateFormat == null ) |
259 | |
{ |
260 | 0 | effectiveDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS"; |
261 | |
} |
262 | 0 | if ( "long".equals( effectiveDateFormat ) ) |
263 | |
{ |
264 | |
try |
265 | |
{ |
266 | 0 | return new java.util.Date( Long.parseLong( s ) ); |
267 | |
} |
268 | 0 | catch ( NumberFormatException e ) |
269 | |
{ |
270 | 0 | throw new XmlPullParserException( e.getMessage(), parser, e ); |
271 | |
} |
272 | |
} |
273 | |
else |
274 | |
{ |
275 | |
try |
276 | |
{ |
277 | 0 | DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, Locale.US ); |
278 | 0 | return dateParser.parse( s ); |
279 | |
} |
280 | 0 | catch ( java.text.ParseException e ) |
281 | |
{ |
282 | 0 | throw new XmlPullParserException( e.getMessage(), parser, e ); |
283 | |
} |
284 | |
} |
285 | |
} |
286 | 0 | return null; |
287 | |
} |
288 | |
|
289 | |
|
290 | |
|
291 | |
|
292 | |
|
293 | |
|
294 | |
|
295 | |
|
296 | |
|
297 | |
|
298 | |
|
299 | |
private double getDoubleValue( String s, String attribute, XmlPullParser parser, boolean strict ) |
300 | |
throws XmlPullParserException |
301 | |
{ |
302 | 0 | if ( s != null ) |
303 | |
{ |
304 | |
try |
305 | |
{ |
306 | 0 | return Double.valueOf( s ).doubleValue(); |
307 | |
} |
308 | 0 | catch ( NumberFormatException nfe ) |
309 | |
{ |
310 | 0 | if ( strict ) |
311 | |
{ |
312 | 0 | throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe ); |
313 | |
} |
314 | |
} |
315 | |
} |
316 | 0 | return 0; |
317 | |
} |
318 | |
|
319 | |
|
320 | |
|
321 | |
|
322 | |
|
323 | |
|
324 | |
|
325 | |
|
326 | |
|
327 | |
|
328 | |
|
329 | |
private float getFloatValue( String s, String attribute, XmlPullParser parser, boolean strict ) |
330 | |
throws XmlPullParserException |
331 | |
{ |
332 | 0 | if ( s != null ) |
333 | |
{ |
334 | |
try |
335 | |
{ |
336 | 0 | return Float.valueOf( s ).floatValue(); |
337 | |
} |
338 | 0 | catch ( NumberFormatException nfe ) |
339 | |
{ |
340 | 0 | if ( strict ) |
341 | |
{ |
342 | 0 | throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe ); |
343 | |
} |
344 | |
} |
345 | |
} |
346 | 0 | return 0; |
347 | |
} |
348 | |
|
349 | |
|
350 | |
|
351 | |
|
352 | |
|
353 | |
|
354 | |
|
355 | |
|
356 | |
|
357 | |
|
358 | |
|
359 | |
private int getIntegerValue( String s, String attribute, XmlPullParser parser, boolean strict ) |
360 | |
throws XmlPullParserException |
361 | |
{ |
362 | 0 | if ( s != null ) |
363 | |
{ |
364 | |
try |
365 | |
{ |
366 | 0 | return Integer.valueOf( s ).intValue(); |
367 | |
} |
368 | 0 | catch ( NumberFormatException nfe ) |
369 | |
{ |
370 | 0 | if ( strict ) |
371 | |
{ |
372 | 0 | throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be an integer", parser, nfe ); |
373 | |
} |
374 | |
} |
375 | |
} |
376 | 0 | return 0; |
377 | |
} |
378 | |
|
379 | |
|
380 | |
|
381 | |
|
382 | |
|
383 | |
|
384 | |
|
385 | |
|
386 | |
|
387 | |
|
388 | |
|
389 | |
private long getLongValue( String s, String attribute, XmlPullParser parser, boolean strict ) |
390 | |
throws XmlPullParserException |
391 | |
{ |
392 | 0 | if ( s != null ) |
393 | |
{ |
394 | |
try |
395 | |
{ |
396 | 0 | return Long.valueOf( s ).longValue(); |
397 | |
} |
398 | 0 | catch ( NumberFormatException nfe ) |
399 | |
{ |
400 | 0 | if ( strict ) |
401 | |
{ |
402 | 0 | throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a long integer", parser, nfe ); |
403 | |
} |
404 | |
} |
405 | |
} |
406 | 0 | return 0; |
407 | |
} |
408 | |
|
409 | |
|
410 | |
|
411 | |
|
412 | |
|
413 | |
|
414 | |
|
415 | |
|
416 | |
|
417 | |
|
418 | |
|
419 | |
private String getRequiredAttributeValue( String s, String attribute, XmlPullParser parser, boolean strict ) |
420 | |
throws XmlPullParserException |
421 | |
{ |
422 | 0 | if ( s == null ) |
423 | |
{ |
424 | 0 | if ( strict ) |
425 | |
{ |
426 | 0 | throw new XmlPullParserException( "Missing required value for attribute '" + attribute + "'", parser, null ); |
427 | |
} |
428 | |
} |
429 | 0 | return s; |
430 | |
} |
431 | |
|
432 | |
|
433 | |
|
434 | |
|
435 | |
|
436 | |
|
437 | |
|
438 | |
|
439 | |
|
440 | |
|
441 | |
|
442 | |
private short getShortValue( String s, String attribute, XmlPullParser parser, boolean strict ) |
443 | |
throws XmlPullParserException |
444 | |
{ |
445 | 0 | if ( s != null ) |
446 | |
{ |
447 | |
try |
448 | |
{ |
449 | 0 | return Short.valueOf( s ).shortValue(); |
450 | |
} |
451 | 0 | catch ( NumberFormatException nfe ) |
452 | |
{ |
453 | 0 | if ( strict ) |
454 | |
{ |
455 | 0 | throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a short integer", parser, nfe ); |
456 | |
} |
457 | |
} |
458 | |
} |
459 | 0 | return 0; |
460 | |
} |
461 | |
|
462 | |
|
463 | |
|
464 | |
|
465 | |
|
466 | |
|
467 | |
|
468 | |
private String getTrimmedValue( String s ) |
469 | |
{ |
470 | 0 | if ( s != null ) |
471 | |
{ |
472 | 0 | s = s.trim(); |
473 | |
} |
474 | 0 | return s; |
475 | |
} |
476 | |
|
477 | |
|
478 | |
|
479 | |
|
480 | |
|
481 | |
|
482 | |
|
483 | |
private void initParser( XmlPullParser parser ) |
484 | |
throws XmlPullParserException |
485 | |
{ |
486 | 0 | if ( addDefaultEntities ) |
487 | |
{ |
488 | |
|
489 | |
|
490 | |
|
491 | |
|
492 | 0 | parser.defineEntityReplacementText( "nbsp", "\u00a0" ); |
493 | 0 | parser.defineEntityReplacementText( "iexcl", "\u00a1" ); |
494 | 0 | parser.defineEntityReplacementText( "cent", "\u00a2" ); |
495 | 0 | parser.defineEntityReplacementText( "pound", "\u00a3" ); |
496 | 0 | parser.defineEntityReplacementText( "curren", "\u00a4" ); |
497 | 0 | parser.defineEntityReplacementText( "yen", "\u00a5" ); |
498 | 0 | parser.defineEntityReplacementText( "brvbar", "\u00a6" ); |
499 | 0 | parser.defineEntityReplacementText( "sect", "\u00a7" ); |
500 | 0 | parser.defineEntityReplacementText( "uml", "\u00a8" ); |
501 | 0 | parser.defineEntityReplacementText( "copy", "\u00a9" ); |
502 | 0 | parser.defineEntityReplacementText( "ordf", "\u00aa" ); |
503 | 0 | parser.defineEntityReplacementText( "laquo", "\u00ab" ); |
504 | 0 | parser.defineEntityReplacementText( "not", "\u00ac" ); |
505 | 0 | parser.defineEntityReplacementText( "shy", "\u00ad" ); |
506 | 0 | parser.defineEntityReplacementText( "reg", "\u00ae" ); |
507 | 0 | parser.defineEntityReplacementText( "macr", "\u00af" ); |
508 | 0 | parser.defineEntityReplacementText( "deg", "\u00b0" ); |
509 | 0 | parser.defineEntityReplacementText( "plusmn", "\u00b1" ); |
510 | 0 | parser.defineEntityReplacementText( "sup2", "\u00b2" ); |
511 | 0 | parser.defineEntityReplacementText( "sup3", "\u00b3" ); |
512 | 0 | parser.defineEntityReplacementText( "acute", "\u00b4" ); |
513 | 0 | parser.defineEntityReplacementText( "micro", "\u00b5" ); |
514 | 0 | parser.defineEntityReplacementText( "para", "\u00b6" ); |
515 | 0 | parser.defineEntityReplacementText( "middot", "\u00b7" ); |
516 | 0 | parser.defineEntityReplacementText( "cedil", "\u00b8" ); |
517 | 0 | parser.defineEntityReplacementText( "sup1", "\u00b9" ); |
518 | 0 | parser.defineEntityReplacementText( "ordm", "\u00ba" ); |
519 | 0 | parser.defineEntityReplacementText( "raquo", "\u00bb" ); |
520 | 0 | parser.defineEntityReplacementText( "frac14", "\u00bc" ); |
521 | 0 | parser.defineEntityReplacementText( "frac12", "\u00bd" ); |
522 | 0 | parser.defineEntityReplacementText( "frac34", "\u00be" ); |
523 | 0 | parser.defineEntityReplacementText( "iquest", "\u00bf" ); |
524 | 0 | parser.defineEntityReplacementText( "Agrave", "\u00c0" ); |
525 | 0 | parser.defineEntityReplacementText( "Aacute", "\u00c1" ); |
526 | 0 | parser.defineEntityReplacementText( "Acirc", "\u00c2" ); |
527 | 0 | parser.defineEntityReplacementText( "Atilde", "\u00c3" ); |
528 | 0 | parser.defineEntityReplacementText( "Auml", "\u00c4" ); |
529 | 0 | parser.defineEntityReplacementText( "Aring", "\u00c5" ); |
530 | 0 | parser.defineEntityReplacementText( "AElig", "\u00c6" ); |
531 | 0 | parser.defineEntityReplacementText( "Ccedil", "\u00c7" ); |
532 | 0 | parser.defineEntityReplacementText( "Egrave", "\u00c8" ); |
533 | 0 | parser.defineEntityReplacementText( "Eacute", "\u00c9" ); |
534 | 0 | parser.defineEntityReplacementText( "Ecirc", "\u00ca" ); |
535 | 0 | parser.defineEntityReplacementText( "Euml", "\u00cb" ); |
536 | 0 | parser.defineEntityReplacementText( "Igrave", "\u00cc" ); |
537 | 0 | parser.defineEntityReplacementText( "Iacute", "\u00cd" ); |
538 | 0 | parser.defineEntityReplacementText( "Icirc", "\u00ce" ); |
539 | 0 | parser.defineEntityReplacementText( "Iuml", "\u00cf" ); |
540 | 0 | parser.defineEntityReplacementText( "ETH", "\u00d0" ); |
541 | 0 | parser.defineEntityReplacementText( "Ntilde", "\u00d1" ); |
542 | 0 | parser.defineEntityReplacementText( "Ograve", "\u00d2" ); |
543 | 0 | parser.defineEntityReplacementText( "Oacute", "\u00d3" ); |
544 | 0 | parser.defineEntityReplacementText( "Ocirc", "\u00d4" ); |
545 | 0 | parser.defineEntityReplacementText( "Otilde", "\u00d5" ); |
546 | 0 | parser.defineEntityReplacementText( "Ouml", "\u00d6" ); |
547 | 0 | parser.defineEntityReplacementText( "times", "\u00d7" ); |
548 | 0 | parser.defineEntityReplacementText( "Oslash", "\u00d8" ); |
549 | 0 | parser.defineEntityReplacementText( "Ugrave", "\u00d9" ); |
550 | 0 | parser.defineEntityReplacementText( "Uacute", "\u00da" ); |
551 | 0 | parser.defineEntityReplacementText( "Ucirc", "\u00db" ); |
552 | 0 | parser.defineEntityReplacementText( "Uuml", "\u00dc" ); |
553 | 0 | parser.defineEntityReplacementText( "Yacute", "\u00dd" ); |
554 | 0 | parser.defineEntityReplacementText( "THORN", "\u00de" ); |
555 | 0 | parser.defineEntityReplacementText( "szlig", "\u00df" ); |
556 | 0 | parser.defineEntityReplacementText( "agrave", "\u00e0" ); |
557 | 0 | parser.defineEntityReplacementText( "aacute", "\u00e1" ); |
558 | 0 | parser.defineEntityReplacementText( "acirc", "\u00e2" ); |
559 | 0 | parser.defineEntityReplacementText( "atilde", "\u00e3" ); |
560 | 0 | parser.defineEntityReplacementText( "auml", "\u00e4" ); |
561 | 0 | parser.defineEntityReplacementText( "aring", "\u00e5" ); |
562 | 0 | parser.defineEntityReplacementText( "aelig", "\u00e6" ); |
563 | 0 | parser.defineEntityReplacementText( "ccedil", "\u00e7" ); |
564 | 0 | parser.defineEntityReplacementText( "egrave", "\u00e8" ); |
565 | 0 | parser.defineEntityReplacementText( "eacute", "\u00e9" ); |
566 | 0 | parser.defineEntityReplacementText( "ecirc", "\u00ea" ); |
567 | 0 | parser.defineEntityReplacementText( "euml", "\u00eb" ); |
568 | 0 | parser.defineEntityReplacementText( "igrave", "\u00ec" ); |
569 | 0 | parser.defineEntityReplacementText( "iacute", "\u00ed" ); |
570 | 0 | parser.defineEntityReplacementText( "icirc", "\u00ee" ); |
571 | 0 | parser.defineEntityReplacementText( "iuml", "\u00ef" ); |
572 | 0 | parser.defineEntityReplacementText( "eth", "\u00f0" ); |
573 | 0 | parser.defineEntityReplacementText( "ntilde", "\u00f1" ); |
574 | 0 | parser.defineEntityReplacementText( "ograve", "\u00f2" ); |
575 | 0 | parser.defineEntityReplacementText( "oacute", "\u00f3" ); |
576 | 0 | parser.defineEntityReplacementText( "ocirc", "\u00f4" ); |
577 | 0 | parser.defineEntityReplacementText( "otilde", "\u00f5" ); |
578 | 0 | parser.defineEntityReplacementText( "ouml", "\u00f6" ); |
579 | 0 | parser.defineEntityReplacementText( "divide", "\u00f7" ); |
580 | 0 | parser.defineEntityReplacementText( "oslash", "\u00f8" ); |
581 | 0 | parser.defineEntityReplacementText( "ugrave", "\u00f9" ); |
582 | 0 | parser.defineEntityReplacementText( "uacute", "\u00fa" ); |
583 | 0 | parser.defineEntityReplacementText( "ucirc", "\u00fb" ); |
584 | 0 | parser.defineEntityReplacementText( "uuml", "\u00fc" ); |
585 | 0 | parser.defineEntityReplacementText( "yacute", "\u00fd" ); |
586 | 0 | parser.defineEntityReplacementText( "thorn", "\u00fe" ); |
587 | 0 | parser.defineEntityReplacementText( "yuml", "\u00ff" ); |
588 | |
|
589 | |
|
590 | |
|
591 | |
|
592 | |
|
593 | 0 | parser.defineEntityReplacementText( "OElig", "\u0152" ); |
594 | 0 | parser.defineEntityReplacementText( "oelig", "\u0153" ); |
595 | 0 | parser.defineEntityReplacementText( "Scaron", "\u0160" ); |
596 | 0 | parser.defineEntityReplacementText( "scaron", "\u0161" ); |
597 | 0 | parser.defineEntityReplacementText( "Yuml", "\u0178" ); |
598 | 0 | parser.defineEntityReplacementText( "circ", "\u02c6" ); |
599 | 0 | parser.defineEntityReplacementText( "tilde", "\u02dc" ); |
600 | 0 | parser.defineEntityReplacementText( "ensp", "\u2002" ); |
601 | 0 | parser.defineEntityReplacementText( "emsp", "\u2003" ); |
602 | 0 | parser.defineEntityReplacementText( "thinsp", "\u2009" ); |
603 | 0 | parser.defineEntityReplacementText( "zwnj", "\u200c" ); |
604 | 0 | parser.defineEntityReplacementText( "zwj", "\u200d" ); |
605 | 0 | parser.defineEntityReplacementText( "lrm", "\u200e" ); |
606 | 0 | parser.defineEntityReplacementText( "rlm", "\u200f" ); |
607 | 0 | parser.defineEntityReplacementText( "ndash", "\u2013" ); |
608 | 0 | parser.defineEntityReplacementText( "mdash", "\u2014" ); |
609 | 0 | parser.defineEntityReplacementText( "lsquo", "\u2018" ); |
610 | 0 | parser.defineEntityReplacementText( "rsquo", "\u2019" ); |
611 | 0 | parser.defineEntityReplacementText( "sbquo", "\u201a" ); |
612 | 0 | parser.defineEntityReplacementText( "ldquo", "\u201c" ); |
613 | 0 | parser.defineEntityReplacementText( "rdquo", "\u201d" ); |
614 | 0 | parser.defineEntityReplacementText( "bdquo", "\u201e" ); |
615 | 0 | parser.defineEntityReplacementText( "dagger", "\u2020" ); |
616 | 0 | parser.defineEntityReplacementText( "Dagger", "\u2021" ); |
617 | 0 | parser.defineEntityReplacementText( "permil", "\u2030" ); |
618 | 0 | parser.defineEntityReplacementText( "lsaquo", "\u2039" ); |
619 | 0 | parser.defineEntityReplacementText( "rsaquo", "\u203a" ); |
620 | 0 | parser.defineEntityReplacementText( "euro", "\u20ac" ); |
621 | |
|
622 | |
|
623 | |
|
624 | |
|
625 | |
|
626 | 0 | parser.defineEntityReplacementText( "fnof", "\u0192" ); |
627 | 0 | parser.defineEntityReplacementText( "Alpha", "\u0391" ); |
628 | 0 | parser.defineEntityReplacementText( "Beta", "\u0392" ); |
629 | 0 | parser.defineEntityReplacementText( "Gamma", "\u0393" ); |
630 | 0 | parser.defineEntityReplacementText( "Delta", "\u0394" ); |
631 | 0 | parser.defineEntityReplacementText( "Epsilon", "\u0395" ); |
632 | 0 | parser.defineEntityReplacementText( "Zeta", "\u0396" ); |
633 | 0 | parser.defineEntityReplacementText( "Eta", "\u0397" ); |
634 | 0 | parser.defineEntityReplacementText( "Theta", "\u0398" ); |
635 | 0 | parser.defineEntityReplacementText( "Iota", "\u0399" ); |
636 | 0 | parser.defineEntityReplacementText( "Kappa", "\u039a" ); |
637 | 0 | parser.defineEntityReplacementText( "Lambda", "\u039b" ); |
638 | 0 | parser.defineEntityReplacementText( "Mu", "\u039c" ); |
639 | 0 | parser.defineEntityReplacementText( "Nu", "\u039d" ); |
640 | 0 | parser.defineEntityReplacementText( "Xi", "\u039e" ); |
641 | 0 | parser.defineEntityReplacementText( "Omicron", "\u039f" ); |
642 | 0 | parser.defineEntityReplacementText( "Pi", "\u03a0" ); |
643 | 0 | parser.defineEntityReplacementText( "Rho", "\u03a1" ); |
644 | 0 | parser.defineEntityReplacementText( "Sigma", "\u03a3" ); |
645 | 0 | parser.defineEntityReplacementText( "Tau", "\u03a4" ); |
646 | 0 | parser.defineEntityReplacementText( "Upsilon", "\u03a5" ); |
647 | 0 | parser.defineEntityReplacementText( "Phi", "\u03a6" ); |
648 | 0 | parser.defineEntityReplacementText( "Chi", "\u03a7" ); |
649 | 0 | parser.defineEntityReplacementText( "Psi", "\u03a8" ); |
650 | 0 | parser.defineEntityReplacementText( "Omega", "\u03a9" ); |
651 | 0 | parser.defineEntityReplacementText( "alpha", "\u03b1" ); |
652 | 0 | parser.defineEntityReplacementText( "beta", "\u03b2" ); |
653 | 0 | parser.defineEntityReplacementText( "gamma", "\u03b3" ); |
654 | 0 | parser.defineEntityReplacementText( "delta", "\u03b4" ); |
655 | 0 | parser.defineEntityReplacementText( "epsilon", "\u03b5" ); |
656 | 0 | parser.defineEntityReplacementText( "zeta", "\u03b6" ); |
657 | 0 | parser.defineEntityReplacementText( "eta", "\u03b7" ); |
658 | 0 | parser.defineEntityReplacementText( "theta", "\u03b8" ); |
659 | 0 | parser.defineEntityReplacementText( "iota", "\u03b9" ); |
660 | 0 | parser.defineEntityReplacementText( "kappa", "\u03ba" ); |
661 | 0 | parser.defineEntityReplacementText( "lambda", "\u03bb" ); |
662 | 0 | parser.defineEntityReplacementText( "mu", "\u03bc" ); |
663 | 0 | parser.defineEntityReplacementText( "nu", "\u03bd" ); |
664 | 0 | parser.defineEntityReplacementText( "xi", "\u03be" ); |
665 | 0 | parser.defineEntityReplacementText( "omicron", "\u03bf" ); |
666 | 0 | parser.defineEntityReplacementText( "pi", "\u03c0" ); |
667 | 0 | parser.defineEntityReplacementText( "rho", "\u03c1" ); |
668 | 0 | parser.defineEntityReplacementText( "sigmaf", "\u03c2" ); |
669 | 0 | parser.defineEntityReplacementText( "sigma", "\u03c3" ); |
670 | 0 | parser.defineEntityReplacementText( "tau", "\u03c4" ); |
671 | 0 | parser.defineEntityReplacementText( "upsilon", "\u03c5" ); |
672 | 0 | parser.defineEntityReplacementText( "phi", "\u03c6" ); |
673 | 0 | parser.defineEntityReplacementText( "chi", "\u03c7" ); |
674 | 0 | parser.defineEntityReplacementText( "psi", "\u03c8" ); |
675 | 0 | parser.defineEntityReplacementText( "omega", "\u03c9" ); |
676 | 0 | parser.defineEntityReplacementText( "thetasym", "\u03d1" ); |
677 | 0 | parser.defineEntityReplacementText( "upsih", "\u03d2" ); |
678 | 0 | parser.defineEntityReplacementText( "piv", "\u03d6" ); |
679 | 0 | parser.defineEntityReplacementText( "bull", "\u2022" ); |
680 | 0 | parser.defineEntityReplacementText( "hellip", "\u2026" ); |
681 | 0 | parser.defineEntityReplacementText( "prime", "\u2032" ); |
682 | 0 | parser.defineEntityReplacementText( "Prime", "\u2033" ); |
683 | 0 | parser.defineEntityReplacementText( "oline", "\u203e" ); |
684 | 0 | parser.defineEntityReplacementText( "frasl", "\u2044" ); |
685 | 0 | parser.defineEntityReplacementText( "weierp", "\u2118" ); |
686 | 0 | parser.defineEntityReplacementText( "image", "\u2111" ); |
687 | 0 | parser.defineEntityReplacementText( "real", "\u211c" ); |
688 | 0 | parser.defineEntityReplacementText( "trade", "\u2122" ); |
689 | 0 | parser.defineEntityReplacementText( "alefsym", "\u2135" ); |
690 | 0 | parser.defineEntityReplacementText( "larr", "\u2190" ); |
691 | 0 | parser.defineEntityReplacementText( "uarr", "\u2191" ); |
692 | 0 | parser.defineEntityReplacementText( "rarr", "\u2192" ); |
693 | 0 | parser.defineEntityReplacementText( "darr", "\u2193" ); |
694 | 0 | parser.defineEntityReplacementText( "harr", "\u2194" ); |
695 | 0 | parser.defineEntityReplacementText( "crarr", "\u21b5" ); |
696 | 0 | parser.defineEntityReplacementText( "lArr", "\u21d0" ); |
697 | 0 | parser.defineEntityReplacementText( "uArr", "\u21d1" ); |
698 | 0 | parser.defineEntityReplacementText( "rArr", "\u21d2" ); |
699 | 0 | parser.defineEntityReplacementText( "dArr", "\u21d3" ); |
700 | 0 | parser.defineEntityReplacementText( "hArr", "\u21d4" ); |
701 | 0 | parser.defineEntityReplacementText( "forall", "\u2200" ); |
702 | 0 | parser.defineEntityReplacementText( "part", "\u2202" ); |
703 | 0 | parser.defineEntityReplacementText( "exist", "\u2203" ); |
704 | 0 | parser.defineEntityReplacementText( "empty", "\u2205" ); |
705 | 0 | parser.defineEntityReplacementText( "nabla", "\u2207" ); |
706 | 0 | parser.defineEntityReplacementText( "isin", "\u2208" ); |
707 | 0 | parser.defineEntityReplacementText( "notin", "\u2209" ); |
708 | 0 | parser.defineEntityReplacementText( "ni", "\u220b" ); |
709 | 0 | parser.defineEntityReplacementText( "prod", "\u220f" ); |
710 | 0 | parser.defineEntityReplacementText( "sum", "\u2211" ); |
711 | 0 | parser.defineEntityReplacementText( "minus", "\u2212" ); |
712 | 0 | parser.defineEntityReplacementText( "lowast", "\u2217" ); |
713 | 0 | parser.defineEntityReplacementText( "radic", "\u221a" ); |
714 | 0 | parser.defineEntityReplacementText( "prop", "\u221d" ); |
715 | 0 | parser.defineEntityReplacementText( "infin", "\u221e" ); |
716 | 0 | parser.defineEntityReplacementText( "ang", "\u2220" ); |
717 | 0 | parser.defineEntityReplacementText( "and", "\u2227" ); |
718 | 0 | parser.defineEntityReplacementText( "or", "\u2228" ); |
719 | 0 | parser.defineEntityReplacementText( "cap", "\u2229" ); |
720 | 0 | parser.defineEntityReplacementText( "cup", "\u222a" ); |
721 | 0 | parser.defineEntityReplacementText( "int", "\u222b" ); |
722 | 0 | parser.defineEntityReplacementText( "there4", "\u2234" ); |
723 | 0 | parser.defineEntityReplacementText( "sim", "\u223c" ); |
724 | 0 | parser.defineEntityReplacementText( "cong", "\u2245" ); |
725 | 0 | parser.defineEntityReplacementText( "asymp", "\u2248" ); |
726 | 0 | parser.defineEntityReplacementText( "ne", "\u2260" ); |
727 | 0 | parser.defineEntityReplacementText( "equiv", "\u2261" ); |
728 | 0 | parser.defineEntityReplacementText( "le", "\u2264" ); |
729 | 0 | parser.defineEntityReplacementText( "ge", "\u2265" ); |
730 | 0 | parser.defineEntityReplacementText( "sub", "\u2282" ); |
731 | 0 | parser.defineEntityReplacementText( "sup", "\u2283" ); |
732 | 0 | parser.defineEntityReplacementText( "nsub", "\u2284" ); |
733 | 0 | parser.defineEntityReplacementText( "sube", "\u2286" ); |
734 | 0 | parser.defineEntityReplacementText( "supe", "\u2287" ); |
735 | 0 | parser.defineEntityReplacementText( "oplus", "\u2295" ); |
736 | 0 | parser.defineEntityReplacementText( "otimes", "\u2297" ); |
737 | 0 | parser.defineEntityReplacementText( "perp", "\u22a5" ); |
738 | 0 | parser.defineEntityReplacementText( "sdot", "\u22c5" ); |
739 | 0 | parser.defineEntityReplacementText( "lceil", "\u2308" ); |
740 | 0 | parser.defineEntityReplacementText( "rceil", "\u2309" ); |
741 | 0 | parser.defineEntityReplacementText( "lfloor", "\u230a" ); |
742 | 0 | parser.defineEntityReplacementText( "rfloor", "\u230b" ); |
743 | 0 | parser.defineEntityReplacementText( "lang", "\u2329" ); |
744 | 0 | parser.defineEntityReplacementText( "rang", "\u232a" ); |
745 | 0 | parser.defineEntityReplacementText( "loz", "\u25ca" ); |
746 | 0 | parser.defineEntityReplacementText( "spades", "\u2660" ); |
747 | 0 | parser.defineEntityReplacementText( "clubs", "\u2663" ); |
748 | 0 | parser.defineEntityReplacementText( "hearts", "\u2665" ); |
749 | 0 | parser.defineEntityReplacementText( "diams", "\u2666" ); |
750 | |
|
751 | |
} |
752 | 0 | } |
753 | |
|
754 | |
|
755 | |
|
756 | |
|
757 | |
|
758 | |
|
759 | |
|
760 | |
|
761 | |
|
762 | |
private int nextTag( XmlPullParser parser ) |
763 | |
throws IOException, XmlPullParserException |
764 | |
{ |
765 | 0 | int eventType = parser.next(); |
766 | 0 | if ( eventType == XmlPullParser.TEXT ) |
767 | |
{ |
768 | 0 | eventType = parser.next(); |
769 | |
} |
770 | 0 | if ( eventType != XmlPullParser.START_TAG && eventType != XmlPullParser.END_TAG ) |
771 | |
{ |
772 | 0 | throw new XmlPullParserException( "expected START_TAG or END_TAG not " + XmlPullParser.TYPES[eventType], parser, null ); |
773 | |
} |
774 | 0 | return eventType; |
775 | |
} |
776 | |
|
777 | |
|
778 | |
|
779 | |
|
780 | |
|
781 | |
|
782 | |
|
783 | |
|
784 | |
|
785 | |
|
786 | |
private BuildJob parseBuildJob( XmlPullParser parser, boolean strict ) |
787 | |
throws IOException, XmlPullParserException |
788 | |
{ |
789 | 0 | String tagName = parser.getName(); |
790 | 0 | BuildJob buildJob = new BuildJob(); |
791 | 0 | for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) |
792 | |
{ |
793 | 0 | String name = parser.getAttributeName( i ); |
794 | 0 | String value = parser.getAttributeValue( i ); |
795 | |
|
796 | 0 | if ( name.indexOf( ':' ) >= 0 ) |
797 | |
{ |
798 | |
|
799 | |
} |
800 | 0 | else if ( "xmlns".equals( name ) ) |
801 | |
{ |
802 | |
|
803 | |
} |
804 | 0 | else if ( "project".equals( name ) ) |
805 | |
{ |
806 | 0 | buildJob.setProject( getTrimmedValue( value ) ); |
807 | |
} |
808 | 0 | else if ( "name".equals( name ) ) |
809 | |
{ |
810 | 0 | buildJob.setName( getTrimmedValue( value ) ); |
811 | |
} |
812 | 0 | else if ( "description".equals( name ) ) |
813 | |
{ |
814 | 0 | buildJob.setDescription( getTrimmedValue( value ) ); |
815 | |
} |
816 | 0 | else if ( "result".equals( name ) ) |
817 | |
{ |
818 | 0 | buildJob.setResult( getTrimmedValue( value ) ); |
819 | |
} |
820 | 0 | else if ( "time".equals( name ) ) |
821 | |
{ |
822 | 0 | buildJob.setTime( getDoubleValue( getTrimmedValue( value ), "time", parser, strict ) ); |
823 | |
} |
824 | 0 | else if ( "type".equals( name ) ) |
825 | |
{ |
826 | 0 | buildJob.setType( getTrimmedValue( value ) ); |
827 | |
} |
828 | |
else |
829 | |
{ |
830 | 0 | checkUnknownAttribute( parser, name, tagName, strict ); |
831 | |
} |
832 | |
} |
833 | 0 | java.util.Set parsed = new java.util.HashSet(); |
834 | 0 | while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) |
835 | |
{ |
836 | 0 | if ( checkFieldWithDuplicate( parser, "failureMessage", null, parsed ) ) |
837 | |
{ |
838 | 0 | buildJob.setFailureMessage( getTrimmedValue( parser.nextText() ) ); |
839 | |
} |
840 | |
else |
841 | |
{ |
842 | 0 | checkUnknownElement( parser, strict ); |
843 | |
} |
844 | |
} |
845 | 0 | return buildJob; |
846 | |
} |
847 | |
|
848 | |
|
849 | |
|
850 | |
|
851 | |
|
852 | |
|
853 | |
|
854 | |
|
855 | |
|
856 | |
|
857 | |
public BuildJob read( Reader reader, boolean strict ) |
858 | |
throws IOException, XmlPullParserException |
859 | |
{ |
860 | 0 | XmlPullParser parser = new MXParser(); |
861 | |
|
862 | 0 | parser.setInput( reader ); |
863 | |
|
864 | 0 | initParser( parser ); |
865 | |
|
866 | 0 | return read( parser, strict ); |
867 | |
} |
868 | |
|
869 | |
|
870 | |
|
871 | |
|
872 | |
|
873 | |
|
874 | |
|
875 | |
|
876 | |
|
877 | |
public BuildJob read( Reader reader ) |
878 | |
throws IOException, XmlPullParserException |
879 | |
{ |
880 | 0 | return read( reader, true ); |
881 | |
} |
882 | |
|
883 | |
|
884 | |
|
885 | |
|
886 | |
|
887 | |
|
888 | |
|
889 | |
|
890 | |
|
891 | |
|
892 | |
public BuildJob read( InputStream in, boolean strict ) |
893 | |
throws IOException, XmlPullParserException |
894 | |
{ |
895 | 0 | return read( ReaderFactory.newXmlReader( in ), strict ); |
896 | |
} |
897 | |
|
898 | |
|
899 | |
|
900 | |
|
901 | |
|
902 | |
|
903 | |
|
904 | |
|
905 | |
|
906 | |
public BuildJob read( InputStream in ) |
907 | |
throws IOException, XmlPullParserException |
908 | |
{ |
909 | 0 | return read( ReaderFactory.newXmlReader( in ) ); |
910 | |
} |
911 | |
|
912 | |
|
913 | |
|
914 | |
|
915 | |
|
916 | |
|
917 | |
|
918 | |
|
919 | |
|
920 | |
|
921 | |
private BuildJob read( XmlPullParser parser, boolean strict ) |
922 | |
throws IOException, XmlPullParserException |
923 | |
{ |
924 | 0 | int eventType = parser.getEventType(); |
925 | 0 | while ( eventType != XmlPullParser.END_DOCUMENT ) |
926 | |
{ |
927 | 0 | if ( eventType == XmlPullParser.START_TAG ) |
928 | |
{ |
929 | 0 | if ( strict && ! "build-job".equals( parser.getName() ) ) |
930 | |
{ |
931 | 0 | throw new XmlPullParserException( "Expected root element 'build-job' but found '" + parser.getName() + "'", parser, null ); |
932 | |
} |
933 | 0 | BuildJob buildJob = parseBuildJob( parser, strict ); |
934 | 0 | buildJob.setModelEncoding( parser.getInputEncoding() ); |
935 | 0 | return buildJob; |
936 | |
} |
937 | 0 | eventType = parser.next(); |
938 | |
} |
939 | 0 | throw new XmlPullParserException( "Expected root element 'build-job' but found no element at all: invalid XML document", parser, null ); |
940 | |
} |
941 | |
|
942 | |
|
943 | |
|
944 | |
|
945 | |
|
946 | |
|
947 | |
public void setAddDefaultEntities( boolean addDefaultEntities ) |
948 | |
{ |
949 | 0 | this.addDefaultEntities = addDefaultEntities; |
950 | 0 | } |
951 | |
|
952 | |
} |