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