001 /* 002 =================== DO NOT EDIT THIS FILE ==================== 003 Generated by Modello 1.4.1 on 2012-09-02 23:28:13, 004 any modifications will be overwritten. 005 ============================================================== 006 */ 007 008 package org.apache.maven.settings.io.xpp3; 009 010 //---------------------------------/ 011 //- Imported classes and packages -/ 012 //---------------------------------/ 013 014 import java.io.IOException; 015 import java.io.InputStream; 016 import java.io.Reader; 017 import java.text.DateFormat; 018 import java.util.Locale; 019 import org.apache.maven.settings.Activation; 020 import org.apache.maven.settings.ActivationFile; 021 import org.apache.maven.settings.ActivationOS; 022 import org.apache.maven.settings.ActivationProperty; 023 import org.apache.maven.settings.IdentifiableBase; 024 import org.apache.maven.settings.Mirror; 025 import org.apache.maven.settings.Profile; 026 import org.apache.maven.settings.Proxy; 027 import org.apache.maven.settings.Repository; 028 import org.apache.maven.settings.RepositoryBase; 029 import org.apache.maven.settings.RepositoryPolicy; 030 import org.apache.maven.settings.Server; 031 import org.apache.maven.settings.Settings; 032 import org.apache.maven.settings.TrackableBase; 033 import org.codehaus.plexus.util.ReaderFactory; 034 import org.codehaus.plexus.util.xml.Xpp3DomBuilder; 035 import org.codehaus.plexus.util.xml.pull.MXParser; 036 import org.codehaus.plexus.util.xml.pull.XmlPullParser; 037 import org.codehaus.plexus.util.xml.pull.XmlPullParserException; 038 039 /** 040 * Class SettingsXpp3Reader. 041 * 042 * @version $Revision$ $Date$ 043 */ 044 @SuppressWarnings( "all" ) 045 public class SettingsXpp3Reader 046 { 047 048 //--------------------------/ 049 //- Class/Member Variables -/ 050 //--------------------------/ 051 052 /** 053 * If set the parser will be loaded with all single characters 054 * from the XHTML specification. 055 * The entities used: 056 * <ul> 057 * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent</li> 058 * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent</li> 059 * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent</li> 060 * </ul> 061 */ 062 private boolean addDefaultEntities = true; 063 064 065 //-----------/ 066 //- Methods -/ 067 //-----------/ 068 069 /** 070 * Method checkFieldWithDuplicate. 071 * 072 * @param parser 073 * @param parsed 074 * @param alias 075 * @param tagName 076 * @throws XmlPullParserException 077 * @return boolean 078 */ 079 private boolean checkFieldWithDuplicate( XmlPullParser parser, String tagName, String alias, java.util.Set parsed ) 080 throws XmlPullParserException 081 { 082 if ( !( parser.getName().equals( tagName ) || parser.getName().equals( alias ) ) ) 083 { 084 return false; 085 } 086 if ( !parsed.add( tagName ) ) 087 { 088 throw new XmlPullParserException( "Duplicated tag: '" + tagName + "'", parser, null ); 089 } 090 return true; 091 } //-- boolean checkFieldWithDuplicate( XmlPullParser, String, String, java.util.Set ) 092 093 /** 094 * Method checkUnknownAttribute. 095 * 096 * @param parser 097 * @param strict 098 * @param tagName 099 * @param attribute 100 * @throws XmlPullParserException 101 * @throws IOException 102 */ 103 private void checkUnknownAttribute( XmlPullParser parser, String attribute, String tagName, boolean strict ) 104 throws XmlPullParserException, IOException 105 { 106 // strictXmlAttributes = true for model: if strict == true, not only elements are checked but attributes too 107 if ( strict ) 108 { 109 throw new XmlPullParserException( "Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser, null ); 110 } 111 } //-- void checkUnknownAttribute( XmlPullParser, String, String, boolean ) 112 113 /** 114 * Method checkUnknownElement. 115 * 116 * @param parser 117 * @param strict 118 * @throws XmlPullParserException 119 * @throws IOException 120 */ 121 private void checkUnknownElement( XmlPullParser parser, boolean strict ) 122 throws XmlPullParserException, IOException 123 { 124 if ( strict ) 125 { 126 throw new XmlPullParserException( "Unrecognised tag: '" + parser.getName() + "'", parser, null ); 127 } 128 129 for ( int unrecognizedTagCount = 1; unrecognizedTagCount > 0; ) 130 { 131 int eventType = parser.next(); 132 if ( eventType == XmlPullParser.START_TAG ) 133 { 134 unrecognizedTagCount++; 135 } 136 else if ( eventType == XmlPullParser.END_TAG ) 137 { 138 unrecognizedTagCount--; 139 } 140 } 141 } //-- void checkUnknownElement( XmlPullParser, boolean ) 142 143 /** 144 * Returns the state of the "add default entities" flag. 145 * 146 * @return boolean 147 */ 148 public boolean getAddDefaultEntities() 149 { 150 return addDefaultEntities; 151 } //-- boolean getAddDefaultEntities() 152 153 /** 154 * Method getBooleanValue. 155 * 156 * @param s 157 * @param parser 158 * @param attribute 159 * @throws XmlPullParserException 160 * @return boolean 161 */ 162 private boolean getBooleanValue( String s, String attribute, XmlPullParser parser ) 163 throws XmlPullParserException 164 { 165 return getBooleanValue( s, attribute, parser, null ); 166 } //-- boolean getBooleanValue( String, String, XmlPullParser ) 167 168 /** 169 * Method getBooleanValue. 170 * 171 * @param s 172 * @param defaultValue 173 * @param parser 174 * @param attribute 175 * @throws XmlPullParserException 176 * @return boolean 177 */ 178 private boolean getBooleanValue( String s, String attribute, XmlPullParser parser, String defaultValue ) 179 throws XmlPullParserException 180 { 181 if ( s != null && s.length() != 0 ) 182 { 183 return Boolean.valueOf( s ).booleanValue(); 184 } 185 if ( defaultValue != null ) 186 { 187 return Boolean.valueOf( defaultValue ).booleanValue(); 188 } 189 return false; 190 } //-- boolean getBooleanValue( String, String, XmlPullParser, String ) 191 192 /** 193 * Method getByteValue. 194 * 195 * @param s 196 * @param strict 197 * @param parser 198 * @param attribute 199 * @throws XmlPullParserException 200 * @return byte 201 */ 202 private byte getByteValue( String s, String attribute, XmlPullParser parser, boolean strict ) 203 throws XmlPullParserException 204 { 205 if ( s != null ) 206 { 207 try 208 { 209 return Byte.valueOf( s ).byteValue(); 210 } 211 catch ( NumberFormatException nfe ) 212 { 213 if ( strict ) 214 { 215 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a byte", parser, nfe ); 216 } 217 } 218 } 219 return 0; 220 } //-- byte getByteValue( String, String, XmlPullParser, boolean ) 221 222 /** 223 * Method getCharacterValue. 224 * 225 * @param s 226 * @param parser 227 * @param attribute 228 * @throws XmlPullParserException 229 * @return char 230 */ 231 private char getCharacterValue( String s, String attribute, XmlPullParser parser ) 232 throws XmlPullParserException 233 { 234 if ( s != null ) 235 { 236 return s.charAt( 0 ); 237 } 238 return 0; 239 } //-- char getCharacterValue( String, String, XmlPullParser ) 240 241 /** 242 * Method getDateValue. 243 * 244 * @param s 245 * @param parser 246 * @param attribute 247 * @throws XmlPullParserException 248 * @return Date 249 */ 250 private java.util.Date getDateValue( String s, String attribute, XmlPullParser parser ) 251 throws XmlPullParserException 252 { 253 return getDateValue( s, attribute, null, parser ); 254 } //-- java.util.Date getDateValue( String, String, XmlPullParser ) 255 256 /** 257 * Method getDateValue. 258 * 259 * @param s 260 * @param parser 261 * @param dateFormat 262 * @param attribute 263 * @throws XmlPullParserException 264 * @return Date 265 */ 266 private java.util.Date getDateValue( String s, String attribute, String dateFormat, XmlPullParser parser ) 267 throws XmlPullParserException 268 { 269 if ( s != null ) 270 { 271 String effectiveDateFormat = dateFormat; 272 if ( dateFormat == null ) 273 { 274 effectiveDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS"; 275 } 276 if ( "long".equals( effectiveDateFormat ) ) 277 { 278 try 279 { 280 return new java.util.Date( Long.parseLong( s ) ); 281 } 282 catch ( NumberFormatException e ) 283 { 284 throw new XmlPullParserException( e.getMessage(), parser, e ); 285 } 286 } 287 else 288 { 289 try 290 { 291 DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, Locale.US ); 292 return dateParser.parse( s ); 293 } 294 catch ( java.text.ParseException e ) 295 { 296 throw new XmlPullParserException( e.getMessage(), parser, e ); 297 } 298 } 299 } 300 return null; 301 } //-- java.util.Date getDateValue( String, String, String, XmlPullParser ) 302 303 /** 304 * Method getDoubleValue. 305 * 306 * @param s 307 * @param strict 308 * @param parser 309 * @param attribute 310 * @throws XmlPullParserException 311 * @return double 312 */ 313 private double getDoubleValue( String s, String attribute, XmlPullParser parser, boolean strict ) 314 throws XmlPullParserException 315 { 316 if ( s != null ) 317 { 318 try 319 { 320 return Double.valueOf( s ).doubleValue(); 321 } 322 catch ( NumberFormatException nfe ) 323 { 324 if ( strict ) 325 { 326 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe ); 327 } 328 } 329 } 330 return 0; 331 } //-- double getDoubleValue( String, String, XmlPullParser, boolean ) 332 333 /** 334 * Method getFloatValue. 335 * 336 * @param s 337 * @param strict 338 * @param parser 339 * @param attribute 340 * @throws XmlPullParserException 341 * @return float 342 */ 343 private float getFloatValue( String s, String attribute, XmlPullParser parser, boolean strict ) 344 throws XmlPullParserException 345 { 346 if ( s != null ) 347 { 348 try 349 { 350 return Float.valueOf( s ).floatValue(); 351 } 352 catch ( NumberFormatException nfe ) 353 { 354 if ( strict ) 355 { 356 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe ); 357 } 358 } 359 } 360 return 0; 361 } //-- float getFloatValue( String, String, XmlPullParser, boolean ) 362 363 /** 364 * Method getIntegerValue. 365 * 366 * @param s 367 * @param strict 368 * @param parser 369 * @param attribute 370 * @throws XmlPullParserException 371 * @return int 372 */ 373 private int getIntegerValue( String s, String attribute, XmlPullParser parser, boolean strict ) 374 throws XmlPullParserException 375 { 376 if ( s != null ) 377 { 378 try 379 { 380 return Integer.valueOf( s ).intValue(); 381 } 382 catch ( NumberFormatException nfe ) 383 { 384 if ( strict ) 385 { 386 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be an integer", parser, nfe ); 387 } 388 } 389 } 390 return 0; 391 } //-- int getIntegerValue( String, String, XmlPullParser, boolean ) 392 393 /** 394 * Method getLongValue. 395 * 396 * @param s 397 * @param strict 398 * @param parser 399 * @param attribute 400 * @throws XmlPullParserException 401 * @return long 402 */ 403 private long getLongValue( String s, String attribute, XmlPullParser parser, boolean strict ) 404 throws XmlPullParserException 405 { 406 if ( s != null ) 407 { 408 try 409 { 410 return Long.valueOf( s ).longValue(); 411 } 412 catch ( NumberFormatException nfe ) 413 { 414 if ( strict ) 415 { 416 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a long integer", parser, nfe ); 417 } 418 } 419 } 420 return 0; 421 } //-- long getLongValue( String, String, XmlPullParser, boolean ) 422 423 /** 424 * Method getRequiredAttributeValue. 425 * 426 * @param s 427 * @param strict 428 * @param parser 429 * @param attribute 430 * @throws XmlPullParserException 431 * @return String 432 */ 433 private String getRequiredAttributeValue( String s, String attribute, XmlPullParser parser, boolean strict ) 434 throws XmlPullParserException 435 { 436 if ( s == null ) 437 { 438 if ( strict ) 439 { 440 throw new XmlPullParserException( "Missing required value for attribute '" + attribute + "'", parser, null ); 441 } 442 } 443 return s; 444 } //-- String getRequiredAttributeValue( String, String, XmlPullParser, boolean ) 445 446 /** 447 * Method getShortValue. 448 * 449 * @param s 450 * @param strict 451 * @param parser 452 * @param attribute 453 * @throws XmlPullParserException 454 * @return short 455 */ 456 private short getShortValue( String s, String attribute, XmlPullParser parser, boolean strict ) 457 throws XmlPullParserException 458 { 459 if ( s != null ) 460 { 461 try 462 { 463 return Short.valueOf( s ).shortValue(); 464 } 465 catch ( NumberFormatException nfe ) 466 { 467 if ( strict ) 468 { 469 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a short integer", parser, nfe ); 470 } 471 } 472 } 473 return 0; 474 } //-- short getShortValue( String, String, XmlPullParser, boolean ) 475 476 /** 477 * Method getTrimmedValue. 478 * 479 * @param s 480 * @return String 481 */ 482 private String getTrimmedValue( String s ) 483 { 484 if ( s != null ) 485 { 486 s = s.trim(); 487 } 488 return s; 489 } //-- String getTrimmedValue( String ) 490 491 /** 492 * Method initParser. 493 * 494 * @param parser 495 * @throws XmlPullParserException 496 */ 497 private void initParser( XmlPullParser parser ) 498 throws XmlPullParserException 499 { 500 if ( addDefaultEntities ) 501 { 502 // ---------------------------------------------------------------------- 503 // Latin 1 entities 504 // ---------------------------------------------------------------------- 505 506 parser.defineEntityReplacementText( "nbsp", "\u00a0" ); 507 parser.defineEntityReplacementText( "iexcl", "\u00a1" ); 508 parser.defineEntityReplacementText( "cent", "\u00a2" ); 509 parser.defineEntityReplacementText( "pound", "\u00a3" ); 510 parser.defineEntityReplacementText( "curren", "\u00a4" ); 511 parser.defineEntityReplacementText( "yen", "\u00a5" ); 512 parser.defineEntityReplacementText( "brvbar", "\u00a6" ); 513 parser.defineEntityReplacementText( "sect", "\u00a7" ); 514 parser.defineEntityReplacementText( "uml", "\u00a8" ); 515 parser.defineEntityReplacementText( "copy", "\u00a9" ); 516 parser.defineEntityReplacementText( "ordf", "\u00aa" ); 517 parser.defineEntityReplacementText( "laquo", "\u00ab" ); 518 parser.defineEntityReplacementText( "not", "\u00ac" ); 519 parser.defineEntityReplacementText( "shy", "\u00ad" ); 520 parser.defineEntityReplacementText( "reg", "\u00ae" ); 521 parser.defineEntityReplacementText( "macr", "\u00af" ); 522 parser.defineEntityReplacementText( "deg", "\u00b0" ); 523 parser.defineEntityReplacementText( "plusmn", "\u00b1" ); 524 parser.defineEntityReplacementText( "sup2", "\u00b2" ); 525 parser.defineEntityReplacementText( "sup3", "\u00b3" ); 526 parser.defineEntityReplacementText( "acute", "\u00b4" ); 527 parser.defineEntityReplacementText( "micro", "\u00b5" ); 528 parser.defineEntityReplacementText( "para", "\u00b6" ); 529 parser.defineEntityReplacementText( "middot", "\u00b7" ); 530 parser.defineEntityReplacementText( "cedil", "\u00b8" ); 531 parser.defineEntityReplacementText( "sup1", "\u00b9" ); 532 parser.defineEntityReplacementText( "ordm", "\u00ba" ); 533 parser.defineEntityReplacementText( "raquo", "\u00bb" ); 534 parser.defineEntityReplacementText( "frac14", "\u00bc" ); 535 parser.defineEntityReplacementText( "frac12", "\u00bd" ); 536 parser.defineEntityReplacementText( "frac34", "\u00be" ); 537 parser.defineEntityReplacementText( "iquest", "\u00bf" ); 538 parser.defineEntityReplacementText( "Agrave", "\u00c0" ); 539 parser.defineEntityReplacementText( "Aacute", "\u00c1" ); 540 parser.defineEntityReplacementText( "Acirc", "\u00c2" ); 541 parser.defineEntityReplacementText( "Atilde", "\u00c3" ); 542 parser.defineEntityReplacementText( "Auml", "\u00c4" ); 543 parser.defineEntityReplacementText( "Aring", "\u00c5" ); 544 parser.defineEntityReplacementText( "AElig", "\u00c6" ); 545 parser.defineEntityReplacementText( "Ccedil", "\u00c7" ); 546 parser.defineEntityReplacementText( "Egrave", "\u00c8" ); 547 parser.defineEntityReplacementText( "Eacute", "\u00c9" ); 548 parser.defineEntityReplacementText( "Ecirc", "\u00ca" ); 549 parser.defineEntityReplacementText( "Euml", "\u00cb" ); 550 parser.defineEntityReplacementText( "Igrave", "\u00cc" ); 551 parser.defineEntityReplacementText( "Iacute", "\u00cd" ); 552 parser.defineEntityReplacementText( "Icirc", "\u00ce" ); 553 parser.defineEntityReplacementText( "Iuml", "\u00cf" ); 554 parser.defineEntityReplacementText( "ETH", "\u00d0" ); 555 parser.defineEntityReplacementText( "Ntilde", "\u00d1" ); 556 parser.defineEntityReplacementText( "Ograve", "\u00d2" ); 557 parser.defineEntityReplacementText( "Oacute", "\u00d3" ); 558 parser.defineEntityReplacementText( "Ocirc", "\u00d4" ); 559 parser.defineEntityReplacementText( "Otilde", "\u00d5" ); 560 parser.defineEntityReplacementText( "Ouml", "\u00d6" ); 561 parser.defineEntityReplacementText( "times", "\u00d7" ); 562 parser.defineEntityReplacementText( "Oslash", "\u00d8" ); 563 parser.defineEntityReplacementText( "Ugrave", "\u00d9" ); 564 parser.defineEntityReplacementText( "Uacute", "\u00da" ); 565 parser.defineEntityReplacementText( "Ucirc", "\u00db" ); 566 parser.defineEntityReplacementText( "Uuml", "\u00dc" ); 567 parser.defineEntityReplacementText( "Yacute", "\u00dd" ); 568 parser.defineEntityReplacementText( "THORN", "\u00de" ); 569 parser.defineEntityReplacementText( "szlig", "\u00df" ); 570 parser.defineEntityReplacementText( "agrave", "\u00e0" ); 571 parser.defineEntityReplacementText( "aacute", "\u00e1" ); 572 parser.defineEntityReplacementText( "acirc", "\u00e2" ); 573 parser.defineEntityReplacementText( "atilde", "\u00e3" ); 574 parser.defineEntityReplacementText( "auml", "\u00e4" ); 575 parser.defineEntityReplacementText( "aring", "\u00e5" ); 576 parser.defineEntityReplacementText( "aelig", "\u00e6" ); 577 parser.defineEntityReplacementText( "ccedil", "\u00e7" ); 578 parser.defineEntityReplacementText( "egrave", "\u00e8" ); 579 parser.defineEntityReplacementText( "eacute", "\u00e9" ); 580 parser.defineEntityReplacementText( "ecirc", "\u00ea" ); 581 parser.defineEntityReplacementText( "euml", "\u00eb" ); 582 parser.defineEntityReplacementText( "igrave", "\u00ec" ); 583 parser.defineEntityReplacementText( "iacute", "\u00ed" ); 584 parser.defineEntityReplacementText( "icirc", "\u00ee" ); 585 parser.defineEntityReplacementText( "iuml", "\u00ef" ); 586 parser.defineEntityReplacementText( "eth", "\u00f0" ); 587 parser.defineEntityReplacementText( "ntilde", "\u00f1" ); 588 parser.defineEntityReplacementText( "ograve", "\u00f2" ); 589 parser.defineEntityReplacementText( "oacute", "\u00f3" ); 590 parser.defineEntityReplacementText( "ocirc", "\u00f4" ); 591 parser.defineEntityReplacementText( "otilde", "\u00f5" ); 592 parser.defineEntityReplacementText( "ouml", "\u00f6" ); 593 parser.defineEntityReplacementText( "divide", "\u00f7" ); 594 parser.defineEntityReplacementText( "oslash", "\u00f8" ); 595 parser.defineEntityReplacementText( "ugrave", "\u00f9" ); 596 parser.defineEntityReplacementText( "uacute", "\u00fa" ); 597 parser.defineEntityReplacementText( "ucirc", "\u00fb" ); 598 parser.defineEntityReplacementText( "uuml", "\u00fc" ); 599 parser.defineEntityReplacementText( "yacute", "\u00fd" ); 600 parser.defineEntityReplacementText( "thorn", "\u00fe" ); 601 parser.defineEntityReplacementText( "yuml", "\u00ff" ); 602 603 // ---------------------------------------------------------------------- 604 // Special entities 605 // ---------------------------------------------------------------------- 606 607 parser.defineEntityReplacementText( "OElig", "\u0152" ); 608 parser.defineEntityReplacementText( "oelig", "\u0153" ); 609 parser.defineEntityReplacementText( "Scaron", "\u0160" ); 610 parser.defineEntityReplacementText( "scaron", "\u0161" ); 611 parser.defineEntityReplacementText( "Yuml", "\u0178" ); 612 parser.defineEntityReplacementText( "circ", "\u02c6" ); 613 parser.defineEntityReplacementText( "tilde", "\u02dc" ); 614 parser.defineEntityReplacementText( "ensp", "\u2002" ); 615 parser.defineEntityReplacementText( "emsp", "\u2003" ); 616 parser.defineEntityReplacementText( "thinsp", "\u2009" ); 617 parser.defineEntityReplacementText( "zwnj", "\u200c" ); 618 parser.defineEntityReplacementText( "zwj", "\u200d" ); 619 parser.defineEntityReplacementText( "lrm", "\u200e" ); 620 parser.defineEntityReplacementText( "rlm", "\u200f" ); 621 parser.defineEntityReplacementText( "ndash", "\u2013" ); 622 parser.defineEntityReplacementText( "mdash", "\u2014" ); 623 parser.defineEntityReplacementText( "lsquo", "\u2018" ); 624 parser.defineEntityReplacementText( "rsquo", "\u2019" ); 625 parser.defineEntityReplacementText( "sbquo", "\u201a" ); 626 parser.defineEntityReplacementText( "ldquo", "\u201c" ); 627 parser.defineEntityReplacementText( "rdquo", "\u201d" ); 628 parser.defineEntityReplacementText( "bdquo", "\u201e" ); 629 parser.defineEntityReplacementText( "dagger", "\u2020" ); 630 parser.defineEntityReplacementText( "Dagger", "\u2021" ); 631 parser.defineEntityReplacementText( "permil", "\u2030" ); 632 parser.defineEntityReplacementText( "lsaquo", "\u2039" ); 633 parser.defineEntityReplacementText( "rsaquo", "\u203a" ); 634 parser.defineEntityReplacementText( "euro", "\u20ac" ); 635 636 // ---------------------------------------------------------------------- 637 // Symbol entities 638 // ---------------------------------------------------------------------- 639 640 parser.defineEntityReplacementText( "fnof", "\u0192" ); 641 parser.defineEntityReplacementText( "Alpha", "\u0391" ); 642 parser.defineEntityReplacementText( "Beta", "\u0392" ); 643 parser.defineEntityReplacementText( "Gamma", "\u0393" ); 644 parser.defineEntityReplacementText( "Delta", "\u0394" ); 645 parser.defineEntityReplacementText( "Epsilon", "\u0395" ); 646 parser.defineEntityReplacementText( "Zeta", "\u0396" ); 647 parser.defineEntityReplacementText( "Eta", "\u0397" ); 648 parser.defineEntityReplacementText( "Theta", "\u0398" ); 649 parser.defineEntityReplacementText( "Iota", "\u0399" ); 650 parser.defineEntityReplacementText( "Kappa", "\u039a" ); 651 parser.defineEntityReplacementText( "Lambda", "\u039b" ); 652 parser.defineEntityReplacementText( "Mu", "\u039c" ); 653 parser.defineEntityReplacementText( "Nu", "\u039d" ); 654 parser.defineEntityReplacementText( "Xi", "\u039e" ); 655 parser.defineEntityReplacementText( "Omicron", "\u039f" ); 656 parser.defineEntityReplacementText( "Pi", "\u03a0" ); 657 parser.defineEntityReplacementText( "Rho", "\u03a1" ); 658 parser.defineEntityReplacementText( "Sigma", "\u03a3" ); 659 parser.defineEntityReplacementText( "Tau", "\u03a4" ); 660 parser.defineEntityReplacementText( "Upsilon", "\u03a5" ); 661 parser.defineEntityReplacementText( "Phi", "\u03a6" ); 662 parser.defineEntityReplacementText( "Chi", "\u03a7" ); 663 parser.defineEntityReplacementText( "Psi", "\u03a8" ); 664 parser.defineEntityReplacementText( "Omega", "\u03a9" ); 665 parser.defineEntityReplacementText( "alpha", "\u03b1" ); 666 parser.defineEntityReplacementText( "beta", "\u03b2" ); 667 parser.defineEntityReplacementText( "gamma", "\u03b3" ); 668 parser.defineEntityReplacementText( "delta", "\u03b4" ); 669 parser.defineEntityReplacementText( "epsilon", "\u03b5" ); 670 parser.defineEntityReplacementText( "zeta", "\u03b6" ); 671 parser.defineEntityReplacementText( "eta", "\u03b7" ); 672 parser.defineEntityReplacementText( "theta", "\u03b8" ); 673 parser.defineEntityReplacementText( "iota", "\u03b9" ); 674 parser.defineEntityReplacementText( "kappa", "\u03ba" ); 675 parser.defineEntityReplacementText( "lambda", "\u03bb" ); 676 parser.defineEntityReplacementText( "mu", "\u03bc" ); 677 parser.defineEntityReplacementText( "nu", "\u03bd" ); 678 parser.defineEntityReplacementText( "xi", "\u03be" ); 679 parser.defineEntityReplacementText( "omicron", "\u03bf" ); 680 parser.defineEntityReplacementText( "pi", "\u03c0" ); 681 parser.defineEntityReplacementText( "rho", "\u03c1" ); 682 parser.defineEntityReplacementText( "sigmaf", "\u03c2" ); 683 parser.defineEntityReplacementText( "sigma", "\u03c3" ); 684 parser.defineEntityReplacementText( "tau", "\u03c4" ); 685 parser.defineEntityReplacementText( "upsilon", "\u03c5" ); 686 parser.defineEntityReplacementText( "phi", "\u03c6" ); 687 parser.defineEntityReplacementText( "chi", "\u03c7" ); 688 parser.defineEntityReplacementText( "psi", "\u03c8" ); 689 parser.defineEntityReplacementText( "omega", "\u03c9" ); 690 parser.defineEntityReplacementText( "thetasym", "\u03d1" ); 691 parser.defineEntityReplacementText( "upsih", "\u03d2" ); 692 parser.defineEntityReplacementText( "piv", "\u03d6" ); 693 parser.defineEntityReplacementText( "bull", "\u2022" ); 694 parser.defineEntityReplacementText( "hellip", "\u2026" ); 695 parser.defineEntityReplacementText( "prime", "\u2032" ); 696 parser.defineEntityReplacementText( "Prime", "\u2033" ); 697 parser.defineEntityReplacementText( "oline", "\u203e" ); 698 parser.defineEntityReplacementText( "frasl", "\u2044" ); 699 parser.defineEntityReplacementText( "weierp", "\u2118" ); 700 parser.defineEntityReplacementText( "image", "\u2111" ); 701 parser.defineEntityReplacementText( "real", "\u211c" ); 702 parser.defineEntityReplacementText( "trade", "\u2122" ); 703 parser.defineEntityReplacementText( "alefsym", "\u2135" ); 704 parser.defineEntityReplacementText( "larr", "\u2190" ); 705 parser.defineEntityReplacementText( "uarr", "\u2191" ); 706 parser.defineEntityReplacementText( "rarr", "\u2192" ); 707 parser.defineEntityReplacementText( "darr", "\u2193" ); 708 parser.defineEntityReplacementText( "harr", "\u2194" ); 709 parser.defineEntityReplacementText( "crarr", "\u21b5" ); 710 parser.defineEntityReplacementText( "lArr", "\u21d0" ); 711 parser.defineEntityReplacementText( "uArr", "\u21d1" ); 712 parser.defineEntityReplacementText( "rArr", "\u21d2" ); 713 parser.defineEntityReplacementText( "dArr", "\u21d3" ); 714 parser.defineEntityReplacementText( "hArr", "\u21d4" ); 715 parser.defineEntityReplacementText( "forall", "\u2200" ); 716 parser.defineEntityReplacementText( "part", "\u2202" ); 717 parser.defineEntityReplacementText( "exist", "\u2203" ); 718 parser.defineEntityReplacementText( "empty", "\u2205" ); 719 parser.defineEntityReplacementText( "nabla", "\u2207" ); 720 parser.defineEntityReplacementText( "isin", "\u2208" ); 721 parser.defineEntityReplacementText( "notin", "\u2209" ); 722 parser.defineEntityReplacementText( "ni", "\u220b" ); 723 parser.defineEntityReplacementText( "prod", "\u220f" ); 724 parser.defineEntityReplacementText( "sum", "\u2211" ); 725 parser.defineEntityReplacementText( "minus", "\u2212" ); 726 parser.defineEntityReplacementText( "lowast", "\u2217" ); 727 parser.defineEntityReplacementText( "radic", "\u221a" ); 728 parser.defineEntityReplacementText( "prop", "\u221d" ); 729 parser.defineEntityReplacementText( "infin", "\u221e" ); 730 parser.defineEntityReplacementText( "ang", "\u2220" ); 731 parser.defineEntityReplacementText( "and", "\u2227" ); 732 parser.defineEntityReplacementText( "or", "\u2228" ); 733 parser.defineEntityReplacementText( "cap", "\u2229" ); 734 parser.defineEntityReplacementText( "cup", "\u222a" ); 735 parser.defineEntityReplacementText( "int", "\u222b" ); 736 parser.defineEntityReplacementText( "there4", "\u2234" ); 737 parser.defineEntityReplacementText( "sim", "\u223c" ); 738 parser.defineEntityReplacementText( "cong", "\u2245" ); 739 parser.defineEntityReplacementText( "asymp", "\u2248" ); 740 parser.defineEntityReplacementText( "ne", "\u2260" ); 741 parser.defineEntityReplacementText( "equiv", "\u2261" ); 742 parser.defineEntityReplacementText( "le", "\u2264" ); 743 parser.defineEntityReplacementText( "ge", "\u2265" ); 744 parser.defineEntityReplacementText( "sub", "\u2282" ); 745 parser.defineEntityReplacementText( "sup", "\u2283" ); 746 parser.defineEntityReplacementText( "nsub", "\u2284" ); 747 parser.defineEntityReplacementText( "sube", "\u2286" ); 748 parser.defineEntityReplacementText( "supe", "\u2287" ); 749 parser.defineEntityReplacementText( "oplus", "\u2295" ); 750 parser.defineEntityReplacementText( "otimes", "\u2297" ); 751 parser.defineEntityReplacementText( "perp", "\u22a5" ); 752 parser.defineEntityReplacementText( "sdot", "\u22c5" ); 753 parser.defineEntityReplacementText( "lceil", "\u2308" ); 754 parser.defineEntityReplacementText( "rceil", "\u2309" ); 755 parser.defineEntityReplacementText( "lfloor", "\u230a" ); 756 parser.defineEntityReplacementText( "rfloor", "\u230b" ); 757 parser.defineEntityReplacementText( "lang", "\u2329" ); 758 parser.defineEntityReplacementText( "rang", "\u232a" ); 759 parser.defineEntityReplacementText( "loz", "\u25ca" ); 760 parser.defineEntityReplacementText( "spades", "\u2660" ); 761 parser.defineEntityReplacementText( "clubs", "\u2663" ); 762 parser.defineEntityReplacementText( "hearts", "\u2665" ); 763 parser.defineEntityReplacementText( "diams", "\u2666" ); 764 765 } 766 } //-- void initParser( XmlPullParser ) 767 768 /** 769 * Method nextTag. 770 * 771 * @param parser 772 * @throws IOException 773 * @throws XmlPullParserException 774 * @return int 775 */ 776 private int nextTag( XmlPullParser parser ) 777 throws IOException, XmlPullParserException 778 { 779 int eventType = parser.next(); 780 if ( eventType == XmlPullParser.TEXT ) 781 { 782 eventType = parser.next(); 783 } 784 if ( eventType != XmlPullParser.START_TAG && eventType != XmlPullParser.END_TAG ) 785 { 786 throw new XmlPullParserException( "expected START_TAG or END_TAG not " + XmlPullParser.TYPES[eventType], parser, null ); 787 } 788 return eventType; 789 } //-- int nextTag( XmlPullParser ) 790 791 /** 792 * Method parseActivation. 793 * 794 * @param parser 795 * @param strict 796 * @throws IOException 797 * @throws XmlPullParserException 798 * @return Activation 799 */ 800 private Activation parseActivation( XmlPullParser parser, boolean strict ) 801 throws IOException, XmlPullParserException 802 { 803 String tagName = parser.getName(); 804 Activation activation = new Activation(); 805 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 806 { 807 String name = parser.getAttributeName( i ); 808 String value = parser.getAttributeValue( i ); 809 810 if ( name.indexOf( ':' ) >= 0 ) 811 { 812 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 813 } 814 else 815 { 816 checkUnknownAttribute( parser, name, tagName, strict ); 817 } 818 } 819 java.util.Set parsed = new java.util.HashSet(); 820 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 821 { 822 if ( checkFieldWithDuplicate( parser, "activeByDefault", null, parsed ) ) 823 { 824 activation.setActiveByDefault( getBooleanValue( getTrimmedValue( parser.nextText() ), "activeByDefault", parser, "false" ) ); 825 } 826 else if ( checkFieldWithDuplicate( parser, "jdk", null, parsed ) ) 827 { 828 activation.setJdk( getTrimmedValue( parser.nextText() ) ); 829 } 830 else if ( checkFieldWithDuplicate( parser, "os", null, parsed ) ) 831 { 832 activation.setOs( parseActivationOS( parser, strict ) ); 833 } 834 else if ( checkFieldWithDuplicate( parser, "property", null, parsed ) ) 835 { 836 activation.setProperty( parseActivationProperty( parser, strict ) ); 837 } 838 else if ( checkFieldWithDuplicate( parser, "file", null, parsed ) ) 839 { 840 activation.setFile( parseActivationFile( parser, strict ) ); 841 } 842 else 843 { 844 checkUnknownElement( parser, strict ); 845 } 846 } 847 return activation; 848 } //-- Activation parseActivation( XmlPullParser, boolean ) 849 850 /** 851 * Method parseActivationFile. 852 * 853 * @param parser 854 * @param strict 855 * @throws IOException 856 * @throws XmlPullParserException 857 * @return ActivationFile 858 */ 859 private ActivationFile parseActivationFile( XmlPullParser parser, boolean strict ) 860 throws IOException, XmlPullParserException 861 { 862 String tagName = parser.getName(); 863 ActivationFile activationFile = new ActivationFile(); 864 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 865 { 866 String name = parser.getAttributeName( i ); 867 String value = parser.getAttributeValue( i ); 868 869 if ( name.indexOf( ':' ) >= 0 ) 870 { 871 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 872 } 873 else 874 { 875 checkUnknownAttribute( parser, name, tagName, strict ); 876 } 877 } 878 java.util.Set parsed = new java.util.HashSet(); 879 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 880 { 881 if ( checkFieldWithDuplicate( parser, "missing", null, parsed ) ) 882 { 883 activationFile.setMissing( getTrimmedValue( parser.nextText() ) ); 884 } 885 else if ( checkFieldWithDuplicate( parser, "exists", null, parsed ) ) 886 { 887 activationFile.setExists( getTrimmedValue( parser.nextText() ) ); 888 } 889 else 890 { 891 checkUnknownElement( parser, strict ); 892 } 893 } 894 return activationFile; 895 } //-- ActivationFile parseActivationFile( XmlPullParser, boolean ) 896 897 /** 898 * Method parseActivationOS. 899 * 900 * @param parser 901 * @param strict 902 * @throws IOException 903 * @throws XmlPullParserException 904 * @return ActivationOS 905 */ 906 private ActivationOS parseActivationOS( XmlPullParser parser, boolean strict ) 907 throws IOException, XmlPullParserException 908 { 909 String tagName = parser.getName(); 910 ActivationOS activationOS = new ActivationOS(); 911 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 912 { 913 String name = parser.getAttributeName( i ); 914 String value = parser.getAttributeValue( i ); 915 916 if ( name.indexOf( ':' ) >= 0 ) 917 { 918 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 919 } 920 else 921 { 922 checkUnknownAttribute( parser, name, tagName, strict ); 923 } 924 } 925 java.util.Set parsed = new java.util.HashSet(); 926 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 927 { 928 if ( checkFieldWithDuplicate( parser, "name", null, parsed ) ) 929 { 930 activationOS.setName( getTrimmedValue( parser.nextText() ) ); 931 } 932 else if ( checkFieldWithDuplicate( parser, "family", null, parsed ) ) 933 { 934 activationOS.setFamily( getTrimmedValue( parser.nextText() ) ); 935 } 936 else if ( checkFieldWithDuplicate( parser, "arch", null, parsed ) ) 937 { 938 activationOS.setArch( getTrimmedValue( parser.nextText() ) ); 939 } 940 else if ( checkFieldWithDuplicate( parser, "version", null, parsed ) ) 941 { 942 activationOS.setVersion( getTrimmedValue( parser.nextText() ) ); 943 } 944 else 945 { 946 checkUnknownElement( parser, strict ); 947 } 948 } 949 return activationOS; 950 } //-- ActivationOS parseActivationOS( XmlPullParser, boolean ) 951 952 /** 953 * Method parseActivationProperty. 954 * 955 * @param parser 956 * @param strict 957 * @throws IOException 958 * @throws XmlPullParserException 959 * @return ActivationProperty 960 */ 961 private ActivationProperty parseActivationProperty( XmlPullParser parser, boolean strict ) 962 throws IOException, XmlPullParserException 963 { 964 String tagName = parser.getName(); 965 ActivationProperty activationProperty = new ActivationProperty(); 966 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 967 { 968 String name = parser.getAttributeName( i ); 969 String value = parser.getAttributeValue( i ); 970 971 if ( name.indexOf( ':' ) >= 0 ) 972 { 973 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 974 } 975 else 976 { 977 checkUnknownAttribute( parser, name, tagName, strict ); 978 } 979 } 980 java.util.Set parsed = new java.util.HashSet(); 981 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 982 { 983 if ( checkFieldWithDuplicate( parser, "name", null, parsed ) ) 984 { 985 activationProperty.setName( getTrimmedValue( parser.nextText() ) ); 986 } 987 else if ( checkFieldWithDuplicate( parser, "value", null, parsed ) ) 988 { 989 activationProperty.setValue( getTrimmedValue( parser.nextText() ) ); 990 } 991 else 992 { 993 checkUnknownElement( parser, strict ); 994 } 995 } 996 return activationProperty; 997 } //-- ActivationProperty parseActivationProperty( XmlPullParser, boolean ) 998 999 /** 1000 * Method parseIdentifiableBase. 1001 * 1002 * @param parser 1003 * @param strict 1004 * @throws IOException 1005 * @throws XmlPullParserException 1006 * @return IdentifiableBase 1007 */ 1008 private IdentifiableBase parseIdentifiableBase( XmlPullParser parser, boolean strict ) 1009 throws IOException, XmlPullParserException 1010 { 1011 String tagName = parser.getName(); 1012 IdentifiableBase identifiableBase = new IdentifiableBase(); 1013 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 1014 { 1015 String name = parser.getAttributeName( i ); 1016 String value = parser.getAttributeValue( i ); 1017 1018 if ( name.indexOf( ':' ) >= 0 ) 1019 { 1020 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 1021 } 1022 else 1023 { 1024 checkUnknownAttribute( parser, name, tagName, strict ); 1025 } 1026 } 1027 java.util.Set parsed = new java.util.HashSet(); 1028 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 1029 { 1030 if ( checkFieldWithDuplicate( parser, "id", null, parsed ) ) 1031 { 1032 identifiableBase.setId( getTrimmedValue( parser.nextText() ) ); 1033 } 1034 else 1035 { 1036 checkUnknownElement( parser, strict ); 1037 } 1038 } 1039 return identifiableBase; 1040 } //-- IdentifiableBase parseIdentifiableBase( XmlPullParser, boolean ) 1041 1042 /** 1043 * Method parseMirror. 1044 * 1045 * @param parser 1046 * @param strict 1047 * @throws IOException 1048 * @throws XmlPullParserException 1049 * @return Mirror 1050 */ 1051 private Mirror parseMirror( XmlPullParser parser, boolean strict ) 1052 throws IOException, XmlPullParserException 1053 { 1054 String tagName = parser.getName(); 1055 Mirror mirror = new Mirror(); 1056 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 1057 { 1058 String name = parser.getAttributeName( i ); 1059 String value = parser.getAttributeValue( i ); 1060 1061 if ( name.indexOf( ':' ) >= 0 ) 1062 { 1063 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 1064 } 1065 else 1066 { 1067 checkUnknownAttribute( parser, name, tagName, strict ); 1068 } 1069 } 1070 java.util.Set parsed = new java.util.HashSet(); 1071 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 1072 { 1073 if ( checkFieldWithDuplicate( parser, "mirrorOf", null, parsed ) ) 1074 { 1075 mirror.setMirrorOf( getTrimmedValue( parser.nextText() ) ); 1076 } 1077 else if ( checkFieldWithDuplicate( parser, "name", null, parsed ) ) 1078 { 1079 mirror.setName( getTrimmedValue( parser.nextText() ) ); 1080 } 1081 else if ( checkFieldWithDuplicate( parser, "url", null, parsed ) ) 1082 { 1083 mirror.setUrl( getTrimmedValue( parser.nextText() ) ); 1084 } 1085 else if ( checkFieldWithDuplicate( parser, "layout", null, parsed ) ) 1086 { 1087 mirror.setLayout( getTrimmedValue( parser.nextText() ) ); 1088 } 1089 else if ( checkFieldWithDuplicate( parser, "mirrorOfLayouts", null, parsed ) ) 1090 { 1091 mirror.setMirrorOfLayouts( getTrimmedValue( parser.nextText() ) ); 1092 } 1093 else if ( checkFieldWithDuplicate( parser, "id", null, parsed ) ) 1094 { 1095 mirror.setId( getTrimmedValue( parser.nextText() ) ); 1096 } 1097 else 1098 { 1099 checkUnknownElement( parser, strict ); 1100 } 1101 } 1102 return mirror; 1103 } //-- Mirror parseMirror( XmlPullParser, boolean ) 1104 1105 /** 1106 * Method parseProfile. 1107 * 1108 * @param parser 1109 * @param strict 1110 * @throws IOException 1111 * @throws XmlPullParserException 1112 * @return Profile 1113 */ 1114 private Profile parseProfile( XmlPullParser parser, boolean strict ) 1115 throws IOException, XmlPullParserException 1116 { 1117 String tagName = parser.getName(); 1118 Profile profile = new Profile(); 1119 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 1120 { 1121 String name = parser.getAttributeName( i ); 1122 String value = parser.getAttributeValue( i ); 1123 1124 if ( name.indexOf( ':' ) >= 0 ) 1125 { 1126 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 1127 } 1128 else 1129 { 1130 checkUnknownAttribute( parser, name, tagName, strict ); 1131 } 1132 } 1133 java.util.Set parsed = new java.util.HashSet(); 1134 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 1135 { 1136 if ( checkFieldWithDuplicate( parser, "activation", null, parsed ) ) 1137 { 1138 profile.setActivation( parseActivation( parser, strict ) ); 1139 } 1140 else if ( checkFieldWithDuplicate( parser, "properties", null, parsed ) ) 1141 { 1142 while ( parser.nextTag() == XmlPullParser.START_TAG ) 1143 { 1144 String key = parser.getName(); 1145 String value = parser.nextText().trim(); 1146 profile.addProperty( key, value ); 1147 } 1148 } 1149 else if ( checkFieldWithDuplicate( parser, "repositories", null, parsed ) ) 1150 { 1151 java.util.List repositories = new java.util.ArrayList/*<Repository>*/(); 1152 profile.setRepositories( repositories ); 1153 while ( parser.nextTag() == XmlPullParser.START_TAG ) 1154 { 1155 if ( "repository".equals( parser.getName() ) ) 1156 { 1157 repositories.add( parseRepository( parser, strict ) ); 1158 } 1159 else 1160 { 1161 checkUnknownElement( parser, strict ); 1162 } 1163 } 1164 } 1165 else if ( checkFieldWithDuplicate( parser, "pluginRepositories", null, parsed ) ) 1166 { 1167 java.util.List pluginRepositories = new java.util.ArrayList/*<Repository>*/(); 1168 profile.setPluginRepositories( pluginRepositories ); 1169 while ( parser.nextTag() == XmlPullParser.START_TAG ) 1170 { 1171 if ( "pluginRepository".equals( parser.getName() ) ) 1172 { 1173 pluginRepositories.add( parseRepository( parser, strict ) ); 1174 } 1175 else 1176 { 1177 checkUnknownElement( parser, strict ); 1178 } 1179 } 1180 } 1181 else if ( checkFieldWithDuplicate( parser, "id", null, parsed ) ) 1182 { 1183 profile.setId( getTrimmedValue( parser.nextText() ) ); 1184 } 1185 else 1186 { 1187 checkUnknownElement( parser, strict ); 1188 } 1189 } 1190 return profile; 1191 } //-- Profile parseProfile( XmlPullParser, boolean ) 1192 1193 /** 1194 * Method parseProxy. 1195 * 1196 * @param parser 1197 * @param strict 1198 * @throws IOException 1199 * @throws XmlPullParserException 1200 * @return Proxy 1201 */ 1202 private Proxy parseProxy( XmlPullParser parser, boolean strict ) 1203 throws IOException, XmlPullParserException 1204 { 1205 String tagName = parser.getName(); 1206 Proxy proxy = new Proxy(); 1207 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 1208 { 1209 String name = parser.getAttributeName( i ); 1210 String value = parser.getAttributeValue( i ); 1211 1212 if ( name.indexOf( ':' ) >= 0 ) 1213 { 1214 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 1215 } 1216 else 1217 { 1218 checkUnknownAttribute( parser, name, tagName, strict ); 1219 } 1220 } 1221 java.util.Set parsed = new java.util.HashSet(); 1222 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 1223 { 1224 if ( checkFieldWithDuplicate( parser, "active", null, parsed ) ) 1225 { 1226 proxy.setActive( getBooleanValue( getTrimmedValue( parser.nextText() ), "active", parser, "true" ) ); 1227 } 1228 else if ( checkFieldWithDuplicate( parser, "protocol", null, parsed ) ) 1229 { 1230 proxy.setProtocol( getTrimmedValue( parser.nextText() ) ); 1231 } 1232 else if ( checkFieldWithDuplicate( parser, "username", null, parsed ) ) 1233 { 1234 proxy.setUsername( getTrimmedValue( parser.nextText() ) ); 1235 } 1236 else if ( checkFieldWithDuplicate( parser, "password", null, parsed ) ) 1237 { 1238 proxy.setPassword( getTrimmedValue( parser.nextText() ) ); 1239 } 1240 else if ( checkFieldWithDuplicate( parser, "port", null, parsed ) ) 1241 { 1242 proxy.setPort( getIntegerValue( getTrimmedValue( parser.nextText() ), "port", parser, strict ) ); 1243 } 1244 else if ( checkFieldWithDuplicate( parser, "host", null, parsed ) ) 1245 { 1246 proxy.setHost( getTrimmedValue( parser.nextText() ) ); 1247 } 1248 else if ( checkFieldWithDuplicate( parser, "nonProxyHosts", null, parsed ) ) 1249 { 1250 proxy.setNonProxyHosts( getTrimmedValue( parser.nextText() ) ); 1251 } 1252 else if ( checkFieldWithDuplicate( parser, "id", null, parsed ) ) 1253 { 1254 proxy.setId( getTrimmedValue( parser.nextText() ) ); 1255 } 1256 else 1257 { 1258 checkUnknownElement( parser, strict ); 1259 } 1260 } 1261 return proxy; 1262 } //-- Proxy parseProxy( XmlPullParser, boolean ) 1263 1264 /** 1265 * Method parseRepository. 1266 * 1267 * @param parser 1268 * @param strict 1269 * @throws IOException 1270 * @throws XmlPullParserException 1271 * @return Repository 1272 */ 1273 private Repository parseRepository( XmlPullParser parser, boolean strict ) 1274 throws IOException, XmlPullParserException 1275 { 1276 String tagName = parser.getName(); 1277 Repository repository = new Repository(); 1278 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 1279 { 1280 String name = parser.getAttributeName( i ); 1281 String value = parser.getAttributeValue( i ); 1282 1283 if ( name.indexOf( ':' ) >= 0 ) 1284 { 1285 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 1286 } 1287 else 1288 { 1289 checkUnknownAttribute( parser, name, tagName, strict ); 1290 } 1291 } 1292 java.util.Set parsed = new java.util.HashSet(); 1293 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 1294 { 1295 if ( checkFieldWithDuplicate( parser, "releases", null, parsed ) ) 1296 { 1297 repository.setReleases( parseRepositoryPolicy( parser, strict ) ); 1298 } 1299 else if ( checkFieldWithDuplicate( parser, "snapshots", null, parsed ) ) 1300 { 1301 repository.setSnapshots( parseRepositoryPolicy( parser, strict ) ); 1302 } 1303 else if ( checkFieldWithDuplicate( parser, "id", null, parsed ) ) 1304 { 1305 repository.setId( getTrimmedValue( parser.nextText() ) ); 1306 } 1307 else if ( checkFieldWithDuplicate( parser, "name", null, parsed ) ) 1308 { 1309 repository.setName( getTrimmedValue( parser.nextText() ) ); 1310 } 1311 else if ( checkFieldWithDuplicate( parser, "url", null, parsed ) ) 1312 { 1313 repository.setUrl( getTrimmedValue( parser.nextText() ) ); 1314 } 1315 else if ( checkFieldWithDuplicate( parser, "layout", null, parsed ) ) 1316 { 1317 repository.setLayout( getTrimmedValue( parser.nextText() ) ); 1318 } 1319 else 1320 { 1321 checkUnknownElement( parser, strict ); 1322 } 1323 } 1324 return repository; 1325 } //-- Repository parseRepository( XmlPullParser, boolean ) 1326 1327 /** 1328 * Method parseRepositoryBase. 1329 * 1330 * @param parser 1331 * @param strict 1332 * @throws IOException 1333 * @throws XmlPullParserException 1334 * @return RepositoryBase 1335 */ 1336 private RepositoryBase parseRepositoryBase( XmlPullParser parser, boolean strict ) 1337 throws IOException, XmlPullParserException 1338 { 1339 String tagName = parser.getName(); 1340 RepositoryBase repositoryBase = new RepositoryBase(); 1341 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 1342 { 1343 String name = parser.getAttributeName( i ); 1344 String value = parser.getAttributeValue( i ); 1345 1346 if ( name.indexOf( ':' ) >= 0 ) 1347 { 1348 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 1349 } 1350 else 1351 { 1352 checkUnknownAttribute( parser, name, tagName, strict ); 1353 } 1354 } 1355 java.util.Set parsed = new java.util.HashSet(); 1356 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 1357 { 1358 if ( checkFieldWithDuplicate( parser, "id", null, parsed ) ) 1359 { 1360 repositoryBase.setId( getTrimmedValue( parser.nextText() ) ); 1361 } 1362 else if ( checkFieldWithDuplicate( parser, "name", null, parsed ) ) 1363 { 1364 repositoryBase.setName( getTrimmedValue( parser.nextText() ) ); 1365 } 1366 else if ( checkFieldWithDuplicate( parser, "url", null, parsed ) ) 1367 { 1368 repositoryBase.setUrl( getTrimmedValue( parser.nextText() ) ); 1369 } 1370 else if ( checkFieldWithDuplicate( parser, "layout", null, parsed ) ) 1371 { 1372 repositoryBase.setLayout( getTrimmedValue( parser.nextText() ) ); 1373 } 1374 else 1375 { 1376 checkUnknownElement( parser, strict ); 1377 } 1378 } 1379 return repositoryBase; 1380 } //-- RepositoryBase parseRepositoryBase( XmlPullParser, boolean ) 1381 1382 /** 1383 * Method parseRepositoryPolicy. 1384 * 1385 * @param parser 1386 * @param strict 1387 * @throws IOException 1388 * @throws XmlPullParserException 1389 * @return RepositoryPolicy 1390 */ 1391 private RepositoryPolicy parseRepositoryPolicy( XmlPullParser parser, boolean strict ) 1392 throws IOException, XmlPullParserException 1393 { 1394 String tagName = parser.getName(); 1395 RepositoryPolicy repositoryPolicy = new RepositoryPolicy(); 1396 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 1397 { 1398 String name = parser.getAttributeName( i ); 1399 String value = parser.getAttributeValue( i ); 1400 1401 if ( name.indexOf( ':' ) >= 0 ) 1402 { 1403 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 1404 } 1405 else 1406 { 1407 checkUnknownAttribute( parser, name, tagName, strict ); 1408 } 1409 } 1410 java.util.Set parsed = new java.util.HashSet(); 1411 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 1412 { 1413 if ( checkFieldWithDuplicate( parser, "enabled", null, parsed ) ) 1414 { 1415 repositoryPolicy.setEnabled( getBooleanValue( getTrimmedValue( parser.nextText() ), "enabled", parser, "true" ) ); 1416 } 1417 else if ( checkFieldWithDuplicate( parser, "updatePolicy", null, parsed ) ) 1418 { 1419 repositoryPolicy.setUpdatePolicy( getTrimmedValue( parser.nextText() ) ); 1420 } 1421 else if ( checkFieldWithDuplicate( parser, "checksumPolicy", null, parsed ) ) 1422 { 1423 repositoryPolicy.setChecksumPolicy( getTrimmedValue( parser.nextText() ) ); 1424 } 1425 else 1426 { 1427 checkUnknownElement( parser, strict ); 1428 } 1429 } 1430 return repositoryPolicy; 1431 } //-- RepositoryPolicy parseRepositoryPolicy( XmlPullParser, boolean ) 1432 1433 /** 1434 * Method parseServer. 1435 * 1436 * @param parser 1437 * @param strict 1438 * @throws IOException 1439 * @throws XmlPullParserException 1440 * @return Server 1441 */ 1442 private Server parseServer( XmlPullParser parser, boolean strict ) 1443 throws IOException, XmlPullParserException 1444 { 1445 String tagName = parser.getName(); 1446 Server server = new Server(); 1447 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 1448 { 1449 String name = parser.getAttributeName( i ); 1450 String value = parser.getAttributeValue( i ); 1451 1452 if ( name.indexOf( ':' ) >= 0 ) 1453 { 1454 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 1455 } 1456 else 1457 { 1458 checkUnknownAttribute( parser, name, tagName, strict ); 1459 } 1460 } 1461 java.util.Set parsed = new java.util.HashSet(); 1462 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 1463 { 1464 if ( checkFieldWithDuplicate( parser, "username", null, parsed ) ) 1465 { 1466 server.setUsername( getTrimmedValue( parser.nextText() ) ); 1467 } 1468 else if ( checkFieldWithDuplicate( parser, "password", null, parsed ) ) 1469 { 1470 server.setPassword( getTrimmedValue( parser.nextText() ) ); 1471 } 1472 else if ( checkFieldWithDuplicate( parser, "privateKey", null, parsed ) ) 1473 { 1474 server.setPrivateKey( getTrimmedValue( parser.nextText() ) ); 1475 } 1476 else if ( checkFieldWithDuplicate( parser, "passphrase", null, parsed ) ) 1477 { 1478 server.setPassphrase( getTrimmedValue( parser.nextText() ) ); 1479 } 1480 else if ( checkFieldWithDuplicate( parser, "filePermissions", null, parsed ) ) 1481 { 1482 server.setFilePermissions( getTrimmedValue( parser.nextText() ) ); 1483 } 1484 else if ( checkFieldWithDuplicate( parser, "directoryPermissions", null, parsed ) ) 1485 { 1486 server.setDirectoryPermissions( getTrimmedValue( parser.nextText() ) ); 1487 } 1488 else if ( checkFieldWithDuplicate( parser, "configuration", null, parsed ) ) 1489 { 1490 server.setConfiguration( Xpp3DomBuilder.build( parser ) ); 1491 } 1492 else if ( checkFieldWithDuplicate( parser, "id", null, parsed ) ) 1493 { 1494 server.setId( getTrimmedValue( parser.nextText() ) ); 1495 } 1496 else 1497 { 1498 checkUnknownElement( parser, strict ); 1499 } 1500 } 1501 return server; 1502 } //-- Server parseServer( XmlPullParser, boolean ) 1503 1504 /** 1505 * Method parseSettings. 1506 * 1507 * @param parser 1508 * @param strict 1509 * @throws IOException 1510 * @throws XmlPullParserException 1511 * @return Settings 1512 */ 1513 private Settings parseSettings( XmlPullParser parser, boolean strict ) 1514 throws IOException, XmlPullParserException 1515 { 1516 String tagName = parser.getName(); 1517 Settings settings = new Settings(); 1518 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 1519 { 1520 String name = parser.getAttributeName( i ); 1521 String value = parser.getAttributeValue( i ); 1522 1523 if ( name.indexOf( ':' ) >= 0 ) 1524 { 1525 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 1526 } 1527 else if ( "xmlns".equals( name ) ) 1528 { 1529 // ignore xmlns attribute in root class, which is a reserved attribute name 1530 } 1531 else 1532 { 1533 checkUnknownAttribute( parser, name, tagName, strict ); 1534 } 1535 } 1536 java.util.Set parsed = new java.util.HashSet(); 1537 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 1538 { 1539 if ( checkFieldWithDuplicate( parser, "localRepository", null, parsed ) ) 1540 { 1541 settings.setLocalRepository( getTrimmedValue( parser.nextText() ) ); 1542 } 1543 else if ( checkFieldWithDuplicate( parser, "interactiveMode", null, parsed ) ) 1544 { 1545 settings.setInteractiveMode( getBooleanValue( getTrimmedValue( parser.nextText() ), "interactiveMode", parser, "true" ) ); 1546 } 1547 else if ( checkFieldWithDuplicate( parser, "usePluginRegistry", null, parsed ) ) 1548 { 1549 settings.setUsePluginRegistry( getBooleanValue( getTrimmedValue( parser.nextText() ), "usePluginRegistry", parser, "false" ) ); 1550 } 1551 else if ( checkFieldWithDuplicate( parser, "offline", null, parsed ) ) 1552 { 1553 settings.setOffline( getBooleanValue( getTrimmedValue( parser.nextText() ), "offline", parser, "false" ) ); 1554 } 1555 else if ( checkFieldWithDuplicate( parser, "proxies", null, parsed ) ) 1556 { 1557 java.util.List proxies = new java.util.ArrayList/*<Proxy>*/(); 1558 settings.setProxies( proxies ); 1559 while ( parser.nextTag() == XmlPullParser.START_TAG ) 1560 { 1561 if ( "proxy".equals( parser.getName() ) ) 1562 { 1563 proxies.add( parseProxy( parser, strict ) ); 1564 } 1565 else 1566 { 1567 checkUnknownElement( parser, strict ); 1568 } 1569 } 1570 } 1571 else if ( checkFieldWithDuplicate( parser, "servers", null, parsed ) ) 1572 { 1573 java.util.List servers = new java.util.ArrayList/*<Server>*/(); 1574 settings.setServers( servers ); 1575 while ( parser.nextTag() == XmlPullParser.START_TAG ) 1576 { 1577 if ( "server".equals( parser.getName() ) ) 1578 { 1579 servers.add( parseServer( parser, strict ) ); 1580 } 1581 else 1582 { 1583 checkUnknownElement( parser, strict ); 1584 } 1585 } 1586 } 1587 else if ( checkFieldWithDuplicate( parser, "mirrors", null, parsed ) ) 1588 { 1589 java.util.List mirrors = new java.util.ArrayList/*<Mirror>*/(); 1590 settings.setMirrors( mirrors ); 1591 while ( parser.nextTag() == XmlPullParser.START_TAG ) 1592 { 1593 if ( "mirror".equals( parser.getName() ) ) 1594 { 1595 mirrors.add( parseMirror( parser, strict ) ); 1596 } 1597 else 1598 { 1599 checkUnknownElement( parser, strict ); 1600 } 1601 } 1602 } 1603 else if ( checkFieldWithDuplicate( parser, "profiles", null, parsed ) ) 1604 { 1605 java.util.List profiles = new java.util.ArrayList/*<Profile>*/(); 1606 settings.setProfiles( profiles ); 1607 while ( parser.nextTag() == XmlPullParser.START_TAG ) 1608 { 1609 if ( "profile".equals( parser.getName() ) ) 1610 { 1611 profiles.add( parseProfile( parser, strict ) ); 1612 } 1613 else 1614 { 1615 checkUnknownElement( parser, strict ); 1616 } 1617 } 1618 } 1619 else if ( checkFieldWithDuplicate( parser, "activeProfiles", null, parsed ) ) 1620 { 1621 java.util.List activeProfiles = new java.util.ArrayList/*<String>*/(); 1622 settings.setActiveProfiles( activeProfiles ); 1623 while ( parser.nextTag() == XmlPullParser.START_TAG ) 1624 { 1625 if ( "activeProfile".equals( parser.getName() ) ) 1626 { 1627 activeProfiles.add( getTrimmedValue( parser.nextText() ) ); 1628 } 1629 else 1630 { 1631 checkUnknownElement( parser, strict ); 1632 } 1633 } 1634 } 1635 else if ( checkFieldWithDuplicate( parser, "pluginGroups", null, parsed ) ) 1636 { 1637 java.util.List pluginGroups = new java.util.ArrayList/*<String>*/(); 1638 settings.setPluginGroups( pluginGroups ); 1639 while ( parser.nextTag() == XmlPullParser.START_TAG ) 1640 { 1641 if ( "pluginGroup".equals( parser.getName() ) ) 1642 { 1643 pluginGroups.add( getTrimmedValue( parser.nextText() ) ); 1644 } 1645 else 1646 { 1647 checkUnknownElement( parser, strict ); 1648 } 1649 } 1650 } 1651 else 1652 { 1653 checkUnknownElement( parser, strict ); 1654 } 1655 } 1656 return settings; 1657 } //-- Settings parseSettings( XmlPullParser, boolean ) 1658 1659 /** 1660 * Method parseTrackableBase. 1661 * 1662 * @param parser 1663 * @param strict 1664 * @throws IOException 1665 * @throws XmlPullParserException 1666 * @return TrackableBase 1667 */ 1668 private TrackableBase parseTrackableBase( XmlPullParser parser, boolean strict ) 1669 throws IOException, XmlPullParserException 1670 { 1671 String tagName = parser.getName(); 1672 TrackableBase trackableBase = new TrackableBase(); 1673 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 1674 { 1675 String name = parser.getAttributeName( i ); 1676 String value = parser.getAttributeValue( i ); 1677 1678 if ( name.indexOf( ':' ) >= 0 ) 1679 { 1680 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 1681 } 1682 else 1683 { 1684 checkUnknownAttribute( parser, name, tagName, strict ); 1685 } 1686 } 1687 java.util.Set parsed = new java.util.HashSet(); 1688 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 1689 { 1690 checkUnknownElement( parser, strict ); 1691 } 1692 return trackableBase; 1693 } //-- TrackableBase parseTrackableBase( XmlPullParser, boolean ) 1694 1695 /** 1696 * @see ReaderFactory#newXmlReader 1697 * 1698 * @param reader 1699 * @param strict 1700 * @throws IOException 1701 * @throws XmlPullParserException 1702 * @return Settings 1703 */ 1704 public Settings read( Reader reader, boolean strict ) 1705 throws IOException, XmlPullParserException 1706 { 1707 XmlPullParser parser = new MXParser(); 1708 1709 parser.setInput( reader ); 1710 1711 initParser( parser ); 1712 1713 return read( parser, strict ); 1714 } //-- Settings read( Reader, boolean ) 1715 1716 /** 1717 * @see ReaderFactory#newXmlReader 1718 * 1719 * @param reader 1720 * @throws IOException 1721 * @throws XmlPullParserException 1722 * @return Settings 1723 */ 1724 public Settings read( Reader reader ) 1725 throws IOException, XmlPullParserException 1726 { 1727 return read( reader, true ); 1728 } //-- Settings read( Reader ) 1729 1730 /** 1731 * Method read. 1732 * 1733 * @param in 1734 * @param strict 1735 * @throws IOException 1736 * @throws XmlPullParserException 1737 * @return Settings 1738 */ 1739 public Settings read( InputStream in, boolean strict ) 1740 throws IOException, XmlPullParserException 1741 { 1742 return read( ReaderFactory.newXmlReader( in ), strict ); 1743 } //-- Settings read( InputStream, boolean ) 1744 1745 /** 1746 * Method read. 1747 * 1748 * @param in 1749 * @throws IOException 1750 * @throws XmlPullParserException 1751 * @return Settings 1752 */ 1753 public Settings read( InputStream in ) 1754 throws IOException, XmlPullParserException 1755 { 1756 return read( ReaderFactory.newXmlReader( in ) ); 1757 } //-- Settings read( InputStream ) 1758 1759 /** 1760 * Method read. 1761 * 1762 * @param parser 1763 * @param strict 1764 * @throws IOException 1765 * @throws XmlPullParserException 1766 * @return Settings 1767 */ 1768 private Settings read( XmlPullParser parser, boolean strict ) 1769 throws IOException, XmlPullParserException 1770 { 1771 int eventType = parser.getEventType(); 1772 while ( eventType != XmlPullParser.END_DOCUMENT ) 1773 { 1774 if ( eventType == XmlPullParser.START_TAG ) 1775 { 1776 if ( strict && ! "settings".equals( parser.getName() ) ) 1777 { 1778 throw new XmlPullParserException( "Expected root element 'settings' but found '" + parser.getName() + "'", parser, null ); 1779 } 1780 Settings settings = parseSettings( parser, strict ); 1781 settings.setModelEncoding( parser.getInputEncoding() ); 1782 return settings; 1783 } 1784 eventType = parser.next(); 1785 } 1786 throw new XmlPullParserException( "Expected root element 'settings' but found no element at all: invalid XML document", parser, null ); 1787 } //-- Settings read( XmlPullParser, boolean ) 1788 1789 /** 1790 * Sets the state of the "add default entities" flag. 1791 * 1792 * @param addDefaultEntities 1793 */ 1794 public void setAddDefaultEntities( boolean addDefaultEntities ) 1795 { 1796 this.addDefaultEntities = addDefaultEntities; 1797 } //-- void setAddDefaultEntities( boolean ) 1798 1799 }