001// =================== DO NOT EDIT THIS FILE ==================== 002// Generated by Modello 1.8.1, 003// any modifications will be overwritten. 004// ============================================================== 005 006package org.apache.maven.profiles.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.profiles.Activation; 017import org.apache.maven.profiles.ActivationFile; 018import org.apache.maven.profiles.ActivationOS; 019import org.apache.maven.profiles.ActivationProperty; 020import org.apache.maven.profiles.Profile; 021import org.apache.maven.profiles.ProfilesRoot; 022import org.apache.maven.profiles.Repository; 023import org.apache.maven.profiles.RepositoryBase; 024import org.apache.maven.profiles.RepositoryPolicy; 025import org.codehaus.plexus.util.ReaderFactory; 026import org.codehaus.plexus.util.xml.pull.EntityReplacementMap; 027import org.codehaus.plexus.util.xml.pull.MXParser; 028import org.codehaus.plexus.util.xml.pull.XmlPullParser; 029import org.codehaus.plexus.util.xml.pull.XmlPullParserException; 030 031/** 032 * Class ProfilesXpp3Reader. 033 * 034 * @version $Revision$ $Date$ 035 */ 036@SuppressWarnings( "all" ) 037public class ProfilesXpp3Reader 038{ 039 040 //--------------------------/ 041 //- Class/Member Variables -/ 042 //--------------------------/ 043 044 /** 045 * If set the parser will be loaded with all single characters 046 * from the XHTML specification. 047 * The entities used: 048 * <ul> 049 * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent</li> 050 * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent</li> 051 * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent</li> 052 * </ul> 053 */ 054 private boolean addDefaultEntities = true; 055 056 057 //-----------/ 058 //- Methods -/ 059 //-----------/ 060 061 /** 062 * Method checkFieldWithDuplicate. 063 * 064 * @param parser 065 * @param parsed 066 * @param alias 067 * @param tagName 068 * @throws XmlPullParserException 069 * @return boolean 070 */ 071 private boolean checkFieldWithDuplicate( XmlPullParser parser, String tagName, String alias, java.util.Set parsed ) 072 throws XmlPullParserException 073 { 074 if ( !( parser.getName().equals( tagName ) || parser.getName().equals( alias ) ) ) 075 { 076 return false; 077 } 078 if ( !parsed.add( tagName ) ) 079 { 080 throw new XmlPullParserException( "Duplicated tag: '" + tagName + "'", parser, null ); 081 } 082 return true; 083 } //-- boolean checkFieldWithDuplicate( XmlPullParser, String, String, java.util.Set ) 084 085 /** 086 * Method checkUnknownAttribute. 087 * 088 * @param parser 089 * @param strict 090 * @param tagName 091 * @param attribute 092 * @throws XmlPullParserException 093 * @throws IOException 094 */ 095 private void checkUnknownAttribute( XmlPullParser parser, String attribute, String tagName, boolean strict ) 096 throws XmlPullParserException, IOException 097 { 098 // strictXmlAttributes = true for model: if strict == true, not only elements are checked but attributes too 099 if ( strict ) 100 { 101 throw new XmlPullParserException( "Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser, null ); 102 } 103 } //-- void checkUnknownAttribute( XmlPullParser, String, String, boolean ) 104 105 /** 106 * Method checkUnknownElement. 107 * 108 * @param parser 109 * @param strict 110 * @throws XmlPullParserException 111 * @throws IOException 112 */ 113 private void checkUnknownElement( XmlPullParser parser, boolean strict ) 114 throws XmlPullParserException, IOException 115 { 116 if ( strict ) 117 { 118 throw new XmlPullParserException( "Unrecognised tag: '" + parser.getName() + "'", parser, null ); 119 } 120 121 for ( int unrecognizedTagCount = 1; unrecognizedTagCount > 0; ) 122 { 123 int eventType = parser.next(); 124 if ( eventType == XmlPullParser.START_TAG ) 125 { 126 unrecognizedTagCount++; 127 } 128 else if ( eventType == XmlPullParser.END_TAG ) 129 { 130 unrecognizedTagCount--; 131 } 132 } 133 } //-- void checkUnknownElement( XmlPullParser, boolean ) 134 135 /** 136 * Returns the state of the "add default entities" flag. 137 * 138 * @return boolean 139 */ 140 public boolean getAddDefaultEntities() 141 { 142 return addDefaultEntities; 143 } //-- boolean getAddDefaultEntities() 144 145 /** 146 * Method getBooleanValue. 147 * 148 * @param s 149 * @param parser 150 * @param attribute 151 * @throws XmlPullParserException 152 * @return boolean 153 */ 154 private boolean getBooleanValue( String s, String attribute, XmlPullParser parser ) 155 throws XmlPullParserException 156 { 157 return getBooleanValue( s, attribute, parser, null ); 158 } //-- boolean getBooleanValue( String, String, XmlPullParser ) 159 160 /** 161 * Method getBooleanValue. 162 * 163 * @param s 164 * @param defaultValue 165 * @param parser 166 * @param attribute 167 * @throws XmlPullParserException 168 * @return boolean 169 */ 170 private boolean getBooleanValue( String s, String attribute, XmlPullParser parser, String defaultValue ) 171 throws XmlPullParserException 172 { 173 if ( s != null && s.length() != 0 ) 174 { 175 return Boolean.valueOf( s ).booleanValue(); 176 } 177 if ( defaultValue != null ) 178 { 179 return Boolean.valueOf( defaultValue ).booleanValue(); 180 } 181 return false; 182 } //-- boolean getBooleanValue( String, String, XmlPullParser, String ) 183 184 /** 185 * Method getByteValue. 186 * 187 * @param s 188 * @param strict 189 * @param parser 190 * @param attribute 191 * @throws XmlPullParserException 192 * @return byte 193 */ 194 private byte getByteValue( String s, String attribute, XmlPullParser parser, boolean strict ) 195 throws XmlPullParserException 196 { 197 if ( s != null ) 198 { 199 try 200 { 201 return Byte.valueOf( s ).byteValue(); 202 } 203 catch ( NumberFormatException nfe ) 204 { 205 if ( strict ) 206 { 207 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a byte", parser, nfe ); 208 } 209 } 210 } 211 return 0; 212 } //-- byte getByteValue( String, String, XmlPullParser, boolean ) 213 214 /** 215 * Method getCharacterValue. 216 * 217 * @param s 218 * @param parser 219 * @param attribute 220 * @throws XmlPullParserException 221 * @return char 222 */ 223 private char getCharacterValue( String s, String attribute, XmlPullParser parser ) 224 throws XmlPullParserException 225 { 226 if ( s != null ) 227 { 228 return s.charAt( 0 ); 229 } 230 return 0; 231 } //-- char getCharacterValue( String, String, XmlPullParser ) 232 233 /** 234 * Method getDateValue. 235 * 236 * @param s 237 * @param parser 238 * @param attribute 239 * @throws XmlPullParserException 240 * @return Date 241 */ 242 private java.util.Date getDateValue( String s, String attribute, XmlPullParser parser ) 243 throws XmlPullParserException 244 { 245 return getDateValue( s, attribute, null, parser ); 246 } //-- java.util.Date getDateValue( String, String, XmlPullParser ) 247 248 /** 249 * Method getDateValue. 250 * 251 * @param s 252 * @param parser 253 * @param dateFormat 254 * @param attribute 255 * @throws XmlPullParserException 256 * @return Date 257 */ 258 private java.util.Date getDateValue( String s, String attribute, String dateFormat, XmlPullParser parser ) 259 throws XmlPullParserException 260 { 261 if ( s != null ) 262 { 263 String effectiveDateFormat = dateFormat; 264 if ( dateFormat == null ) 265 { 266 effectiveDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS"; 267 } 268 if ( "long".equals( effectiveDateFormat ) ) 269 { 270 try 271 { 272 return new java.util.Date( Long.parseLong( s ) ); 273 } 274 catch ( NumberFormatException e ) 275 { 276 throw new XmlPullParserException( e.getMessage(), parser, e ); 277 } 278 } 279 else 280 { 281 try 282 { 283 DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, java.util.Locale.US ); 284 return dateParser.parse( s ); 285 } 286 catch ( java.text.ParseException e ) 287 { 288 throw new XmlPullParserException( e.getMessage(), parser, e ); 289 } 290 } 291 } 292 return null; 293 } //-- java.util.Date getDateValue( String, String, String, XmlPullParser ) 294 295 /** 296 * Method getDoubleValue. 297 * 298 * @param s 299 * @param strict 300 * @param parser 301 * @param attribute 302 * @throws XmlPullParserException 303 * @return double 304 */ 305 private double getDoubleValue( String s, String attribute, XmlPullParser parser, boolean strict ) 306 throws XmlPullParserException 307 { 308 if ( s != null ) 309 { 310 try 311 { 312 return Double.valueOf( s ).doubleValue(); 313 } 314 catch ( NumberFormatException nfe ) 315 { 316 if ( strict ) 317 { 318 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe ); 319 } 320 } 321 } 322 return 0; 323 } //-- double getDoubleValue( String, String, XmlPullParser, boolean ) 324 325 /** 326 * Method getFloatValue. 327 * 328 * @param s 329 * @param strict 330 * @param parser 331 * @param attribute 332 * @throws XmlPullParserException 333 * @return float 334 */ 335 private float getFloatValue( String s, String attribute, XmlPullParser parser, boolean strict ) 336 throws XmlPullParserException 337 { 338 if ( s != null ) 339 { 340 try 341 { 342 return Float.valueOf( s ).floatValue(); 343 } 344 catch ( NumberFormatException nfe ) 345 { 346 if ( strict ) 347 { 348 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe ); 349 } 350 } 351 } 352 return 0; 353 } //-- float getFloatValue( String, String, XmlPullParser, boolean ) 354 355 /** 356 * Method getIntegerValue. 357 * 358 * @param s 359 * @param strict 360 * @param parser 361 * @param attribute 362 * @throws XmlPullParserException 363 * @return int 364 */ 365 private int getIntegerValue( String s, String attribute, XmlPullParser parser, boolean strict ) 366 throws XmlPullParserException 367 { 368 if ( s != null ) 369 { 370 try 371 { 372 return Integer.valueOf( s ).intValue(); 373 } 374 catch ( NumberFormatException nfe ) 375 { 376 if ( strict ) 377 { 378 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be an integer", parser, nfe ); 379 } 380 } 381 } 382 return 0; 383 } //-- int getIntegerValue( String, String, XmlPullParser, boolean ) 384 385 /** 386 * Method getLongValue. 387 * 388 * @param s 389 * @param strict 390 * @param parser 391 * @param attribute 392 * @throws XmlPullParserException 393 * @return long 394 */ 395 private long getLongValue( String s, String attribute, XmlPullParser parser, boolean strict ) 396 throws XmlPullParserException 397 { 398 if ( s != null ) 399 { 400 try 401 { 402 return Long.valueOf( s ).longValue(); 403 } 404 catch ( NumberFormatException nfe ) 405 { 406 if ( strict ) 407 { 408 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a long integer", parser, nfe ); 409 } 410 } 411 } 412 return 0; 413 } //-- long getLongValue( String, String, XmlPullParser, boolean ) 414 415 /** 416 * Method getRequiredAttributeValue. 417 * 418 * @param s 419 * @param strict 420 * @param parser 421 * @param attribute 422 * @throws XmlPullParserException 423 * @return String 424 */ 425 private String getRequiredAttributeValue( String s, String attribute, XmlPullParser parser, boolean strict ) 426 throws XmlPullParserException 427 { 428 if ( s == null ) 429 { 430 if ( strict ) 431 { 432 throw new XmlPullParserException( "Missing required value for attribute '" + attribute + "'", parser, null ); 433 } 434 } 435 return s; 436 } //-- String getRequiredAttributeValue( String, String, XmlPullParser, boolean ) 437 438 /** 439 * Method getShortValue. 440 * 441 * @param s 442 * @param strict 443 * @param parser 444 * @param attribute 445 * @throws XmlPullParserException 446 * @return short 447 */ 448 private short getShortValue( String s, String attribute, XmlPullParser parser, boolean strict ) 449 throws XmlPullParserException 450 { 451 if ( s != null ) 452 { 453 try 454 { 455 return Short.valueOf( s ).shortValue(); 456 } 457 catch ( NumberFormatException nfe ) 458 { 459 if ( strict ) 460 { 461 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a short integer", parser, nfe ); 462 } 463 } 464 } 465 return 0; 466 } //-- short getShortValue( String, String, XmlPullParser, boolean ) 467 468 /** 469 * Method getTrimmedValue. 470 * 471 * @param s 472 * @return String 473 */ 474 private String getTrimmedValue( String s ) 475 { 476 if ( s != null ) 477 { 478 s = s.trim(); 479 } 480 return s; 481 } //-- String getTrimmedValue( String ) 482 483 /** 484 * Method nextTag. 485 * 486 * @param parser 487 * @throws IOException 488 * @throws XmlPullParserException 489 * @return int 490 */ 491 private int nextTag( XmlPullParser parser ) 492 throws IOException, XmlPullParserException 493 { 494 int eventType = parser.next(); 495 if ( eventType == XmlPullParser.TEXT ) 496 { 497 eventType = parser.next(); 498 } 499 if ( eventType != XmlPullParser.START_TAG && eventType != XmlPullParser.END_TAG ) 500 { 501 throw new XmlPullParserException( "expected START_TAG or END_TAG not " + XmlPullParser.TYPES[eventType], parser, null ); 502 } 503 return eventType; 504 } //-- int nextTag( XmlPullParser ) 505 506 /** 507 * @see ReaderFactory#newXmlReader 508 * 509 * @param reader 510 * @param strict 511 * @throws IOException 512 * @throws XmlPullParserException 513 * @return ProfilesRoot 514 */ 515 public ProfilesRoot read( Reader reader, boolean strict ) 516 throws IOException, XmlPullParserException 517 { 518 XmlPullParser parser = addDefaultEntities ? new MXParser(EntityReplacementMap.defaultEntityReplacementMap) : new MXParser( ); 519 520 parser.setInput( reader ); 521 522 523 return read( parser, strict ); 524 } //-- ProfilesRoot read( Reader, boolean ) 525 526 /** 527 * @see ReaderFactory#newXmlReader 528 * 529 * @param reader 530 * @throws IOException 531 * @throws XmlPullParserException 532 * @return ProfilesRoot 533 */ 534 public ProfilesRoot read( Reader reader ) 535 throws IOException, XmlPullParserException 536 { 537 return read( reader, true ); 538 } //-- ProfilesRoot read( Reader ) 539 540 /** 541 * Method read. 542 * 543 * @param in 544 * @param strict 545 * @throws IOException 546 * @throws XmlPullParserException 547 * @return ProfilesRoot 548 */ 549 public ProfilesRoot read( InputStream in, boolean strict ) 550 throws IOException, XmlPullParserException 551 { 552 return read( ReaderFactory.newXmlReader( in ), strict ); 553 } //-- ProfilesRoot read( InputStream, boolean ) 554 555 /** 556 * Method read. 557 * 558 * @param in 559 * @throws IOException 560 * @throws XmlPullParserException 561 * @return ProfilesRoot 562 */ 563 public ProfilesRoot read( InputStream in ) 564 throws IOException, XmlPullParserException 565 { 566 return read( ReaderFactory.newXmlReader( in ) ); 567 } //-- ProfilesRoot read( InputStream ) 568 569 /** 570 * Method parseActivation. 571 * 572 * @param parser 573 * @param strict 574 * @throws IOException 575 * @throws XmlPullParserException 576 * @return Activation 577 */ 578 private Activation parseActivation( XmlPullParser parser, boolean strict ) 579 throws IOException, XmlPullParserException 580 { 581 String tagName = parser.getName(); 582 Activation activation = new Activation(); 583 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 584 { 585 String name = parser.getAttributeName( i ); 586 String value = parser.getAttributeValue( i ); 587 588 if ( name.indexOf( ':' ) >= 0 ) 589 { 590 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 591 } 592 else 593 { 594 checkUnknownAttribute( parser, name, tagName, strict ); 595 } 596 } 597 java.util.Set parsed = new java.util.HashSet(); 598 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 599 { 600 if ( checkFieldWithDuplicate( parser, "activeByDefault", null, parsed ) ) 601 { 602 activation.setActiveByDefault( getBooleanValue( getTrimmedValue( parser.nextText() ), "activeByDefault", parser, "false" ) ); 603 } 604 else if ( checkFieldWithDuplicate( parser, "jdk", null, parsed ) ) 605 { 606 activation.setJdk( getTrimmedValue( parser.nextText() ) ); 607 } 608 else if ( checkFieldWithDuplicate( parser, "os", null, parsed ) ) 609 { 610 activation.setOs( parseActivationOS( parser, strict ) ); 611 } 612 else if ( checkFieldWithDuplicate( parser, "property", null, parsed ) ) 613 { 614 activation.setProperty( parseActivationProperty( parser, strict ) ); 615 } 616 else if ( checkFieldWithDuplicate( parser, "file", null, parsed ) ) 617 { 618 activation.setFile( parseActivationFile( parser, strict ) ); 619 } 620 else 621 { 622 checkUnknownElement( parser, strict ); 623 } 624 } 625 return activation; 626 } //-- Activation parseActivation( XmlPullParser, boolean ) 627 628 /** 629 * Method parseActivationFile. 630 * 631 * @param parser 632 * @param strict 633 * @throws IOException 634 * @throws XmlPullParserException 635 * @return ActivationFile 636 */ 637 private ActivationFile parseActivationFile( XmlPullParser parser, boolean strict ) 638 throws IOException, XmlPullParserException 639 { 640 String tagName = parser.getName(); 641 ActivationFile activationFile = new ActivationFile(); 642 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 643 { 644 String name = parser.getAttributeName( i ); 645 String value = parser.getAttributeValue( i ); 646 647 if ( name.indexOf( ':' ) >= 0 ) 648 { 649 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 650 } 651 else 652 { 653 checkUnknownAttribute( parser, name, tagName, strict ); 654 } 655 } 656 java.util.Set parsed = new java.util.HashSet(); 657 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 658 { 659 if ( checkFieldWithDuplicate( parser, "missing", null, parsed ) ) 660 { 661 activationFile.setMissing( getTrimmedValue( parser.nextText() ) ); 662 } 663 else if ( checkFieldWithDuplicate( parser, "exists", null, parsed ) ) 664 { 665 activationFile.setExists( getTrimmedValue( parser.nextText() ) ); 666 } 667 else 668 { 669 checkUnknownElement( parser, strict ); 670 } 671 } 672 return activationFile; 673 } //-- ActivationFile parseActivationFile( XmlPullParser, boolean ) 674 675 /** 676 * Method parseActivationOS. 677 * 678 * @param parser 679 * @param strict 680 * @throws IOException 681 * @throws XmlPullParserException 682 * @return ActivationOS 683 */ 684 private ActivationOS parseActivationOS( XmlPullParser parser, boolean strict ) 685 throws IOException, XmlPullParserException 686 { 687 String tagName = parser.getName(); 688 ActivationOS activationOS = new ActivationOS(); 689 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 690 { 691 String name = parser.getAttributeName( i ); 692 String value = parser.getAttributeValue( i ); 693 694 if ( name.indexOf( ':' ) >= 0 ) 695 { 696 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 697 } 698 else 699 { 700 checkUnknownAttribute( parser, name, tagName, strict ); 701 } 702 } 703 java.util.Set parsed = new java.util.HashSet(); 704 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 705 { 706 if ( checkFieldWithDuplicate( parser, "name", null, parsed ) ) 707 { 708 activationOS.setName( getTrimmedValue( parser.nextText() ) ); 709 } 710 else if ( checkFieldWithDuplicate( parser, "family", null, parsed ) ) 711 { 712 activationOS.setFamily( getTrimmedValue( parser.nextText() ) ); 713 } 714 else if ( checkFieldWithDuplicate( parser, "arch", null, parsed ) ) 715 { 716 activationOS.setArch( getTrimmedValue( parser.nextText() ) ); 717 } 718 else if ( checkFieldWithDuplicate( parser, "version", null, parsed ) ) 719 { 720 activationOS.setVersion( getTrimmedValue( parser.nextText() ) ); 721 } 722 else 723 { 724 checkUnknownElement( parser, strict ); 725 } 726 } 727 return activationOS; 728 } //-- ActivationOS parseActivationOS( XmlPullParser, boolean ) 729 730 /** 731 * Method parseActivationProperty. 732 * 733 * @param parser 734 * @param strict 735 * @throws IOException 736 * @throws XmlPullParserException 737 * @return ActivationProperty 738 */ 739 private ActivationProperty parseActivationProperty( XmlPullParser parser, boolean strict ) 740 throws IOException, XmlPullParserException 741 { 742 String tagName = parser.getName(); 743 ActivationProperty activationProperty = new ActivationProperty(); 744 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 745 { 746 String name = parser.getAttributeName( i ); 747 String value = parser.getAttributeValue( i ); 748 749 if ( name.indexOf( ':' ) >= 0 ) 750 { 751 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 752 } 753 else 754 { 755 checkUnknownAttribute( parser, name, tagName, strict ); 756 } 757 } 758 java.util.Set parsed = new java.util.HashSet(); 759 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 760 { 761 if ( checkFieldWithDuplicate( parser, "name", null, parsed ) ) 762 { 763 activationProperty.setName( getTrimmedValue( parser.nextText() ) ); 764 } 765 else if ( checkFieldWithDuplicate( parser, "value", null, parsed ) ) 766 { 767 activationProperty.setValue( getTrimmedValue( parser.nextText() ) ); 768 } 769 else 770 { 771 checkUnknownElement( parser, strict ); 772 } 773 } 774 return activationProperty; 775 } //-- ActivationProperty parseActivationProperty( XmlPullParser, boolean ) 776 777 /** 778 * Method parseProfile. 779 * 780 * @param parser 781 * @param strict 782 * @throws IOException 783 * @throws XmlPullParserException 784 * @return Profile 785 */ 786 private Profile parseProfile( XmlPullParser parser, boolean strict ) 787 throws IOException, XmlPullParserException 788 { 789 String tagName = parser.getName(); 790 Profile profile = new Profile(); 791 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 792 { 793 String name = parser.getAttributeName( i ); 794 String value = parser.getAttributeValue( i ); 795 796 if ( name.indexOf( ':' ) >= 0 ) 797 { 798 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 799 } 800 else 801 { 802 checkUnknownAttribute( parser, name, tagName, strict ); 803 } 804 } 805 java.util.Set parsed = new java.util.HashSet(); 806 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 807 { 808 if ( checkFieldWithDuplicate( parser, "id", null, parsed ) ) 809 { 810 profile.setId( getTrimmedValue( parser.nextText() ) ); 811 } 812 else if ( checkFieldWithDuplicate( parser, "activation", null, parsed ) ) 813 { 814 profile.setActivation( parseActivation( parser, strict ) ); 815 } 816 else if ( checkFieldWithDuplicate( parser, "properties", null, parsed ) ) 817 { 818 while ( parser.nextTag() == XmlPullParser.START_TAG ) 819 { 820 String key = parser.getName(); 821 String value = parser.nextText().trim(); 822 profile.addProperty( key, value ); 823 } 824 } 825 else if ( checkFieldWithDuplicate( parser, "repositories", null, parsed ) ) 826 { 827 java.util.List repositories = new java.util.ArrayList/*<Repository>*/(); 828 profile.setRepositories( repositories ); 829 while ( parser.nextTag() == XmlPullParser.START_TAG ) 830 { 831 if ( "repository".equals( parser.getName() ) ) 832 { 833 repositories.add( parseRepository( parser, strict ) ); 834 } 835 else 836 { 837 checkUnknownElement( parser, strict ); 838 } 839 } 840 } 841 else if ( checkFieldWithDuplicate( parser, "pluginRepositories", null, parsed ) ) 842 { 843 java.util.List pluginRepositories = new java.util.ArrayList/*<Repository>*/(); 844 profile.setPluginRepositories( pluginRepositories ); 845 while ( parser.nextTag() == XmlPullParser.START_TAG ) 846 { 847 if ( "pluginRepository".equals( parser.getName() ) ) 848 { 849 pluginRepositories.add( parseRepository( parser, strict ) ); 850 } 851 else 852 { 853 checkUnknownElement( parser, strict ); 854 } 855 } 856 } 857 else 858 { 859 checkUnknownElement( parser, strict ); 860 } 861 } 862 return profile; 863 } //-- Profile parseProfile( XmlPullParser, boolean ) 864 865 /** 866 * Method parseProfilesRoot. 867 * 868 * @param parser 869 * @param strict 870 * @throws IOException 871 * @throws XmlPullParserException 872 * @return ProfilesRoot 873 */ 874 private ProfilesRoot parseProfilesRoot( XmlPullParser parser, boolean strict ) 875 throws IOException, XmlPullParserException 876 { 877 String tagName = parser.getName(); 878 ProfilesRoot profilesRoot = new ProfilesRoot(); 879 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 880 { 881 String name = parser.getAttributeName( i ); 882 String value = parser.getAttributeValue( i ); 883 884 if ( name.indexOf( ':' ) >= 0 ) 885 { 886 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 887 } 888 else if ( "xmlns".equals( name ) ) 889 { 890 // ignore xmlns attribute in root class, which is a reserved attribute name 891 } 892 else 893 { 894 checkUnknownAttribute( parser, name, tagName, strict ); 895 } 896 } 897 java.util.Set parsed = new java.util.HashSet(); 898 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 899 { 900 if ( checkFieldWithDuplicate( parser, "profiles", null, parsed ) ) 901 { 902 java.util.List profiles = new java.util.ArrayList/*<Profile>*/(); 903 profilesRoot.setProfiles( profiles ); 904 while ( parser.nextTag() == XmlPullParser.START_TAG ) 905 { 906 if ( "profile".equals( parser.getName() ) ) 907 { 908 profiles.add( parseProfile( parser, strict ) ); 909 } 910 else 911 { 912 checkUnknownElement( parser, strict ); 913 } 914 } 915 } 916 else if ( checkFieldWithDuplicate( parser, "activeProfiles", null, parsed ) ) 917 { 918 java.util.List activeProfiles = new java.util.ArrayList/*<String>*/(); 919 profilesRoot.setActiveProfiles( activeProfiles ); 920 while ( parser.nextTag() == XmlPullParser.START_TAG ) 921 { 922 if ( "activeProfile".equals( parser.getName() ) ) 923 { 924 activeProfiles.add( getTrimmedValue( parser.nextText() ) ); 925 } 926 else 927 { 928 checkUnknownElement( parser, strict ); 929 } 930 } 931 } 932 else 933 { 934 checkUnknownElement( parser, strict ); 935 } 936 } 937 return profilesRoot; 938 } //-- ProfilesRoot parseProfilesRoot( XmlPullParser, boolean ) 939 940 /** 941 * Method parseRepository. 942 * 943 * @param parser 944 * @param strict 945 * @throws IOException 946 * @throws XmlPullParserException 947 * @return Repository 948 */ 949 private Repository parseRepository( XmlPullParser parser, boolean strict ) 950 throws IOException, XmlPullParserException 951 { 952 String tagName = parser.getName(); 953 Repository repository = new Repository(); 954 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 955 { 956 String name = parser.getAttributeName( i ); 957 String value = parser.getAttributeValue( i ); 958 959 if ( name.indexOf( ':' ) >= 0 ) 960 { 961 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 962 } 963 else 964 { 965 checkUnknownAttribute( parser, name, tagName, strict ); 966 } 967 } 968 java.util.Set parsed = new java.util.HashSet(); 969 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 970 { 971 if ( checkFieldWithDuplicate( parser, "releases", null, parsed ) ) 972 { 973 repository.setReleases( parseRepositoryPolicy( parser, strict ) ); 974 } 975 else if ( checkFieldWithDuplicate( parser, "snapshots", null, parsed ) ) 976 { 977 repository.setSnapshots( parseRepositoryPolicy( parser, strict ) ); 978 } 979 else if ( checkFieldWithDuplicate( parser, "id", null, parsed ) ) 980 { 981 repository.setId( getTrimmedValue( parser.nextText() ) ); 982 } 983 else if ( checkFieldWithDuplicate( parser, "name", null, parsed ) ) 984 { 985 repository.setName( getTrimmedValue( parser.nextText() ) ); 986 } 987 else if ( checkFieldWithDuplicate( parser, "url", null, parsed ) ) 988 { 989 repository.setUrl( getTrimmedValue( parser.nextText() ) ); 990 } 991 else if ( checkFieldWithDuplicate( parser, "layout", null, parsed ) ) 992 { 993 repository.setLayout( getTrimmedValue( parser.nextText() ) ); 994 } 995 else 996 { 997 checkUnknownElement( parser, strict ); 998 } 999 } 1000 return repository; 1001 } //-- Repository parseRepository( XmlPullParser, boolean ) 1002 1003 /** 1004 * Method parseRepositoryBase. 1005 * 1006 * @param parser 1007 * @param strict 1008 * @throws IOException 1009 * @throws XmlPullParserException 1010 * @return RepositoryBase 1011 */ 1012 private RepositoryBase parseRepositoryBase( XmlPullParser parser, boolean strict ) 1013 throws IOException, XmlPullParserException 1014 { 1015 String tagName = parser.getName(); 1016 RepositoryBase repositoryBase = new RepositoryBase(); 1017 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 1018 { 1019 String name = parser.getAttributeName( i ); 1020 String value = parser.getAttributeValue( i ); 1021 1022 if ( name.indexOf( ':' ) >= 0 ) 1023 { 1024 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 1025 } 1026 else 1027 { 1028 checkUnknownAttribute( parser, name, tagName, strict ); 1029 } 1030 } 1031 java.util.Set parsed = new java.util.HashSet(); 1032 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 1033 { 1034 if ( checkFieldWithDuplicate( parser, "id", null, parsed ) ) 1035 { 1036 repositoryBase.setId( getTrimmedValue( parser.nextText() ) ); 1037 } 1038 else if ( checkFieldWithDuplicate( parser, "name", null, parsed ) ) 1039 { 1040 repositoryBase.setName( getTrimmedValue( parser.nextText() ) ); 1041 } 1042 else if ( checkFieldWithDuplicate( parser, "url", null, parsed ) ) 1043 { 1044 repositoryBase.setUrl( getTrimmedValue( parser.nextText() ) ); 1045 } 1046 else if ( checkFieldWithDuplicate( parser, "layout", null, parsed ) ) 1047 { 1048 repositoryBase.setLayout( getTrimmedValue( parser.nextText() ) ); 1049 } 1050 else 1051 { 1052 checkUnknownElement( parser, strict ); 1053 } 1054 } 1055 return repositoryBase; 1056 } //-- RepositoryBase parseRepositoryBase( XmlPullParser, boolean ) 1057 1058 /** 1059 * Method parseRepositoryPolicy. 1060 * 1061 * @param parser 1062 * @param strict 1063 * @throws IOException 1064 * @throws XmlPullParserException 1065 * @return RepositoryPolicy 1066 */ 1067 private RepositoryPolicy parseRepositoryPolicy( XmlPullParser parser, boolean strict ) 1068 throws IOException, XmlPullParserException 1069 { 1070 String tagName = parser.getName(); 1071 RepositoryPolicy repositoryPolicy = new RepositoryPolicy(); 1072 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 1073 { 1074 String name = parser.getAttributeName( i ); 1075 String value = parser.getAttributeValue( i ); 1076 1077 if ( name.indexOf( ':' ) >= 0 ) 1078 { 1079 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 1080 } 1081 else 1082 { 1083 checkUnknownAttribute( parser, name, tagName, strict ); 1084 } 1085 } 1086 java.util.Set parsed = new java.util.HashSet(); 1087 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 1088 { 1089 if ( checkFieldWithDuplicate( parser, "enabled", null, parsed ) ) 1090 { 1091 repositoryPolicy.setEnabled( getBooleanValue( getTrimmedValue( parser.nextText() ), "enabled", parser, "true" ) ); 1092 } 1093 else if ( checkFieldWithDuplicate( parser, "updatePolicy", null, parsed ) ) 1094 { 1095 repositoryPolicy.setUpdatePolicy( getTrimmedValue( parser.nextText() ) ); 1096 } 1097 else if ( checkFieldWithDuplicate( parser, "checksumPolicy", null, parsed ) ) 1098 { 1099 repositoryPolicy.setChecksumPolicy( getTrimmedValue( parser.nextText() ) ); 1100 } 1101 else 1102 { 1103 checkUnknownElement( parser, strict ); 1104 } 1105 } 1106 return repositoryPolicy; 1107 } //-- RepositoryPolicy parseRepositoryPolicy( XmlPullParser, boolean ) 1108 1109 /** 1110 * Method read. 1111 * 1112 * @param parser 1113 * @param strict 1114 * @throws IOException 1115 * @throws XmlPullParserException 1116 * @return ProfilesRoot 1117 */ 1118 private ProfilesRoot read( XmlPullParser parser, boolean strict ) 1119 throws IOException, XmlPullParserException 1120 { 1121 int eventType = parser.getEventType(); 1122 while ( eventType != XmlPullParser.END_DOCUMENT ) 1123 { 1124 if ( eventType == XmlPullParser.START_TAG ) 1125 { 1126 if ( strict && ! "profilesXml".equals( parser.getName() ) ) 1127 { 1128 throw new XmlPullParserException( "Expected root element 'profilesXml' but found '" + parser.getName() + "'", parser, null ); 1129 } 1130 ProfilesRoot profilesRoot = parseProfilesRoot( parser, strict ); 1131 profilesRoot.setModelEncoding( parser.getInputEncoding() ); 1132 return profilesRoot; 1133 } 1134 eventType = parser.next(); 1135 } 1136 throw new XmlPullParserException( "Expected root element 'profilesXml' but found no element at all: invalid XML document", parser, null ); 1137 } //-- ProfilesRoot read( XmlPullParser, boolean ) 1138 1139 /** 1140 * Sets the state of the "add default entities" flag. 1141 * 1142 * @param addDefaultEntities 1143 */ 1144 public void setAddDefaultEntities( boolean addDefaultEntities ) 1145 { 1146 this.addDefaultEntities = addDefaultEntities; 1147 } //-- void setAddDefaultEntities( boolean ) 1148 1149}