001 /* 002 =================== DO NOT EDIT THIS FILE ==================== 003 Generated by Modello 1.4.1 on 2012-01-20 18:32:34, 004 any modifications will be overwritten. 005 ============================================================== 006 */ 007 008 package org.apache.maven.usability.plugin.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.usability.plugin.Expression; 020 import org.apache.maven.usability.plugin.ExpressionDocumentation; 021 import org.codehaus.plexus.util.ReaderFactory; 022 import org.codehaus.plexus.util.xml.pull.MXParser; 023 import org.codehaus.plexus.util.xml.pull.XmlPullParser; 024 import org.codehaus.plexus.util.xml.pull.XmlPullParserException; 025 026 /** 027 * Class ParamdocXpp3Reader. 028 * 029 * @version $Revision$ $Date$ 030 */ 031 @SuppressWarnings( "all" ) 032 public class ParamdocXpp3Reader 033 { 034 035 //--------------------------/ 036 //- Class/Member Variables -/ 037 //--------------------------/ 038 039 /** 040 * If set the parser will be loaded with all single characters 041 * from the XHTML specification. 042 * The entities used: 043 * <ul> 044 * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent</li> 045 * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent</li> 046 * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent</li> 047 * </ul> 048 */ 049 private boolean addDefaultEntities = true; 050 051 052 //-----------/ 053 //- Methods -/ 054 //-----------/ 055 056 /** 057 * Method checkFieldWithDuplicate. 058 * 059 * @param parser 060 * @param parsed 061 * @param alias 062 * @param tagName 063 * @throws XmlPullParserException 064 * @return boolean 065 */ 066 private boolean checkFieldWithDuplicate( XmlPullParser parser, String tagName, String alias, java.util.Set parsed ) 067 throws XmlPullParserException 068 { 069 if ( !( parser.getName().equals( tagName ) || parser.getName().equals( alias ) ) ) 070 { 071 return false; 072 } 073 if ( !parsed.add( tagName ) ) 074 { 075 throw new XmlPullParserException( "Duplicated tag: '" + tagName + "'", parser, null ); 076 } 077 return true; 078 } //-- boolean checkFieldWithDuplicate( XmlPullParser, String, String, java.util.Set ) 079 080 /** 081 * Method checkUnknownAttribute. 082 * 083 * @param parser 084 * @param strict 085 * @param tagName 086 * @param attribute 087 * @throws XmlPullParserException 088 * @throws IOException 089 */ 090 private void checkUnknownAttribute( XmlPullParser parser, String attribute, String tagName, boolean strict ) 091 throws XmlPullParserException, IOException 092 { 093 // strictXmlAttributes = true for model: if strict == true, not only elements are checked but attributes too 094 if ( strict ) 095 { 096 throw new XmlPullParserException( "Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser, null ); 097 } 098 } //-- void checkUnknownAttribute( XmlPullParser, String, String, boolean ) 099 100 /** 101 * Method checkUnknownElement. 102 * 103 * @param parser 104 * @param strict 105 * @throws XmlPullParserException 106 * @throws IOException 107 */ 108 private void checkUnknownElement( XmlPullParser parser, boolean strict ) 109 throws XmlPullParserException, IOException 110 { 111 if ( strict ) 112 { 113 throw new XmlPullParserException( "Unrecognised tag: '" + parser.getName() + "'", parser, null ); 114 } 115 116 for ( int unrecognizedTagCount = 1; unrecognizedTagCount > 0; ) 117 { 118 int eventType = parser.next(); 119 if ( eventType == XmlPullParser.START_TAG ) 120 { 121 unrecognizedTagCount++; 122 } 123 else if ( eventType == XmlPullParser.END_TAG ) 124 { 125 unrecognizedTagCount--; 126 } 127 } 128 } //-- void checkUnknownElement( XmlPullParser, boolean ) 129 130 /** 131 * Returns the state of the "add default entities" flag. 132 * 133 * @return boolean 134 */ 135 public boolean getAddDefaultEntities() 136 { 137 return addDefaultEntities; 138 } //-- boolean getAddDefaultEntities() 139 140 /** 141 * Method getBooleanValue. 142 * 143 * @param s 144 * @param parser 145 * @param attribute 146 * @throws XmlPullParserException 147 * @return boolean 148 */ 149 private boolean getBooleanValue( String s, String attribute, XmlPullParser parser ) 150 throws XmlPullParserException 151 { 152 return getBooleanValue( s, attribute, parser, null ); 153 } //-- boolean getBooleanValue( String, String, XmlPullParser ) 154 155 /** 156 * Method getBooleanValue. 157 * 158 * @param s 159 * @param defaultValue 160 * @param parser 161 * @param attribute 162 * @throws XmlPullParserException 163 * @return boolean 164 */ 165 private boolean getBooleanValue( String s, String attribute, XmlPullParser parser, String defaultValue ) 166 throws XmlPullParserException 167 { 168 if ( s != null && s.length() != 0 ) 169 { 170 return Boolean.valueOf( s ).booleanValue(); 171 } 172 if ( defaultValue != null ) 173 { 174 return Boolean.valueOf( defaultValue ).booleanValue(); 175 } 176 return false; 177 } //-- boolean getBooleanValue( String, String, XmlPullParser, String ) 178 179 /** 180 * Method getByteValue. 181 * 182 * @param s 183 * @param strict 184 * @param parser 185 * @param attribute 186 * @throws XmlPullParserException 187 * @return byte 188 */ 189 private byte getByteValue( String s, String attribute, XmlPullParser parser, boolean strict ) 190 throws XmlPullParserException 191 { 192 if ( s != null ) 193 { 194 try 195 { 196 return Byte.valueOf( s ).byteValue(); 197 } 198 catch ( NumberFormatException nfe ) 199 { 200 if ( strict ) 201 { 202 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a byte", parser, nfe ); 203 } 204 } 205 } 206 return 0; 207 } //-- byte getByteValue( String, String, XmlPullParser, boolean ) 208 209 /** 210 * Method getCharacterValue. 211 * 212 * @param s 213 * @param parser 214 * @param attribute 215 * @throws XmlPullParserException 216 * @return char 217 */ 218 private char getCharacterValue( String s, String attribute, XmlPullParser parser ) 219 throws XmlPullParserException 220 { 221 if ( s != null ) 222 { 223 return s.charAt( 0 ); 224 } 225 return 0; 226 } //-- char getCharacterValue( String, String, XmlPullParser ) 227 228 /** 229 * Method getDateValue. 230 * 231 * @param s 232 * @param parser 233 * @param attribute 234 * @throws XmlPullParserException 235 * @return Date 236 */ 237 private java.util.Date getDateValue( String s, String attribute, XmlPullParser parser ) 238 throws XmlPullParserException 239 { 240 return getDateValue( s, attribute, null, parser ); 241 } //-- java.util.Date getDateValue( String, String, XmlPullParser ) 242 243 /** 244 * Method getDateValue. 245 * 246 * @param s 247 * @param parser 248 * @param dateFormat 249 * @param attribute 250 * @throws XmlPullParserException 251 * @return Date 252 */ 253 private java.util.Date getDateValue( String s, String attribute, String dateFormat, XmlPullParser parser ) 254 throws XmlPullParserException 255 { 256 if ( s != null ) 257 { 258 String effectiveDateFormat = dateFormat; 259 if ( dateFormat == null ) 260 { 261 effectiveDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS"; 262 } 263 if ( "long".equals( effectiveDateFormat ) ) 264 { 265 try 266 { 267 return new java.util.Date( Long.parseLong( s ) ); 268 } 269 catch ( NumberFormatException e ) 270 { 271 throw new XmlPullParserException( e.getMessage(), parser, e ); 272 } 273 } 274 else 275 { 276 try 277 { 278 DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, Locale.US ); 279 return dateParser.parse( s ); 280 } 281 catch ( java.text.ParseException e ) 282 { 283 throw new XmlPullParserException( e.getMessage(), parser, e ); 284 } 285 } 286 } 287 return null; 288 } //-- java.util.Date getDateValue( String, String, String, XmlPullParser ) 289 290 /** 291 * Method getDoubleValue. 292 * 293 * @param s 294 * @param strict 295 * @param parser 296 * @param attribute 297 * @throws XmlPullParserException 298 * @return double 299 */ 300 private double getDoubleValue( String s, String attribute, XmlPullParser parser, boolean strict ) 301 throws XmlPullParserException 302 { 303 if ( s != null ) 304 { 305 try 306 { 307 return Double.valueOf( s ).doubleValue(); 308 } 309 catch ( NumberFormatException nfe ) 310 { 311 if ( strict ) 312 { 313 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe ); 314 } 315 } 316 } 317 return 0; 318 } //-- double getDoubleValue( String, String, XmlPullParser, boolean ) 319 320 /** 321 * Method getFloatValue. 322 * 323 * @param s 324 * @param strict 325 * @param parser 326 * @param attribute 327 * @throws XmlPullParserException 328 * @return float 329 */ 330 private float getFloatValue( String s, String attribute, XmlPullParser parser, boolean strict ) 331 throws XmlPullParserException 332 { 333 if ( s != null ) 334 { 335 try 336 { 337 return Float.valueOf( s ).floatValue(); 338 } 339 catch ( NumberFormatException nfe ) 340 { 341 if ( strict ) 342 { 343 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe ); 344 } 345 } 346 } 347 return 0; 348 } //-- float getFloatValue( String, String, XmlPullParser, boolean ) 349 350 /** 351 * Method getIntegerValue. 352 * 353 * @param s 354 * @param strict 355 * @param parser 356 * @param attribute 357 * @throws XmlPullParserException 358 * @return int 359 */ 360 private int getIntegerValue( String s, String attribute, XmlPullParser parser, boolean strict ) 361 throws XmlPullParserException 362 { 363 if ( s != null ) 364 { 365 try 366 { 367 return Integer.valueOf( s ).intValue(); 368 } 369 catch ( NumberFormatException nfe ) 370 { 371 if ( strict ) 372 { 373 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be an integer", parser, nfe ); 374 } 375 } 376 } 377 return 0; 378 } //-- int getIntegerValue( String, String, XmlPullParser, boolean ) 379 380 /** 381 * Method getLongValue. 382 * 383 * @param s 384 * @param strict 385 * @param parser 386 * @param attribute 387 * @throws XmlPullParserException 388 * @return long 389 */ 390 private long getLongValue( String s, String attribute, XmlPullParser parser, boolean strict ) 391 throws XmlPullParserException 392 { 393 if ( s != null ) 394 { 395 try 396 { 397 return Long.valueOf( s ).longValue(); 398 } 399 catch ( NumberFormatException nfe ) 400 { 401 if ( strict ) 402 { 403 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a long integer", parser, nfe ); 404 } 405 } 406 } 407 return 0; 408 } //-- long getLongValue( String, String, XmlPullParser, boolean ) 409 410 /** 411 * Method getRequiredAttributeValue. 412 * 413 * @param s 414 * @param strict 415 * @param parser 416 * @param attribute 417 * @throws XmlPullParserException 418 * @return String 419 */ 420 private String getRequiredAttributeValue( String s, String attribute, XmlPullParser parser, boolean strict ) 421 throws XmlPullParserException 422 { 423 if ( s == null ) 424 { 425 if ( strict ) 426 { 427 throw new XmlPullParserException( "Missing required value for attribute '" + attribute + "'", parser, null ); 428 } 429 } 430 return s; 431 } //-- String getRequiredAttributeValue( String, String, XmlPullParser, boolean ) 432 433 /** 434 * Method getShortValue. 435 * 436 * @param s 437 * @param strict 438 * @param parser 439 * @param attribute 440 * @throws XmlPullParserException 441 * @return short 442 */ 443 private short getShortValue( String s, String attribute, XmlPullParser parser, boolean strict ) 444 throws XmlPullParserException 445 { 446 if ( s != null ) 447 { 448 try 449 { 450 return Short.valueOf( s ).shortValue(); 451 } 452 catch ( NumberFormatException nfe ) 453 { 454 if ( strict ) 455 { 456 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a short integer", parser, nfe ); 457 } 458 } 459 } 460 return 0; 461 } //-- short getShortValue( String, String, XmlPullParser, boolean ) 462 463 /** 464 * Method getTrimmedValue. 465 * 466 * @param s 467 * @return String 468 */ 469 private String getTrimmedValue( String s ) 470 { 471 if ( s != null ) 472 { 473 s = s.trim(); 474 } 475 return s; 476 } //-- String getTrimmedValue( String ) 477 478 /** 479 * Method initParser. 480 * 481 * @param parser 482 * @throws XmlPullParserException 483 */ 484 private void initParser( XmlPullParser parser ) 485 throws XmlPullParserException 486 { 487 if ( addDefaultEntities ) 488 { 489 // ---------------------------------------------------------------------- 490 // Latin 1 entities 491 // ---------------------------------------------------------------------- 492 493 parser.defineEntityReplacementText( "nbsp", "\u00a0" ); 494 parser.defineEntityReplacementText( "iexcl", "\u00a1" ); 495 parser.defineEntityReplacementText( "cent", "\u00a2" ); 496 parser.defineEntityReplacementText( "pound", "\u00a3" ); 497 parser.defineEntityReplacementText( "curren", "\u00a4" ); 498 parser.defineEntityReplacementText( "yen", "\u00a5" ); 499 parser.defineEntityReplacementText( "brvbar", "\u00a6" ); 500 parser.defineEntityReplacementText( "sect", "\u00a7" ); 501 parser.defineEntityReplacementText( "uml", "\u00a8" ); 502 parser.defineEntityReplacementText( "copy", "\u00a9" ); 503 parser.defineEntityReplacementText( "ordf", "\u00aa" ); 504 parser.defineEntityReplacementText( "laquo", "\u00ab" ); 505 parser.defineEntityReplacementText( "not", "\u00ac" ); 506 parser.defineEntityReplacementText( "shy", "\u00ad" ); 507 parser.defineEntityReplacementText( "reg", "\u00ae" ); 508 parser.defineEntityReplacementText( "macr", "\u00af" ); 509 parser.defineEntityReplacementText( "deg", "\u00b0" ); 510 parser.defineEntityReplacementText( "plusmn", "\u00b1" ); 511 parser.defineEntityReplacementText( "sup2", "\u00b2" ); 512 parser.defineEntityReplacementText( "sup3", "\u00b3" ); 513 parser.defineEntityReplacementText( "acute", "\u00b4" ); 514 parser.defineEntityReplacementText( "micro", "\u00b5" ); 515 parser.defineEntityReplacementText( "para", "\u00b6" ); 516 parser.defineEntityReplacementText( "middot", "\u00b7" ); 517 parser.defineEntityReplacementText( "cedil", "\u00b8" ); 518 parser.defineEntityReplacementText( "sup1", "\u00b9" ); 519 parser.defineEntityReplacementText( "ordm", "\u00ba" ); 520 parser.defineEntityReplacementText( "raquo", "\u00bb" ); 521 parser.defineEntityReplacementText( "frac14", "\u00bc" ); 522 parser.defineEntityReplacementText( "frac12", "\u00bd" ); 523 parser.defineEntityReplacementText( "frac34", "\u00be" ); 524 parser.defineEntityReplacementText( "iquest", "\u00bf" ); 525 parser.defineEntityReplacementText( "Agrave", "\u00c0" ); 526 parser.defineEntityReplacementText( "Aacute", "\u00c1" ); 527 parser.defineEntityReplacementText( "Acirc", "\u00c2" ); 528 parser.defineEntityReplacementText( "Atilde", "\u00c3" ); 529 parser.defineEntityReplacementText( "Auml", "\u00c4" ); 530 parser.defineEntityReplacementText( "Aring", "\u00c5" ); 531 parser.defineEntityReplacementText( "AElig", "\u00c6" ); 532 parser.defineEntityReplacementText( "Ccedil", "\u00c7" ); 533 parser.defineEntityReplacementText( "Egrave", "\u00c8" ); 534 parser.defineEntityReplacementText( "Eacute", "\u00c9" ); 535 parser.defineEntityReplacementText( "Ecirc", "\u00ca" ); 536 parser.defineEntityReplacementText( "Euml", "\u00cb" ); 537 parser.defineEntityReplacementText( "Igrave", "\u00cc" ); 538 parser.defineEntityReplacementText( "Iacute", "\u00cd" ); 539 parser.defineEntityReplacementText( "Icirc", "\u00ce" ); 540 parser.defineEntityReplacementText( "Iuml", "\u00cf" ); 541 parser.defineEntityReplacementText( "ETH", "\u00d0" ); 542 parser.defineEntityReplacementText( "Ntilde", "\u00d1" ); 543 parser.defineEntityReplacementText( "Ograve", "\u00d2" ); 544 parser.defineEntityReplacementText( "Oacute", "\u00d3" ); 545 parser.defineEntityReplacementText( "Ocirc", "\u00d4" ); 546 parser.defineEntityReplacementText( "Otilde", "\u00d5" ); 547 parser.defineEntityReplacementText( "Ouml", "\u00d6" ); 548 parser.defineEntityReplacementText( "times", "\u00d7" ); 549 parser.defineEntityReplacementText( "Oslash", "\u00d8" ); 550 parser.defineEntityReplacementText( "Ugrave", "\u00d9" ); 551 parser.defineEntityReplacementText( "Uacute", "\u00da" ); 552 parser.defineEntityReplacementText( "Ucirc", "\u00db" ); 553 parser.defineEntityReplacementText( "Uuml", "\u00dc" ); 554 parser.defineEntityReplacementText( "Yacute", "\u00dd" ); 555 parser.defineEntityReplacementText( "THORN", "\u00de" ); 556 parser.defineEntityReplacementText( "szlig", "\u00df" ); 557 parser.defineEntityReplacementText( "agrave", "\u00e0" ); 558 parser.defineEntityReplacementText( "aacute", "\u00e1" ); 559 parser.defineEntityReplacementText( "acirc", "\u00e2" ); 560 parser.defineEntityReplacementText( "atilde", "\u00e3" ); 561 parser.defineEntityReplacementText( "auml", "\u00e4" ); 562 parser.defineEntityReplacementText( "aring", "\u00e5" ); 563 parser.defineEntityReplacementText( "aelig", "\u00e6" ); 564 parser.defineEntityReplacementText( "ccedil", "\u00e7" ); 565 parser.defineEntityReplacementText( "egrave", "\u00e8" ); 566 parser.defineEntityReplacementText( "eacute", "\u00e9" ); 567 parser.defineEntityReplacementText( "ecirc", "\u00ea" ); 568 parser.defineEntityReplacementText( "euml", "\u00eb" ); 569 parser.defineEntityReplacementText( "igrave", "\u00ec" ); 570 parser.defineEntityReplacementText( "iacute", "\u00ed" ); 571 parser.defineEntityReplacementText( "icirc", "\u00ee" ); 572 parser.defineEntityReplacementText( "iuml", "\u00ef" ); 573 parser.defineEntityReplacementText( "eth", "\u00f0" ); 574 parser.defineEntityReplacementText( "ntilde", "\u00f1" ); 575 parser.defineEntityReplacementText( "ograve", "\u00f2" ); 576 parser.defineEntityReplacementText( "oacute", "\u00f3" ); 577 parser.defineEntityReplacementText( "ocirc", "\u00f4" ); 578 parser.defineEntityReplacementText( "otilde", "\u00f5" ); 579 parser.defineEntityReplacementText( "ouml", "\u00f6" ); 580 parser.defineEntityReplacementText( "divide", "\u00f7" ); 581 parser.defineEntityReplacementText( "oslash", "\u00f8" ); 582 parser.defineEntityReplacementText( "ugrave", "\u00f9" ); 583 parser.defineEntityReplacementText( "uacute", "\u00fa" ); 584 parser.defineEntityReplacementText( "ucirc", "\u00fb" ); 585 parser.defineEntityReplacementText( "uuml", "\u00fc" ); 586 parser.defineEntityReplacementText( "yacute", "\u00fd" ); 587 parser.defineEntityReplacementText( "thorn", "\u00fe" ); 588 parser.defineEntityReplacementText( "yuml", "\u00ff" ); 589 590 // ---------------------------------------------------------------------- 591 // Special entities 592 // ---------------------------------------------------------------------- 593 594 parser.defineEntityReplacementText( "OElig", "\u0152" ); 595 parser.defineEntityReplacementText( "oelig", "\u0153" ); 596 parser.defineEntityReplacementText( "Scaron", "\u0160" ); 597 parser.defineEntityReplacementText( "scaron", "\u0161" ); 598 parser.defineEntityReplacementText( "Yuml", "\u0178" ); 599 parser.defineEntityReplacementText( "circ", "\u02c6" ); 600 parser.defineEntityReplacementText( "tilde", "\u02dc" ); 601 parser.defineEntityReplacementText( "ensp", "\u2002" ); 602 parser.defineEntityReplacementText( "emsp", "\u2003" ); 603 parser.defineEntityReplacementText( "thinsp", "\u2009" ); 604 parser.defineEntityReplacementText( "zwnj", "\u200c" ); 605 parser.defineEntityReplacementText( "zwj", "\u200d" ); 606 parser.defineEntityReplacementText( "lrm", "\u200e" ); 607 parser.defineEntityReplacementText( "rlm", "\u200f" ); 608 parser.defineEntityReplacementText( "ndash", "\u2013" ); 609 parser.defineEntityReplacementText( "mdash", "\u2014" ); 610 parser.defineEntityReplacementText( "lsquo", "\u2018" ); 611 parser.defineEntityReplacementText( "rsquo", "\u2019" ); 612 parser.defineEntityReplacementText( "sbquo", "\u201a" ); 613 parser.defineEntityReplacementText( "ldquo", "\u201c" ); 614 parser.defineEntityReplacementText( "rdquo", "\u201d" ); 615 parser.defineEntityReplacementText( "bdquo", "\u201e" ); 616 parser.defineEntityReplacementText( "dagger", "\u2020" ); 617 parser.defineEntityReplacementText( "Dagger", "\u2021" ); 618 parser.defineEntityReplacementText( "permil", "\u2030" ); 619 parser.defineEntityReplacementText( "lsaquo", "\u2039" ); 620 parser.defineEntityReplacementText( "rsaquo", "\u203a" ); 621 parser.defineEntityReplacementText( "euro", "\u20ac" ); 622 623 // ---------------------------------------------------------------------- 624 // Symbol entities 625 // ---------------------------------------------------------------------- 626 627 parser.defineEntityReplacementText( "fnof", "\u0192" ); 628 parser.defineEntityReplacementText( "Alpha", "\u0391" ); 629 parser.defineEntityReplacementText( "Beta", "\u0392" ); 630 parser.defineEntityReplacementText( "Gamma", "\u0393" ); 631 parser.defineEntityReplacementText( "Delta", "\u0394" ); 632 parser.defineEntityReplacementText( "Epsilon", "\u0395" ); 633 parser.defineEntityReplacementText( "Zeta", "\u0396" ); 634 parser.defineEntityReplacementText( "Eta", "\u0397" ); 635 parser.defineEntityReplacementText( "Theta", "\u0398" ); 636 parser.defineEntityReplacementText( "Iota", "\u0399" ); 637 parser.defineEntityReplacementText( "Kappa", "\u039a" ); 638 parser.defineEntityReplacementText( "Lambda", "\u039b" ); 639 parser.defineEntityReplacementText( "Mu", "\u039c" ); 640 parser.defineEntityReplacementText( "Nu", "\u039d" ); 641 parser.defineEntityReplacementText( "Xi", "\u039e" ); 642 parser.defineEntityReplacementText( "Omicron", "\u039f" ); 643 parser.defineEntityReplacementText( "Pi", "\u03a0" ); 644 parser.defineEntityReplacementText( "Rho", "\u03a1" ); 645 parser.defineEntityReplacementText( "Sigma", "\u03a3" ); 646 parser.defineEntityReplacementText( "Tau", "\u03a4" ); 647 parser.defineEntityReplacementText( "Upsilon", "\u03a5" ); 648 parser.defineEntityReplacementText( "Phi", "\u03a6" ); 649 parser.defineEntityReplacementText( "Chi", "\u03a7" ); 650 parser.defineEntityReplacementText( "Psi", "\u03a8" ); 651 parser.defineEntityReplacementText( "Omega", "\u03a9" ); 652 parser.defineEntityReplacementText( "alpha", "\u03b1" ); 653 parser.defineEntityReplacementText( "beta", "\u03b2" ); 654 parser.defineEntityReplacementText( "gamma", "\u03b3" ); 655 parser.defineEntityReplacementText( "delta", "\u03b4" ); 656 parser.defineEntityReplacementText( "epsilon", "\u03b5" ); 657 parser.defineEntityReplacementText( "zeta", "\u03b6" ); 658 parser.defineEntityReplacementText( "eta", "\u03b7" ); 659 parser.defineEntityReplacementText( "theta", "\u03b8" ); 660 parser.defineEntityReplacementText( "iota", "\u03b9" ); 661 parser.defineEntityReplacementText( "kappa", "\u03ba" ); 662 parser.defineEntityReplacementText( "lambda", "\u03bb" ); 663 parser.defineEntityReplacementText( "mu", "\u03bc" ); 664 parser.defineEntityReplacementText( "nu", "\u03bd" ); 665 parser.defineEntityReplacementText( "xi", "\u03be" ); 666 parser.defineEntityReplacementText( "omicron", "\u03bf" ); 667 parser.defineEntityReplacementText( "pi", "\u03c0" ); 668 parser.defineEntityReplacementText( "rho", "\u03c1" ); 669 parser.defineEntityReplacementText( "sigmaf", "\u03c2" ); 670 parser.defineEntityReplacementText( "sigma", "\u03c3" ); 671 parser.defineEntityReplacementText( "tau", "\u03c4" ); 672 parser.defineEntityReplacementText( "upsilon", "\u03c5" ); 673 parser.defineEntityReplacementText( "phi", "\u03c6" ); 674 parser.defineEntityReplacementText( "chi", "\u03c7" ); 675 parser.defineEntityReplacementText( "psi", "\u03c8" ); 676 parser.defineEntityReplacementText( "omega", "\u03c9" ); 677 parser.defineEntityReplacementText( "thetasym", "\u03d1" ); 678 parser.defineEntityReplacementText( "upsih", "\u03d2" ); 679 parser.defineEntityReplacementText( "piv", "\u03d6" ); 680 parser.defineEntityReplacementText( "bull", "\u2022" ); 681 parser.defineEntityReplacementText( "hellip", "\u2026" ); 682 parser.defineEntityReplacementText( "prime", "\u2032" ); 683 parser.defineEntityReplacementText( "Prime", "\u2033" ); 684 parser.defineEntityReplacementText( "oline", "\u203e" ); 685 parser.defineEntityReplacementText( "frasl", "\u2044" ); 686 parser.defineEntityReplacementText( "weierp", "\u2118" ); 687 parser.defineEntityReplacementText( "image", "\u2111" ); 688 parser.defineEntityReplacementText( "real", "\u211c" ); 689 parser.defineEntityReplacementText( "trade", "\u2122" ); 690 parser.defineEntityReplacementText( "alefsym", "\u2135" ); 691 parser.defineEntityReplacementText( "larr", "\u2190" ); 692 parser.defineEntityReplacementText( "uarr", "\u2191" ); 693 parser.defineEntityReplacementText( "rarr", "\u2192" ); 694 parser.defineEntityReplacementText( "darr", "\u2193" ); 695 parser.defineEntityReplacementText( "harr", "\u2194" ); 696 parser.defineEntityReplacementText( "crarr", "\u21b5" ); 697 parser.defineEntityReplacementText( "lArr", "\u21d0" ); 698 parser.defineEntityReplacementText( "uArr", "\u21d1" ); 699 parser.defineEntityReplacementText( "rArr", "\u21d2" ); 700 parser.defineEntityReplacementText( "dArr", "\u21d3" ); 701 parser.defineEntityReplacementText( "hArr", "\u21d4" ); 702 parser.defineEntityReplacementText( "forall", "\u2200" ); 703 parser.defineEntityReplacementText( "part", "\u2202" ); 704 parser.defineEntityReplacementText( "exist", "\u2203" ); 705 parser.defineEntityReplacementText( "empty", "\u2205" ); 706 parser.defineEntityReplacementText( "nabla", "\u2207" ); 707 parser.defineEntityReplacementText( "isin", "\u2208" ); 708 parser.defineEntityReplacementText( "notin", "\u2209" ); 709 parser.defineEntityReplacementText( "ni", "\u220b" ); 710 parser.defineEntityReplacementText( "prod", "\u220f" ); 711 parser.defineEntityReplacementText( "sum", "\u2211" ); 712 parser.defineEntityReplacementText( "minus", "\u2212" ); 713 parser.defineEntityReplacementText( "lowast", "\u2217" ); 714 parser.defineEntityReplacementText( "radic", "\u221a" ); 715 parser.defineEntityReplacementText( "prop", "\u221d" ); 716 parser.defineEntityReplacementText( "infin", "\u221e" ); 717 parser.defineEntityReplacementText( "ang", "\u2220" ); 718 parser.defineEntityReplacementText( "and", "\u2227" ); 719 parser.defineEntityReplacementText( "or", "\u2228" ); 720 parser.defineEntityReplacementText( "cap", "\u2229" ); 721 parser.defineEntityReplacementText( "cup", "\u222a" ); 722 parser.defineEntityReplacementText( "int", "\u222b" ); 723 parser.defineEntityReplacementText( "there4", "\u2234" ); 724 parser.defineEntityReplacementText( "sim", "\u223c" ); 725 parser.defineEntityReplacementText( "cong", "\u2245" ); 726 parser.defineEntityReplacementText( "asymp", "\u2248" ); 727 parser.defineEntityReplacementText( "ne", "\u2260" ); 728 parser.defineEntityReplacementText( "equiv", "\u2261" ); 729 parser.defineEntityReplacementText( "le", "\u2264" ); 730 parser.defineEntityReplacementText( "ge", "\u2265" ); 731 parser.defineEntityReplacementText( "sub", "\u2282" ); 732 parser.defineEntityReplacementText( "sup", "\u2283" ); 733 parser.defineEntityReplacementText( "nsub", "\u2284" ); 734 parser.defineEntityReplacementText( "sube", "\u2286" ); 735 parser.defineEntityReplacementText( "supe", "\u2287" ); 736 parser.defineEntityReplacementText( "oplus", "\u2295" ); 737 parser.defineEntityReplacementText( "otimes", "\u2297" ); 738 parser.defineEntityReplacementText( "perp", "\u22a5" ); 739 parser.defineEntityReplacementText( "sdot", "\u22c5" ); 740 parser.defineEntityReplacementText( "lceil", "\u2308" ); 741 parser.defineEntityReplacementText( "rceil", "\u2309" ); 742 parser.defineEntityReplacementText( "lfloor", "\u230a" ); 743 parser.defineEntityReplacementText( "rfloor", "\u230b" ); 744 parser.defineEntityReplacementText( "lang", "\u2329" ); 745 parser.defineEntityReplacementText( "rang", "\u232a" ); 746 parser.defineEntityReplacementText( "loz", "\u25ca" ); 747 parser.defineEntityReplacementText( "spades", "\u2660" ); 748 parser.defineEntityReplacementText( "clubs", "\u2663" ); 749 parser.defineEntityReplacementText( "hearts", "\u2665" ); 750 parser.defineEntityReplacementText( "diams", "\u2666" ); 751 752 } 753 } //-- void initParser( XmlPullParser ) 754 755 /** 756 * Method nextTag. 757 * 758 * @param parser 759 * @throws IOException 760 * @throws XmlPullParserException 761 * @return int 762 */ 763 private int nextTag( XmlPullParser parser ) 764 throws IOException, XmlPullParserException 765 { 766 int eventType = parser.next(); 767 if ( eventType == XmlPullParser.TEXT ) 768 { 769 eventType = parser.next(); 770 } 771 if ( eventType != XmlPullParser.START_TAG && eventType != XmlPullParser.END_TAG ) 772 { 773 throw new XmlPullParserException( "expected START_TAG or END_TAG not " + XmlPullParser.TYPES[eventType], parser, null ); 774 } 775 return eventType; 776 } //-- int nextTag( XmlPullParser ) 777 778 /** 779 * Method parseExpression. 780 * 781 * @param parser 782 * @param strict 783 * @throws IOException 784 * @throws XmlPullParserException 785 * @return Expression 786 */ 787 private Expression parseExpression( XmlPullParser parser, boolean strict ) 788 throws IOException, XmlPullParserException 789 { 790 String tagName = parser.getName(); 791 Expression expression = new Expression(); 792 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 793 { 794 String name = parser.getAttributeName( i ); 795 String value = parser.getAttributeValue( i ); 796 797 if ( name.indexOf( ':' ) >= 0 ) 798 { 799 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 800 } 801 else 802 { 803 checkUnknownAttribute( parser, name, tagName, strict ); 804 } 805 } 806 java.util.Set parsed = new java.util.HashSet(); 807 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 808 { 809 if ( checkFieldWithDuplicate( parser, "syntax", null, parsed ) ) 810 { 811 expression.setSyntax( getTrimmedValue( parser.nextText() ) ); 812 } 813 else if ( checkFieldWithDuplicate( parser, "description", null, parsed ) ) 814 { 815 expression.setDescription( getTrimmedValue( parser.nextText() ) ); 816 } 817 else if ( checkFieldWithDuplicate( parser, "configuration", null, parsed ) ) 818 { 819 expression.setConfiguration( getTrimmedValue( parser.nextText() ) ); 820 } 821 else if ( checkFieldWithDuplicate( parser, "cliOptions", null, parsed ) ) 822 { 823 while ( parser.nextTag() == XmlPullParser.START_TAG ) 824 { 825 if ( "cliOption".equals( parser.getName() ) ) 826 { 827 String key = null; 828 String value = null; 829 // explode mode. 830 while ( parser.nextTag() == XmlPullParser.START_TAG ) 831 { 832 if ( "key".equals( parser.getName() ) ) 833 { 834 key = parser.nextText(); 835 } 836 else if ( "value".equals( parser.getName() ) ) 837 { 838 value = parser.nextText().trim(); 839 } 840 else 841 { 842 parser.nextText(); 843 } 844 } 845 expression.addCliOption( key, value ); 846 } 847 parser.next(); 848 } 849 } 850 else if ( checkFieldWithDuplicate( parser, "apiMethods", null, parsed ) ) 851 { 852 while ( parser.nextTag() == XmlPullParser.START_TAG ) 853 { 854 if ( "apiMethod".equals( parser.getName() ) ) 855 { 856 String key = null; 857 String value = null; 858 // explode mode. 859 while ( parser.nextTag() == XmlPullParser.START_TAG ) 860 { 861 if ( "key".equals( parser.getName() ) ) 862 { 863 key = parser.nextText(); 864 } 865 else if ( "value".equals( parser.getName() ) ) 866 { 867 value = parser.nextText().trim(); 868 } 869 else 870 { 871 parser.nextText(); 872 } 873 } 874 expression.addApiMethod( key, value ); 875 } 876 parser.next(); 877 } 878 } 879 else if ( checkFieldWithDuplicate( parser, "deprecation", null, parsed ) ) 880 { 881 expression.setDeprecation( getTrimmedValue( parser.nextText() ) ); 882 } 883 else if ( checkFieldWithDuplicate( parser, "ban", null, parsed ) ) 884 { 885 expression.setBan( getTrimmedValue( parser.nextText() ) ); 886 } 887 else if ( checkFieldWithDuplicate( parser, "editable", null, parsed ) ) 888 { 889 expression.setEditable( getBooleanValue( getTrimmedValue( parser.nextText() ), "editable", parser, "true" ) ); 890 } 891 else 892 { 893 checkUnknownElement( parser, strict ); 894 } 895 } 896 return expression; 897 } //-- Expression parseExpression( XmlPullParser, boolean ) 898 899 /** 900 * Method parseExpressionDocumentation. 901 * 902 * @param parser 903 * @param strict 904 * @throws IOException 905 * @throws XmlPullParserException 906 * @return ExpressionDocumentation 907 */ 908 private ExpressionDocumentation parseExpressionDocumentation( XmlPullParser parser, boolean strict ) 909 throws IOException, XmlPullParserException 910 { 911 String tagName = parser.getName(); 912 ExpressionDocumentation expressionDocumentation = new ExpressionDocumentation(); 913 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) 914 { 915 String name = parser.getAttributeName( i ); 916 String value = parser.getAttributeValue( i ); 917 918 if ( name.indexOf( ':' ) >= 0 ) 919 { 920 // just ignore attributes with non-default namespace (for example: xmlns:xsi) 921 } 922 else if ( "xmlns".equals( name ) ) 923 { 924 // ignore xmlns attribute in root class, which is a reserved attribute name 925 } 926 else 927 { 928 checkUnknownAttribute( parser, name, tagName, strict ); 929 } 930 } 931 java.util.Set parsed = new java.util.HashSet(); 932 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) 933 { 934 if ( checkFieldWithDuplicate( parser, "expressions", null, parsed ) ) 935 { 936 java.util.List expressions = new java.util.ArrayList/*<Expression>*/(); 937 expressionDocumentation.setExpressions( expressions ); 938 while ( parser.nextTag() == XmlPullParser.START_TAG ) 939 { 940 if ( "expression".equals( parser.getName() ) ) 941 { 942 expressions.add( parseExpression( parser, strict ) ); 943 } 944 else 945 { 946 checkUnknownElement( parser, strict ); 947 } 948 } 949 } 950 else 951 { 952 checkUnknownElement( parser, strict ); 953 } 954 } 955 return expressionDocumentation; 956 } //-- ExpressionDocumentation parseExpressionDocumentation( XmlPullParser, boolean ) 957 958 /** 959 * @see ReaderFactory#newXmlReader 960 * 961 * @param reader 962 * @param strict 963 * @throws IOException 964 * @throws XmlPullParserException 965 * @return ExpressionDocumentation 966 */ 967 public ExpressionDocumentation read( Reader reader, boolean strict ) 968 throws IOException, XmlPullParserException 969 { 970 XmlPullParser parser = new MXParser(); 971 972 parser.setInput( reader ); 973 974 initParser( parser ); 975 976 return read( parser, strict ); 977 } //-- ExpressionDocumentation read( Reader, boolean ) 978 979 /** 980 * @see ReaderFactory#newXmlReader 981 * 982 * @param reader 983 * @throws IOException 984 * @throws XmlPullParserException 985 * @return ExpressionDocumentation 986 */ 987 public ExpressionDocumentation read( Reader reader ) 988 throws IOException, XmlPullParserException 989 { 990 return read( reader, true ); 991 } //-- ExpressionDocumentation read( Reader ) 992 993 /** 994 * Method read. 995 * 996 * @param in 997 * @param strict 998 * @throws IOException 999 * @throws XmlPullParserException 1000 * @return ExpressionDocumentation 1001 */ 1002 public ExpressionDocumentation read( InputStream in, boolean strict ) 1003 throws IOException, XmlPullParserException 1004 { 1005 return read( ReaderFactory.newXmlReader( in ), strict ); 1006 } //-- ExpressionDocumentation read( InputStream, boolean ) 1007 1008 /** 1009 * Method read. 1010 * 1011 * @param in 1012 * @throws IOException 1013 * @throws XmlPullParserException 1014 * @return ExpressionDocumentation 1015 */ 1016 public ExpressionDocumentation read( InputStream in ) 1017 throws IOException, XmlPullParserException 1018 { 1019 return read( ReaderFactory.newXmlReader( in ) ); 1020 } //-- ExpressionDocumentation read( InputStream ) 1021 1022 /** 1023 * Method read. 1024 * 1025 * @param parser 1026 * @param strict 1027 * @throws IOException 1028 * @throws XmlPullParserException 1029 * @return ExpressionDocumentation 1030 */ 1031 private ExpressionDocumentation read( XmlPullParser parser, boolean strict ) 1032 throws IOException, XmlPullParserException 1033 { 1034 int eventType = parser.getEventType(); 1035 while ( eventType != XmlPullParser.END_DOCUMENT ) 1036 { 1037 if ( eventType == XmlPullParser.START_TAG ) 1038 { 1039 if ( strict && ! "paramdoc".equals( parser.getName() ) ) 1040 { 1041 throw new XmlPullParserException( "Expected root element 'paramdoc' but found '" + parser.getName() + "'", parser, null ); 1042 } 1043 ExpressionDocumentation expressionDocumentation = parseExpressionDocumentation( parser, strict ); 1044 expressionDocumentation.setModelEncoding( parser.getInputEncoding() ); 1045 return expressionDocumentation; 1046 } 1047 eventType = parser.next(); 1048 } 1049 throw new XmlPullParserException( "Expected root element 'paramdoc' but found no element at all: invalid XML document", parser, null ); 1050 } //-- ExpressionDocumentation read( XmlPullParser, boolean ) 1051 1052 /** 1053 * Sets the state of the "add default entities" flag. 1054 * 1055 * @param addDefaultEntities 1056 */ 1057 public void setAddDefaultEntities( boolean addDefaultEntities ) 1058 { 1059 this.addDefaultEntities = addDefaultEntities; 1060 } //-- void setAddDefaultEntities( boolean ) 1061 1062 }