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