001// =================== DO NOT EDIT THIS FILE ==================== 002// Generated by Modello 1.8.3, 003// any modifications will be overwritten. 004// ============================================================== 005 006package org.apache.maven.plugin.lifecycle.io.xpp3; 007 008 //---------------------------------/ 009 //- Imported classes and packages -/ 010//---------------------------------/ 011 012import java.io.IOException; 013import java.io.InputStream; 014import java.io.Reader; 015import java.text.DateFormat; 016import org.apache.maven.plugin.lifecycle.Execution; 017import org.apache.maven.plugin.lifecycle.Lifecycle; 018import org.apache.maven.plugin.lifecycle.LifecycleConfiguration; 019import org.apache.maven.plugin.lifecycle.Phase; 020import org.codehaus.plexus.util.ReaderFactory; 021import org.codehaus.plexus.util.xml.pull.EntityReplacementMap; 022import org.codehaus.plexus.util.xml.pull.MXParser; 023import org.codehaus.plexus.util.xml.pull.XmlPullParser; 024import org.codehaus.plexus.util.xml.pull.XmlPullParserException; 025 026/** 027 * Class LifecycleMappingsXpp3Reader. 028 * 029 * @version $Revision$ $Date$ 030 */ 031@SuppressWarnings( "all" ) 032public class LifecycleMappingsXpp3Reader 033{ 034 035 //--------------------------/ 036 //- Class/Member Variables -/ 037 //--------------------------/ 038 039 /** 040 * If set the parser will be loaded with all single characters 041 * from the XHTML specification. 042 * The entities used: 043 * <ul> 044 * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent</li> 045 * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent</li> 046 * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent</li> 047 * </ul> 048 */ 049 private boolean addDefaultEntities = true; 050 051 /** 052 * Field contentTransformer. 053 */ 054 public final ContentTransformer contentTransformer; 055 056 057 //----------------/ 058 //- Constructors -/ 059 //----------------/ 060 061 public LifecycleMappingsXpp3Reader() 062 { 063 this( new ContentTransformer() 064 { 065 public String transform( String source, String fieldName ) 066 { 067 return source; 068 } 069 } ); 070 } //-- org.apache.maven.plugin.lifecycle.io.xpp3.LifecycleMappingsXpp3Reader() 071 072 public LifecycleMappingsXpp3Reader(ContentTransformer contentTransformer) 073 { 074 this.contentTransformer = contentTransformer; 075 } //-- org.apache.maven.plugin.lifecycle.io.xpp3.LifecycleMappingsXpp3Reader(ContentTransformer) 076 077 078 //-----------/ 079 //- Methods -/ 080 //-----------/ 081 082 /** 083 * Method checkFieldWithDuplicate. 084 * 085 * @param parser 086 * @param parsed 087 * @param alias 088 * @param tagName 089 * @throws XmlPullParserException 090 * @return boolean 091 */ 092 private boolean checkFieldWithDuplicate( XmlPullParser parser, String tagName, String alias, java.util.Set parsed ) 093 throws XmlPullParserException 094 { 095 if ( !( parser.getName().equals( tagName ) || parser.getName().equals( alias ) ) ) 096 { 097 return false; 098 } 099 if ( !parsed.add( tagName ) ) 100 { 101 throw new XmlPullParserException( "Duplicated tag: '" + tagName + "'", parser, null ); 102 } 103 return true; 104 } //-- boolean checkFieldWithDuplicate( XmlPullParser, String, String, java.util.Set ) 105 106 /** 107 * Method checkUnknownAttribute. 108 * 109 * @param parser 110 * @param strict 111 * @param tagName 112 * @param attribute 113 * @throws XmlPullParserException 114 * @throws IOException 115 */ 116 private void checkUnknownAttribute( XmlPullParser parser, String attribute, String tagName, boolean strict ) 117 throws XmlPullParserException, IOException 118 { 119 // strictXmlAttributes = true for model: if strict == true, not only elements are checked but attributes too 120 if ( strict ) 121 { 122 throw new XmlPullParserException( "Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser, null ); 123 } 124 } //-- void checkUnknownAttribute( XmlPullParser, String, String, boolean ) 125 126 /** 127 * Method checkUnknownElement. 128 * 129 * @param parser 130 * @param strict 131 * @throws XmlPullParserException 132 * @throws IOException 133 */ 134 private void checkUnknownElement( XmlPullParser parser, boolean strict ) 135 throws XmlPullParserException, IOException 136 { 137 if ( strict ) 138 { 139 throw new XmlPullParserException( "Unrecognised tag: '" + parser.getName() + "'", parser, null ); 140 } 141 142 for ( int unrecognizedTagCount = 1; unrecognizedTagCount > 0; ) 143 { 144 int eventType = parser.next(); 145 if ( eventType == XmlPullParser.START_TAG ) 146 { 147 unrecognizedTagCount++; 148 } 149 else if ( eventType == XmlPullParser.END_TAG ) 150 { 151 unrecognizedTagCount--; 152 } 153 } 154 } //-- void checkUnknownElement( XmlPullParser, boolean ) 155 156 /** 157 * Returns the state of the "add default entities" flag. 158 * 159 * @return boolean 160 */ 161 public boolean getAddDefaultEntities() 162 { 163 return addDefaultEntities; 164 } //-- boolean getAddDefaultEntities() 165 166 /** 167 * Method getBooleanValue. 168 * 169 * @param s 170 * @param parser 171 * @param attribute 172 * @throws XmlPullParserException 173 * @return boolean 174 */ 175 private boolean getBooleanValue( String s, String attribute, XmlPullParser parser ) 176 throws XmlPullParserException 177 { 178 return getBooleanValue( s, attribute, parser, null ); 179 } //-- boolean getBooleanValue( String, String, XmlPullParser ) 180 181 /** 182 * Method getBooleanValue. 183 * 184 * @param s 185 * @param defaultValue 186 * @param parser 187 * @param attribute 188 * @throws XmlPullParserException 189 * @return boolean 190 */ 191 private boolean getBooleanValue( String s, String attribute, XmlPullParser parser, String defaultValue ) 192 throws XmlPullParserException 193 { 194 if ( s != null && s.length() != 0 ) 195 { 196 return Boolean.valueOf( s ).booleanValue(); 197 } 198 if ( defaultValue != null ) 199 { 200 return Boolean.valueOf( defaultValue ).booleanValue(); 201 } 202 return false; 203 } //-- boolean getBooleanValue( String, String, XmlPullParser, String ) 204 205 /** 206 * Method getByteValue. 207 * 208 * @param s 209 * @param strict 210 * @param parser 211 * @param attribute 212 * @throws XmlPullParserException 213 * @return byte 214 */ 215 private byte getByteValue( String s, String attribute, XmlPullParser parser, boolean strict ) 216 throws XmlPullParserException 217 { 218 if ( s != null ) 219 { 220 try 221 { 222 return Byte.valueOf( s ).byteValue(); 223 } 224 catch ( NumberFormatException nfe ) 225 { 226 if ( strict ) 227 { 228 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a byte", parser, nfe ); 229 } 230 } 231 } 232 return 0; 233 } //-- byte getByteValue( String, String, XmlPullParser, boolean ) 234 235 /** 236 * Method getCharacterValue. 237 * 238 * @param s 239 * @param parser 240 * @param attribute 241 * @throws XmlPullParserException 242 * @return char 243 */ 244 private char getCharacterValue( String s, String attribute, XmlPullParser parser ) 245 throws XmlPullParserException 246 { 247 if ( s != null ) 248 { 249 return s.charAt( 0 ); 250 } 251 return 0; 252 } //-- char getCharacterValue( String, String, XmlPullParser ) 253 254 /** 255 * Method getDateValue. 256 * 257 * @param s 258 * @param parser 259 * @param attribute 260 * @throws XmlPullParserException 261 * @return Date 262 */ 263 private java.util.Date getDateValue( String s, String attribute, XmlPullParser parser ) 264 throws XmlPullParserException 265 { 266 return getDateValue( s, attribute, null, parser ); 267 } //-- java.util.Date getDateValue( String, String, XmlPullParser ) 268 269 /** 270 * Method getDateValue. 271 * 272 * @param s 273 * @param parser 274 * @param dateFormat 275 * @param attribute 276 * @throws XmlPullParserException 277 * @return Date 278 */ 279 private java.util.Date getDateValue( String s, String attribute, String dateFormat, XmlPullParser parser ) 280 throws XmlPullParserException 281 { 282 if ( s != null ) 283 { 284 String effectiveDateFormat = dateFormat; 285 if ( dateFormat == null ) 286 { 287 effectiveDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS"; 288 } 289 if ( "long".equals( effectiveDateFormat ) ) 290 { 291 try 292 { 293 return new java.util.Date( Long.parseLong( s ) ); 294 } 295 catch ( NumberFormatException e ) 296 { 297 throw new XmlPullParserException( e.getMessage(), parser, e ); 298 } 299 } 300 else 301 { 302 try 303 { 304 DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, java.util.Locale.US ); 305 return dateParser.parse( s ); 306 } 307 catch ( java.text.ParseException e ) 308 { 309 throw new XmlPullParserException( e.getMessage(), parser, e ); 310 } 311 } 312 } 313 return null; 314 } //-- java.util.Date getDateValue( String, String, String, XmlPullParser ) 315 316 /** 317 * Method getDoubleValue. 318 * 319 * @param s 320 * @param strict 321 * @param parser 322 * @param attribute 323 * @throws XmlPullParserException 324 * @return double 325 */ 326 private double getDoubleValue( String s, String attribute, XmlPullParser parser, boolean strict ) 327 throws XmlPullParserException 328 { 329 if ( s != null ) 330 { 331 try 332 { 333 return Double.valueOf( s ).doubleValue(); 334 } 335 catch ( NumberFormatException nfe ) 336 { 337 if ( strict ) 338 { 339 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe ); 340 } 341 } 342 } 343 return 0; 344 } //-- double getDoubleValue( String, String, XmlPullParser, boolean ) 345 346 /** 347 * Method getFloatValue. 348 * 349 * @param s 350 * @param strict 351 * @param parser 352 * @param attribute 353 * @throws XmlPullParserException 354 * @return float 355 */ 356 private float getFloatValue( String s, String attribute, XmlPullParser parser, boolean strict ) 357 throws XmlPullParserException 358 { 359 if ( s != null ) 360 { 361 try 362 { 363 return Float.valueOf( s ).floatValue(); 364 } 365 catch ( NumberFormatException nfe ) 366 { 367 if ( strict ) 368 { 369 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe ); 370 } 371 } 372 } 373 return 0; 374 } //-- float getFloatValue( String, String, XmlPullParser, boolean ) 375 376 /** 377 * Method getIntegerValue. 378 * 379 * @param s 380 * @param strict 381 * @param parser 382 * @param attribute 383 * @throws XmlPullParserException 384 * @return int 385 */ 386 private int getIntegerValue( String s, String attribute, XmlPullParser parser, boolean strict ) 387 throws XmlPullParserException 388 { 389 if ( s != null ) 390 { 391 try 392 { 393 return Integer.valueOf( s ).intValue(); 394 } 395 catch ( NumberFormatException nfe ) 396 { 397 if ( strict ) 398 { 399 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be an integer", parser, nfe ); 400 } 401 } 402 } 403 return 0; 404 } //-- int getIntegerValue( String, String, XmlPullParser, boolean ) 405 406 /** 407 * Method getLongValue. 408 * 409 * @param s 410 * @param strict 411 * @param parser 412 * @param attribute 413 * @throws XmlPullParserException 414 * @return long 415 */ 416 private long getLongValue( String s, String attribute, XmlPullParser parser, boolean strict ) 417 throws XmlPullParserException 418 { 419 if ( s != null ) 420 { 421 try 422 { 423 return Long.valueOf( s ).longValue(); 424 } 425 catch ( NumberFormatException nfe ) 426 { 427 if ( strict ) 428 { 429 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a long integer", parser, nfe ); 430 } 431 } 432 } 433 return 0; 434 } //-- long getLongValue( String, String, XmlPullParser, boolean ) 435 436 /** 437 * Method getRequiredAttributeValue. 438 * 439 * @param s 440 * @param strict 441 * @param parser 442 * @param attribute 443 * @throws XmlPullParserException 444 * @return String 445 */ 446 private String getRequiredAttributeValue( String s, String attribute, XmlPullParser parser, boolean strict ) 447 throws XmlPullParserException 448 { 449 if ( s == null ) 450 { 451 if ( strict ) 452 { 453 throw new XmlPullParserException( "Missing required value for attribute '" + attribute + "'", parser, null ); 454 } 455 } 456 return s; 457 } //-- String getRequiredAttributeValue( String, String, XmlPullParser, boolean ) 458 459 /** 460 * Method getShortValue. 461 * 462 * @param s 463 * @param strict 464 * @param parser 465 * @param attribute 466 * @throws XmlPullParserException 467 * @return short 468 */ 469 private short getShortValue( String s, String attribute, XmlPullParser parser, boolean strict ) 470 throws XmlPullParserException 471 { 472 if ( s != null ) 473 { 474 try 475 { 476 return Short.valueOf( s ).shortValue(); 477 } 478 catch ( NumberFormatException nfe ) 479 { 480 if ( strict ) 481 { 482 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a short integer", parser, nfe ); 483 } 484 } 485 } 486 return 0; 487 } //-- short getShortValue( String, String, XmlPullParser, boolean ) 488 489 /** 490 * Method getTrimmedValue. 491 * 492 * @param s 493 * @return String 494 */ 495 private String getTrimmedValue( String s ) 496 { 497 if ( s != null ) 498 { 499 s = s.trim(); 500 } 501 return s; 502 } //-- String getTrimmedValue( String ) 503 504 /** 505 * Method interpolatedTrimmed. 506 * 507 * @param value 508 * @param context 509 * @return String 510 */ 511 private String interpolatedTrimmed( String value, String context ) 512 { 513 return getTrimmedValue( contentTransformer.transform( value, context ) ); 514 } //-- String interpolatedTrimmed( String, String ) 515 516 /** 517 * Method nextTag. 518 * 519 * @param parser 520 * @throws IOException 521 * @throws XmlPullParserException 522 * @return int 523 */ 524 private int nextTag( XmlPullParser parser ) 525 throws IOException, XmlPullParserException 526 { 527 int eventType = parser.next(); 528 if ( eventType == XmlPullParser.TEXT ) 529 { 530 eventType = parser.next(); 531 } 532 if ( eventType != XmlPullParser.START_TAG && eventType != XmlPullParser.END_TAG ) 533 { 534 throw new XmlPullParserException( "expected START_TAG or END_TAG not " + XmlPullParser.TYPES[eventType], parser, null ); 535 } 536 return eventType; 537 } //-- int nextTag( XmlPullParser ) 538 539 /** 540 * @see ReaderFactory#newXmlReader 541 * 542 * @param reader 543 * @param strict 544 * @throws IOException 545 * @throws XmlPullParserException 546 * @return LifecycleConfiguration 547 */ 548 public LifecycleConfiguration read( Reader reader, boolean strict ) 549 throws IOException, XmlPullParserException 550 { 551 XmlPullParser parser = addDefaultEntities ? new MXParser(EntityReplacementMap.defaultEntityReplacementMap) : new MXParser( ); 552 553 parser.setInput( reader ); 554 555 556 return read( parser, strict ); 557 } //-- LifecycleConfiguration read( Reader, boolean ) 558 559 /** 560 * @see ReaderFactory#newXmlReader 561 * 562 * @param reader 563 * @throws IOException 564 * @throws XmlPullParserException 565 * @return LifecycleConfiguration 566 */ 567 public LifecycleConfiguration read( Reader reader ) 568 throws IOException, XmlPullParserException 569 { 570 return read( reader, true ); 571 } //-- LifecycleConfiguration read( Reader ) 572 573 /** 574 * Method read. 575 * 576 * @param in 577 * @param strict 578 * @throws IOException 579 * @throws XmlPullParserException 580 * @return LifecycleConfiguration 581 */ 582 public LifecycleConfiguration read( InputStream in, boolean strict ) 583 throws IOException, XmlPullParserException 584 { 585 return read( ReaderFactory.newXmlReader( in ), strict ); 586 } //-- LifecycleConfiguration read( InputStream, boolean ) 587 588 /** 589 * Method read. 590 * 591 * @param in 592 * @throws IOException 593 * @throws XmlPullParserException 594 * @return LifecycleConfiguration 595 */ 596 public LifecycleConfiguration read( InputStream in ) 597 throws IOException, XmlPullParserException 598 { 599 return read( ReaderFactory.newXmlReader( in ) ); 600 } //-- LifecycleConfiguration read( InputStream ) 601 602 /** 603 * Method parseExecution. 604 * 605 * @param parser 606 * @param strict 607 * @throws IOException 608 * @throws XmlPullParserException 609 * @return Execution 610 */ 611 private Execution parseExecution( XmlPullParser parser, boolean strict ) 612 throws IOException, XmlPullParserException 613 { 614 String tagName = parser.getName(); 615 Execution execution = new Execution(); 616 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 617 { 618 String name = parser.getAttributeName( i ); 619 String value = parser.getAttributeValue( i ); 620 621 if ( name.indexOf( ':' ) >= 0 ) 622 { 623 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 624 } 625 else 626 { 627 checkUnknownAttribute( parser, name, tagName, strict ); 628 } 629 } 630 java.util.Set parsed = new java.util.HashSet(); 631 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 632 { 633 if ( checkFieldWithDuplicate( parser, "configuration", null, parsed ) ) 634 { 635 execution.setConfiguration( org.codehaus.plexus.util.xml.Xpp3DomBuilder.build( parser, true ) ); 636 } 637 else if ( checkFieldWithDuplicate( parser, "goals", null, parsed ) ) 638 { 639 java.util.List goals = new java.util.ArrayList/*<String>*/(); 640 execution.setGoals( goals ); 641 while ( parser.nextTag() == XmlPullParser.START_TAG ) 642 { 643 if ( "goal".equals( parser.getName() ) ) 644 { 645 goals.add( interpolatedTrimmed( parser.nextText(), "goals" ) ); 646 } 647 else 648 { 649 checkUnknownElement( parser, strict ); 650 } 651 } 652 } 653 else 654 { 655 checkUnknownElement( parser, strict ); 656 } 657 } 658 return execution; 659 } //-- Execution parseExecution( XmlPullParser, boolean ) 660 661 /** 662 * Method parseLifecycle. 663 * 664 * @param parser 665 * @param strict 666 * @throws IOException 667 * @throws XmlPullParserException 668 * @return Lifecycle 669 */ 670 private Lifecycle parseLifecycle( XmlPullParser parser, boolean strict ) 671 throws IOException, XmlPullParserException 672 { 673 String tagName = parser.getName(); 674 Lifecycle lifecycle = new Lifecycle(); 675 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 676 { 677 String name = parser.getAttributeName( i ); 678 String value = parser.getAttributeValue( i ); 679 680 if ( name.indexOf( ':' ) >= 0 ) 681 { 682 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 683 } 684 else 685 { 686 checkUnknownAttribute( parser, name, tagName, strict ); 687 } 688 } 689 java.util.Set parsed = new java.util.HashSet(); 690 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 691 { 692 if ( checkFieldWithDuplicate( parser, "id", null, parsed ) ) 693 { 694 lifecycle.setId( interpolatedTrimmed( parser.nextText(), "id" ) ); 695 } 696 else if ( checkFieldWithDuplicate( parser, "phases", null, parsed ) ) 697 { 698 java.util.List phases = new java.util.ArrayList/*<Phase>*/(); 699 lifecycle.setPhases( phases ); 700 while ( parser.nextTag() == XmlPullParser.START_TAG ) 701 { 702 if ( "phase".equals( parser.getName() ) ) 703 { 704 phases.add( parsePhase( parser, strict ) ); 705 } 706 else 707 { 708 checkUnknownElement( parser, strict ); 709 } 710 } 711 } 712 else 713 { 714 checkUnknownElement( parser, strict ); 715 } 716 } 717 return lifecycle; 718 } //-- Lifecycle parseLifecycle( XmlPullParser, boolean ) 719 720 /** 721 * Method parseLifecycleConfiguration. 722 * 723 * @param parser 724 * @param strict 725 * @throws IOException 726 * @throws XmlPullParserException 727 * @return LifecycleConfiguration 728 */ 729 private LifecycleConfiguration parseLifecycleConfiguration( XmlPullParser parser, boolean strict ) 730 throws IOException, XmlPullParserException 731 { 732 String tagName = parser.getName(); 733 LifecycleConfiguration lifecycleConfiguration = new LifecycleConfiguration(); 734 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 735 { 736 String name = parser.getAttributeName( i ); 737 String value = parser.getAttributeValue( i ); 738 739 if ( name.indexOf( ':' ) >= 0 ) 740 { 741 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 742 } 743 else if ( "xmlns".equals( name ) ) 744 { 745 // ignore xmlns attribute in root class, which is a reserved attribute name 746 } 747 else 748 { 749 checkUnknownAttribute( parser, name, tagName, strict ); 750 } 751 } 752 java.util.Set parsed = new java.util.HashSet(); 753 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 754 { 755 if ( "lifecycle".equals( parser.getName() ) ) 756 { 757 java.util.List lifecycles = lifecycleConfiguration.getLifecycles(); 758 if ( lifecycles == null ) 759 { 760 lifecycles = new java.util.ArrayList/*<Lifecycle>*/(); 761 lifecycleConfiguration.setLifecycles( lifecycles ); 762 } 763 lifecycles.add( parseLifecycle( parser, strict ) ); 764 } 765 else 766 { 767 checkUnknownElement( parser, strict ); 768 } 769 } 770 return lifecycleConfiguration; 771 } //-- LifecycleConfiguration parseLifecycleConfiguration( XmlPullParser, boolean ) 772 773 /** 774 * Method parsePhase. 775 * 776 * @param parser 777 * @param strict 778 * @throws IOException 779 * @throws XmlPullParserException 780 * @return Phase 781 */ 782 private Phase parsePhase( XmlPullParser parser, boolean strict ) 783 throws IOException, XmlPullParserException 784 { 785 String tagName = parser.getName(); 786 Phase phase = new Phase(); 787 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 788 { 789 String name = parser.getAttributeName( i ); 790 String value = parser.getAttributeValue( i ); 791 792 if ( name.indexOf( ':' ) >= 0 ) 793 { 794 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 795 } 796 else 797 { 798 checkUnknownAttribute( parser, name, tagName, strict ); 799 } 800 } 801 java.util.Set parsed = new java.util.HashSet(); 802 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 803 { 804 if ( checkFieldWithDuplicate( parser, "id", null, parsed ) ) 805 { 806 phase.setId( interpolatedTrimmed( parser.nextText(), "id" ) ); 807 } 808 else if ( checkFieldWithDuplicate( parser, "executions", null, parsed ) ) 809 { 810 java.util.List executions = new java.util.ArrayList/*<Execution>*/(); 811 phase.setExecutions( executions ); 812 while ( parser.nextTag() == XmlPullParser.START_TAG ) 813 { 814 if ( "execution".equals( parser.getName() ) ) 815 { 816 executions.add( parseExecution( parser, strict ) ); 817 } 818 else 819 { 820 checkUnknownElement( parser, strict ); 821 } 822 } 823 } 824 else if ( checkFieldWithDuplicate( parser, "configuration", null, parsed ) ) 825 { 826 phase.setConfiguration( org.codehaus.plexus.util.xml.Xpp3DomBuilder.build( parser, true ) ); 827 } 828 else 829 { 830 checkUnknownElement( parser, strict ); 831 } 832 } 833 return phase; 834 } //-- Phase parsePhase( XmlPullParser, boolean ) 835 836 /** 837 * Method read. 838 * 839 * @param parser 840 * @param strict 841 * @throws IOException 842 * @throws XmlPullParserException 843 * @return LifecycleConfiguration 844 */ 845 private LifecycleConfiguration read( XmlPullParser parser, boolean strict ) 846 throws IOException, XmlPullParserException 847 { 848 int eventType = parser.getEventType(); 849 while ( eventType != XmlPullParser.END_DOCUMENT ) 850 { 851 if ( eventType == XmlPullParser.START_TAG ) 852 { 853 if ( strict && ! "lifecycles".equals( parser.getName() ) ) 854 { 855 throw new XmlPullParserException( "Expected root element 'lifecycles' but found '" + parser.getName() + "'", parser, null ); 856 } 857 LifecycleConfiguration lifecycleConfiguration = parseLifecycleConfiguration( parser, strict ); 858 lifecycleConfiguration.setModelEncoding( parser.getInputEncoding() ); 859 return lifecycleConfiguration; 860 } 861 eventType = parser.next(); 862 } 863 throw new XmlPullParserException( "Expected root element 'lifecycles' but found no element at all: invalid XML document", parser, null ); 864 } //-- LifecycleConfiguration read( XmlPullParser, boolean ) 865 866 /** 867 * Sets the state of the "add default entities" flag. 868 * 869 * @param addDefaultEntities 870 */ 871 public void setAddDefaultEntities( boolean addDefaultEntities ) 872 { 873 this.addDefaultEntities = addDefaultEntities; 874 } //-- void setAddDefaultEntities( boolean ) 875 876 public static interface ContentTransformer 877{ 878 /** 879 * Interpolate the value read from the xpp3 document 880 * @param source The source value 881 * @param fieldName A description of the field being interpolated. The implementation may use this to 882 * log stuff. 883 * @return The interpolated value. 884 */ 885 String transform( String source, String fieldName ); 886} 887 888}