| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
package org.codehaus.mojo.nbm.model.io.xpp3; |
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
import java.io.IOException; |
| 15 | |
import java.io.InputStream; |
| 16 | |
import java.io.Reader; |
| 17 | |
import java.text.DateFormat; |
| 18 | |
import org.codehaus.mojo.nbm.model.Dependency; |
| 19 | |
import org.codehaus.mojo.nbm.model.NbmResource; |
| 20 | |
import org.codehaus.mojo.nbm.model.NetBeansModule; |
| 21 | |
import org.codehaus.plexus.util.ReaderFactory; |
| 22 | |
import org.codehaus.plexus.util.xml.pull.MXParser; |
| 23 | |
import org.codehaus.plexus.util.xml.pull.XmlPullParser; |
| 24 | |
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; |
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
@SuppressWarnings( "all" ) |
| 32 | 0 | public class NetBeansModuleXpp3Reader |
| 33 | |
{ |
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | 0 | private boolean addDefaultEntities = true; |
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
private boolean checkFieldWithDuplicate( XmlPullParser parser, String tagName, String alias, java.util.Set parsed ) |
| 67 | |
throws XmlPullParserException |
| 68 | |
{ |
| 69 | 0 | if ( !( parser.getName().equals( tagName ) || parser.getName().equals( alias ) ) ) |
| 70 | |
{ |
| 71 | 0 | return false; |
| 72 | |
} |
| 73 | 0 | if ( !parsed.add( tagName ) ) |
| 74 | |
{ |
| 75 | 0 | throw new XmlPullParserException( "Duplicated tag: '" + tagName + "'", parser, null ); |
| 76 | |
} |
| 77 | 0 | return true; |
| 78 | |
} |
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
private void checkUnknownAttribute( XmlPullParser parser, String attribute, String tagName, boolean strict ) |
| 91 | |
throws XmlPullParserException, IOException |
| 92 | |
{ |
| 93 | |
|
| 94 | 0 | if ( strict ) |
| 95 | |
{ |
| 96 | 0 | throw new XmlPullParserException( "Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser, null ); |
| 97 | |
} |
| 98 | 0 | } |
| 99 | |
|
| 100 | |
|
| 101 | |
|
| 102 | |
|
| 103 | |
|
| 104 | |
|
| 105 | |
|
| 106 | |
|
| 107 | |
|
| 108 | |
private void checkUnknownElement( XmlPullParser parser, boolean strict ) |
| 109 | |
throws XmlPullParserException, IOException |
| 110 | |
{ |
| 111 | 0 | if ( strict ) |
| 112 | |
{ |
| 113 | 0 | throw new XmlPullParserException( "Unrecognised tag: '" + parser.getName() + "'", parser, null ); |
| 114 | |
} |
| 115 | |
|
| 116 | 0 | for ( int unrecognizedTagCount = 1; unrecognizedTagCount > 0; ) |
| 117 | |
{ |
| 118 | 0 | int eventType = parser.next(); |
| 119 | 0 | if ( eventType == XmlPullParser.START_TAG ) |
| 120 | |
{ |
| 121 | 0 | unrecognizedTagCount++; |
| 122 | |
} |
| 123 | 0 | else if ( eventType == XmlPullParser.END_TAG ) |
| 124 | |
{ |
| 125 | 0 | unrecognizedTagCount--; |
| 126 | |
} |
| 127 | 0 | } |
| 128 | 0 | } |
| 129 | |
|
| 130 | |
|
| 131 | |
|
| 132 | |
|
| 133 | |
|
| 134 | |
|
| 135 | |
public boolean getAddDefaultEntities() |
| 136 | |
{ |
| 137 | 0 | return addDefaultEntities; |
| 138 | |
} |
| 139 | |
|
| 140 | |
|
| 141 | |
|
| 142 | |
|
| 143 | |
|
| 144 | |
|
| 145 | |
|
| 146 | |
|
| 147 | |
|
| 148 | |
|
| 149 | |
private boolean getBooleanValue( String s, String attribute, XmlPullParser parser ) |
| 150 | |
throws XmlPullParserException |
| 151 | |
{ |
| 152 | 0 | return getBooleanValue( s, attribute, parser, null ); |
| 153 | |
} |
| 154 | |
|
| 155 | |
|
| 156 | |
|
| 157 | |
|
| 158 | |
|
| 159 | |
|
| 160 | |
|
| 161 | |
|
| 162 | |
|
| 163 | |
|
| 164 | |
|
| 165 | |
private boolean getBooleanValue( String s, String attribute, XmlPullParser parser, String defaultValue ) |
| 166 | |
throws XmlPullParserException |
| 167 | |
{ |
| 168 | 0 | if ( s != null && s.length() != 0 ) |
| 169 | |
{ |
| 170 | 0 | return Boolean.valueOf( s ).booleanValue(); |
| 171 | |
} |
| 172 | 0 | if ( defaultValue != null ) |
| 173 | |
{ |
| 174 | 0 | return Boolean.valueOf( defaultValue ).booleanValue(); |
| 175 | |
} |
| 176 | 0 | return false; |
| 177 | |
} |
| 178 | |
|
| 179 | |
|
| 180 | |
|
| 181 | |
|
| 182 | |
|
| 183 | |
|
| 184 | |
|
| 185 | |
|
| 186 | |
|
| 187 | |
|
| 188 | |
|
| 189 | |
private byte getByteValue( String s, String attribute, XmlPullParser parser, boolean strict ) |
| 190 | |
throws XmlPullParserException |
| 191 | |
{ |
| 192 | 0 | if ( s != null ) |
| 193 | |
{ |
| 194 | |
try |
| 195 | |
{ |
| 196 | 0 | return Byte.valueOf( s ).byteValue(); |
| 197 | |
} |
| 198 | 0 | catch ( NumberFormatException nfe ) |
| 199 | |
{ |
| 200 | 0 | if ( strict ) |
| 201 | |
{ |
| 202 | 0 | throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a byte", parser, nfe ); |
| 203 | |
} |
| 204 | |
} |
| 205 | |
} |
| 206 | 0 | return 0; |
| 207 | |
} |
| 208 | |
|
| 209 | |
|
| 210 | |
|
| 211 | |
|
| 212 | |
|
| 213 | |
|
| 214 | |
|
| 215 | |
|
| 216 | |
|
| 217 | |
|
| 218 | |
private char getCharacterValue( String s, String attribute, XmlPullParser parser ) |
| 219 | |
throws XmlPullParserException |
| 220 | |
{ |
| 221 | 0 | if ( s != null ) |
| 222 | |
{ |
| 223 | 0 | return s.charAt( 0 ); |
| 224 | |
} |
| 225 | 0 | return 0; |
| 226 | |
} |
| 227 | |
|
| 228 | |
|
| 229 | |
|
| 230 | |
|
| 231 | |
|
| 232 | |
|
| 233 | |
|
| 234 | |
|
| 235 | |
|
| 236 | |
|
| 237 | |
private java.util.Date getDateValue( String s, String attribute, XmlPullParser parser ) |
| 238 | |
throws XmlPullParserException |
| 239 | |
{ |
| 240 | 0 | return getDateValue( s, attribute, null, parser ); |
| 241 | |
} |
| 242 | |
|
| 243 | |
|
| 244 | |
|
| 245 | |
|
| 246 | |
|
| 247 | |
|
| 248 | |
|
| 249 | |
|
| 250 | |
|
| 251 | |
|
| 252 | |
|
| 253 | |
private java.util.Date getDateValue( String s, String attribute, String dateFormat, XmlPullParser parser ) |
| 254 | |
throws XmlPullParserException |
| 255 | |
{ |
| 256 | 0 | if ( s != null ) |
| 257 | |
{ |
| 258 | 0 | String effectiveDateFormat = dateFormat; |
| 259 | 0 | if ( dateFormat == null ) |
| 260 | |
{ |
| 261 | 0 | effectiveDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS"; |
| 262 | |
} |
| 263 | 0 | if ( "long".equals( effectiveDateFormat ) ) |
| 264 | |
{ |
| 265 | |
try |
| 266 | |
{ |
| 267 | 0 | return new java.util.Date( Long.parseLong( s ) ); |
| 268 | |
} |
| 269 | 0 | catch ( NumberFormatException e ) |
| 270 | |
{ |
| 271 | 0 | throw new XmlPullParserException( e.getMessage(), parser, e ); |
| 272 | |
} |
| 273 | |
} |
| 274 | |
else |
| 275 | |
{ |
| 276 | |
try |
| 277 | |
{ |
| 278 | 0 | DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, java.util.Locale.US ); |
| 279 | 0 | return dateParser.parse( s ); |
| 280 | |
} |
| 281 | 0 | catch ( java.text.ParseException e ) |
| 282 | |
{ |
| 283 | 0 | throw new XmlPullParserException( e.getMessage(), parser, e ); |
| 284 | |
} |
| 285 | |
} |
| 286 | |
} |
| 287 | 0 | return null; |
| 288 | |
} |
| 289 | |
|
| 290 | |
|
| 291 | |
|
| 292 | |
|
| 293 | |
|
| 294 | |
|
| 295 | |
|
| 296 | |
|
| 297 | |
|
| 298 | |
|
| 299 | |
|
| 300 | |
private double getDoubleValue( String s, String attribute, XmlPullParser parser, boolean strict ) |
| 301 | |
throws XmlPullParserException |
| 302 | |
{ |
| 303 | 0 | if ( s != null ) |
| 304 | |
{ |
| 305 | |
try |
| 306 | |
{ |
| 307 | 0 | return Double.valueOf( s ).doubleValue(); |
| 308 | |
} |
| 309 | 0 | catch ( NumberFormatException nfe ) |
| 310 | |
{ |
| 311 | 0 | if ( strict ) |
| 312 | |
{ |
| 313 | 0 | throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe ); |
| 314 | |
} |
| 315 | |
} |
| 316 | |
} |
| 317 | 0 | return 0; |
| 318 | |
} |
| 319 | |
|
| 320 | |
|
| 321 | |
|
| 322 | |
|
| 323 | |
|
| 324 | |
|
| 325 | |
|
| 326 | |
|
| 327 | |
|
| 328 | |
|
| 329 | |
|
| 330 | |
private float getFloatValue( String s, String attribute, XmlPullParser parser, boolean strict ) |
| 331 | |
throws XmlPullParserException |
| 332 | |
{ |
| 333 | 0 | if ( s != null ) |
| 334 | |
{ |
| 335 | |
try |
| 336 | |
{ |
| 337 | 0 | return Float.valueOf( s ).floatValue(); |
| 338 | |
} |
| 339 | 0 | catch ( NumberFormatException nfe ) |
| 340 | |
{ |
| 341 | 0 | if ( strict ) |
| 342 | |
{ |
| 343 | 0 | throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe ); |
| 344 | |
} |
| 345 | |
} |
| 346 | |
} |
| 347 | 0 | return 0; |
| 348 | |
} |
| 349 | |
|
| 350 | |
|
| 351 | |
|
| 352 | |
|
| 353 | |
|
| 354 | |
|
| 355 | |
|
| 356 | |
|
| 357 | |
|
| 358 | |
|
| 359 | |
|
| 360 | |
private int getIntegerValue( String s, String attribute, XmlPullParser parser, boolean strict ) |
| 361 | |
throws XmlPullParserException |
| 362 | |
{ |
| 363 | 0 | if ( s != null ) |
| 364 | |
{ |
| 365 | |
try |
| 366 | |
{ |
| 367 | 0 | return Integer.valueOf( s ).intValue(); |
| 368 | |
} |
| 369 | 0 | catch ( NumberFormatException nfe ) |
| 370 | |
{ |
| 371 | 0 | if ( strict ) |
| 372 | |
{ |
| 373 | 0 | throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be an integer", parser, nfe ); |
| 374 | |
} |
| 375 | |
} |
| 376 | |
} |
| 377 | 0 | return 0; |
| 378 | |
} |
| 379 | |
|
| 380 | |
|
| 381 | |
|
| 382 | |
|
| 383 | |
|
| 384 | |
|
| 385 | |
|
| 386 | |
|
| 387 | |
|
| 388 | |
|
| 389 | |
|
| 390 | |
private long getLongValue( String s, String attribute, XmlPullParser parser, boolean strict ) |
| 391 | |
throws XmlPullParserException |
| 392 | |
{ |
| 393 | 0 | if ( s != null ) |
| 394 | |
{ |
| 395 | |
try |
| 396 | |
{ |
| 397 | 0 | return Long.valueOf( s ).longValue(); |
| 398 | |
} |
| 399 | 0 | catch ( NumberFormatException nfe ) |
| 400 | |
{ |
| 401 | 0 | if ( strict ) |
| 402 | |
{ |
| 403 | 0 | throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a long integer", parser, nfe ); |
| 404 | |
} |
| 405 | |
} |
| 406 | |
} |
| 407 | 0 | return 0; |
| 408 | |
} |
| 409 | |
|
| 410 | |
|
| 411 | |
|
| 412 | |
|
| 413 | |
|
| 414 | |
|
| 415 | |
|
| 416 | |
|
| 417 | |
|
| 418 | |
|
| 419 | |
|
| 420 | |
private String getRequiredAttributeValue( String s, String attribute, XmlPullParser parser, boolean strict ) |
| 421 | |
throws XmlPullParserException |
| 422 | |
{ |
| 423 | 0 | if ( s == null ) |
| 424 | |
{ |
| 425 | 0 | if ( strict ) |
| 426 | |
{ |
| 427 | 0 | throw new XmlPullParserException( "Missing required value for attribute '" + attribute + "'", parser, null ); |
| 428 | |
} |
| 429 | |
} |
| 430 | 0 | return s; |
| 431 | |
} |
| 432 | |
|
| 433 | |
|
| 434 | |
|
| 435 | |
|
| 436 | |
|
| 437 | |
|
| 438 | |
|
| 439 | |
|
| 440 | |
|
| 441 | |
|
| 442 | |
|
| 443 | |
private short getShortValue( String s, String attribute, XmlPullParser parser, boolean strict ) |
| 444 | |
throws XmlPullParserException |
| 445 | |
{ |
| 446 | 0 | if ( s != null ) |
| 447 | |
{ |
| 448 | |
try |
| 449 | |
{ |
| 450 | 0 | return Short.valueOf( s ).shortValue(); |
| 451 | |
} |
| 452 | 0 | catch ( NumberFormatException nfe ) |
| 453 | |
{ |
| 454 | 0 | if ( strict ) |
| 455 | |
{ |
| 456 | 0 | throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a short integer", parser, nfe ); |
| 457 | |
} |
| 458 | |
} |
| 459 | |
} |
| 460 | 0 | return 0; |
| 461 | |
} |
| 462 | |
|
| 463 | |
|
| 464 | |
|
| 465 | |
|
| 466 | |
|
| 467 | |
|
| 468 | |
|
| 469 | |
private String getTrimmedValue( String s ) |
| 470 | |
{ |
| 471 | 0 | if ( s != null ) |
| 472 | |
{ |
| 473 | 0 | s = s.trim(); |
| 474 | |
} |
| 475 | 0 | return s; |
| 476 | |
} |
| 477 | |
|
| 478 | |
|
| 479 | |
|
| 480 | |
|
| 481 | |
|
| 482 | |
|
| 483 | |
|
| 484 | |
private void initParser( XmlPullParser parser ) |
| 485 | |
throws XmlPullParserException |
| 486 | |
{ |
| 487 | 0 | if ( addDefaultEntities ) |
| 488 | |
{ |
| 489 | |
|
| 490 | |
|
| 491 | |
|
| 492 | |
|
| 493 | 0 | parser.defineEntityReplacementText( "nbsp", "\u00a0" ); |
| 494 | 0 | parser.defineEntityReplacementText( "iexcl", "\u00a1" ); |
| 495 | 0 | parser.defineEntityReplacementText( "cent", "\u00a2" ); |
| 496 | 0 | parser.defineEntityReplacementText( "pound", "\u00a3" ); |
| 497 | 0 | parser.defineEntityReplacementText( "curren", "\u00a4" ); |
| 498 | 0 | parser.defineEntityReplacementText( "yen", "\u00a5" ); |
| 499 | 0 | parser.defineEntityReplacementText( "brvbar", "\u00a6" ); |
| 500 | 0 | parser.defineEntityReplacementText( "sect", "\u00a7" ); |
| 501 | 0 | parser.defineEntityReplacementText( "uml", "\u00a8" ); |
| 502 | 0 | parser.defineEntityReplacementText( "copy", "\u00a9" ); |
| 503 | 0 | parser.defineEntityReplacementText( "ordf", "\u00aa" ); |
| 504 | 0 | parser.defineEntityReplacementText( "laquo", "\u00ab" ); |
| 505 | 0 | parser.defineEntityReplacementText( "not", "\u00ac" ); |
| 506 | 0 | parser.defineEntityReplacementText( "shy", "\u00ad" ); |
| 507 | 0 | parser.defineEntityReplacementText( "reg", "\u00ae" ); |
| 508 | 0 | parser.defineEntityReplacementText( "macr", "\u00af" ); |
| 509 | 0 | parser.defineEntityReplacementText( "deg", "\u00b0" ); |
| 510 | 0 | parser.defineEntityReplacementText( "plusmn", "\u00b1" ); |
| 511 | 0 | parser.defineEntityReplacementText( "sup2", "\u00b2" ); |
| 512 | 0 | parser.defineEntityReplacementText( "sup3", "\u00b3" ); |
| 513 | 0 | parser.defineEntityReplacementText( "acute", "\u00b4" ); |
| 514 | 0 | parser.defineEntityReplacementText( "micro", "\u00b5" ); |
| 515 | 0 | parser.defineEntityReplacementText( "para", "\u00b6" ); |
| 516 | 0 | parser.defineEntityReplacementText( "middot", "\u00b7" ); |
| 517 | 0 | parser.defineEntityReplacementText( "cedil", "\u00b8" ); |
| 518 | 0 | parser.defineEntityReplacementText( "sup1", "\u00b9" ); |
| 519 | 0 | parser.defineEntityReplacementText( "ordm", "\u00ba" ); |
| 520 | 0 | parser.defineEntityReplacementText( "raquo", "\u00bb" ); |
| 521 | 0 | parser.defineEntityReplacementText( "frac14", "\u00bc" ); |
| 522 | 0 | parser.defineEntityReplacementText( "frac12", "\u00bd" ); |
| 523 | 0 | parser.defineEntityReplacementText( "frac34", "\u00be" ); |
| 524 | 0 | parser.defineEntityReplacementText( "iquest", "\u00bf" ); |
| 525 | 0 | parser.defineEntityReplacementText( "Agrave", "\u00c0" ); |
| 526 | 0 | parser.defineEntityReplacementText( "Aacute", "\u00c1" ); |
| 527 | 0 | parser.defineEntityReplacementText( "Acirc", "\u00c2" ); |
| 528 | 0 | parser.defineEntityReplacementText( "Atilde", "\u00c3" ); |
| 529 | 0 | parser.defineEntityReplacementText( "Auml", "\u00c4" ); |
| 530 | 0 | parser.defineEntityReplacementText( "Aring", "\u00c5" ); |
| 531 | 0 | parser.defineEntityReplacementText( "AElig", "\u00c6" ); |
| 532 | 0 | parser.defineEntityReplacementText( "Ccedil", "\u00c7" ); |
| 533 | 0 | parser.defineEntityReplacementText( "Egrave", "\u00c8" ); |
| 534 | 0 | parser.defineEntityReplacementText( "Eacute", "\u00c9" ); |
| 535 | 0 | parser.defineEntityReplacementText( "Ecirc", "\u00ca" ); |
| 536 | 0 | parser.defineEntityReplacementText( "Euml", "\u00cb" ); |
| 537 | 0 | parser.defineEntityReplacementText( "Igrave", "\u00cc" ); |
| 538 | 0 | parser.defineEntityReplacementText( "Iacute", "\u00cd" ); |
| 539 | 0 | parser.defineEntityReplacementText( "Icirc", "\u00ce" ); |
| 540 | 0 | parser.defineEntityReplacementText( "Iuml", "\u00cf" ); |
| 541 | 0 | parser.defineEntityReplacementText( "ETH", "\u00d0" ); |
| 542 | 0 | parser.defineEntityReplacementText( "Ntilde", "\u00d1" ); |
| 543 | 0 | parser.defineEntityReplacementText( "Ograve", "\u00d2" ); |
| 544 | 0 | parser.defineEntityReplacementText( "Oacute", "\u00d3" ); |
| 545 | 0 | parser.defineEntityReplacementText( "Ocirc", "\u00d4" ); |
| 546 | 0 | parser.defineEntityReplacementText( "Otilde", "\u00d5" ); |
| 547 | 0 | parser.defineEntityReplacementText( "Ouml", "\u00d6" ); |
| 548 | 0 | parser.defineEntityReplacementText( "times", "\u00d7" ); |
| 549 | 0 | parser.defineEntityReplacementText( "Oslash", "\u00d8" ); |
| 550 | 0 | parser.defineEntityReplacementText( "Ugrave", "\u00d9" ); |
| 551 | 0 | parser.defineEntityReplacementText( "Uacute", "\u00da" ); |
| 552 | 0 | parser.defineEntityReplacementText( "Ucirc", "\u00db" ); |
| 553 | 0 | parser.defineEntityReplacementText( "Uuml", "\u00dc" ); |
| 554 | 0 | parser.defineEntityReplacementText( "Yacute", "\u00dd" ); |
| 555 | 0 | parser.defineEntityReplacementText( "THORN", "\u00de" ); |
| 556 | 0 | parser.defineEntityReplacementText( "szlig", "\u00df" ); |
| 557 | 0 | parser.defineEntityReplacementText( "agrave", "\u00e0" ); |
| 558 | 0 | parser.defineEntityReplacementText( "aacute", "\u00e1" ); |
| 559 | 0 | parser.defineEntityReplacementText( "acirc", "\u00e2" ); |
| 560 | 0 | parser.defineEntityReplacementText( "atilde", "\u00e3" ); |
| 561 | 0 | parser.defineEntityReplacementText( "auml", "\u00e4" ); |
| 562 | 0 | parser.defineEntityReplacementText( "aring", "\u00e5" ); |
| 563 | 0 | parser.defineEntityReplacementText( "aelig", "\u00e6" ); |
| 564 | 0 | parser.defineEntityReplacementText( "ccedil", "\u00e7" ); |
| 565 | 0 | parser.defineEntityReplacementText( "egrave", "\u00e8" ); |
| 566 | 0 | parser.defineEntityReplacementText( "eacute", "\u00e9" ); |
| 567 | 0 | parser.defineEntityReplacementText( "ecirc", "\u00ea" ); |
| 568 | 0 | parser.defineEntityReplacementText( "euml", "\u00eb" ); |
| 569 | 0 | parser.defineEntityReplacementText( "igrave", "\u00ec" ); |
| 570 | 0 | parser.defineEntityReplacementText( "iacute", "\u00ed" ); |
| 571 | 0 | parser.defineEntityReplacementText( "icirc", "\u00ee" ); |
| 572 | 0 | parser.defineEntityReplacementText( "iuml", "\u00ef" ); |
| 573 | 0 | parser.defineEntityReplacementText( "eth", "\u00f0" ); |
| 574 | 0 | parser.defineEntityReplacementText( "ntilde", "\u00f1" ); |
| 575 | 0 | parser.defineEntityReplacementText( "ograve", "\u00f2" ); |
| 576 | 0 | parser.defineEntityReplacementText( "oacute", "\u00f3" ); |
| 577 | 0 | parser.defineEntityReplacementText( "ocirc", "\u00f4" ); |
| 578 | 0 | parser.defineEntityReplacementText( "otilde", "\u00f5" ); |
| 579 | 0 | parser.defineEntityReplacementText( "ouml", "\u00f6" ); |
| 580 | 0 | parser.defineEntityReplacementText( "divide", "\u00f7" ); |
| 581 | 0 | parser.defineEntityReplacementText( "oslash", "\u00f8" ); |
| 582 | 0 | parser.defineEntityReplacementText( "ugrave", "\u00f9" ); |
| 583 | 0 | parser.defineEntityReplacementText( "uacute", "\u00fa" ); |
| 584 | 0 | parser.defineEntityReplacementText( "ucirc", "\u00fb" ); |
| 585 | 0 | parser.defineEntityReplacementText( "uuml", "\u00fc" ); |
| 586 | 0 | parser.defineEntityReplacementText( "yacute", "\u00fd" ); |
| 587 | 0 | parser.defineEntityReplacementText( "thorn", "\u00fe" ); |
| 588 | 0 | parser.defineEntityReplacementText( "yuml", "\u00ff" ); |
| 589 | |
|
| 590 | |
|
| 591 | |
|
| 592 | |
|
| 593 | |
|
| 594 | 0 | parser.defineEntityReplacementText( "OElig", "\u0152" ); |
| 595 | 0 | parser.defineEntityReplacementText( "oelig", "\u0153" ); |
| 596 | 0 | parser.defineEntityReplacementText( "Scaron", "\u0160" ); |
| 597 | 0 | parser.defineEntityReplacementText( "scaron", "\u0161" ); |
| 598 | 0 | parser.defineEntityReplacementText( "Yuml", "\u0178" ); |
| 599 | 0 | parser.defineEntityReplacementText( "circ", "\u02c6" ); |
| 600 | 0 | parser.defineEntityReplacementText( "tilde", "\u02dc" ); |
| 601 | 0 | parser.defineEntityReplacementText( "ensp", "\u2002" ); |
| 602 | 0 | parser.defineEntityReplacementText( "emsp", "\u2003" ); |
| 603 | 0 | parser.defineEntityReplacementText( "thinsp", "\u2009" ); |
| 604 | 0 | parser.defineEntityReplacementText( "zwnj", "\u200c" ); |
| 605 | 0 | parser.defineEntityReplacementText( "zwj", "\u200d" ); |
| 606 | 0 | parser.defineEntityReplacementText( "lrm", "\u200e" ); |
| 607 | 0 | parser.defineEntityReplacementText( "rlm", "\u200f" ); |
| 608 | 0 | parser.defineEntityReplacementText( "ndash", "\u2013" ); |
| 609 | 0 | parser.defineEntityReplacementText( "mdash", "\u2014" ); |
| 610 | 0 | parser.defineEntityReplacementText( "lsquo", "\u2018" ); |
| 611 | 0 | parser.defineEntityReplacementText( "rsquo", "\u2019" ); |
| 612 | 0 | parser.defineEntityReplacementText( "sbquo", "\u201a" ); |
| 613 | 0 | parser.defineEntityReplacementText( "ldquo", "\u201c" ); |
| 614 | 0 | parser.defineEntityReplacementText( "rdquo", "\u201d" ); |
| 615 | 0 | parser.defineEntityReplacementText( "bdquo", "\u201e" ); |
| 616 | 0 | parser.defineEntityReplacementText( "dagger", "\u2020" ); |
| 617 | 0 | parser.defineEntityReplacementText( "Dagger", "\u2021" ); |
| 618 | 0 | parser.defineEntityReplacementText( "permil", "\u2030" ); |
| 619 | 0 | parser.defineEntityReplacementText( "lsaquo", "\u2039" ); |
| 620 | 0 | parser.defineEntityReplacementText( "rsaquo", "\u203a" ); |
| 621 | 0 | parser.defineEntityReplacementText( "euro", "\u20ac" ); |
| 622 | |
|
| 623 | |
|
| 624 | |
|
| 625 | |
|
| 626 | |
|
| 627 | 0 | parser.defineEntityReplacementText( "fnof", "\u0192" ); |
| 628 | 0 | parser.defineEntityReplacementText( "Alpha", "\u0391" ); |
| 629 | 0 | parser.defineEntityReplacementText( "Beta", "\u0392" ); |
| 630 | 0 | parser.defineEntityReplacementText( "Gamma", "\u0393" ); |
| 631 | 0 | parser.defineEntityReplacementText( "Delta", "\u0394" ); |
| 632 | 0 | parser.defineEntityReplacementText( "Epsilon", "\u0395" ); |
| 633 | 0 | parser.defineEntityReplacementText( "Zeta", "\u0396" ); |
| 634 | 0 | parser.defineEntityReplacementText( "Eta", "\u0397" ); |
| 635 | 0 | parser.defineEntityReplacementText( "Theta", "\u0398" ); |
| 636 | 0 | parser.defineEntityReplacementText( "Iota", "\u0399" ); |
| 637 | 0 | parser.defineEntityReplacementText( "Kappa", "\u039a" ); |
| 638 | 0 | parser.defineEntityReplacementText( "Lambda", "\u039b" ); |
| 639 | 0 | parser.defineEntityReplacementText( "Mu", "\u039c" ); |
| 640 | 0 | parser.defineEntityReplacementText( "Nu", "\u039d" ); |
| 641 | 0 | parser.defineEntityReplacementText( "Xi", "\u039e" ); |
| 642 | 0 | parser.defineEntityReplacementText( "Omicron", "\u039f" ); |
| 643 | 0 | parser.defineEntityReplacementText( "Pi", "\u03a0" ); |
| 644 | 0 | parser.defineEntityReplacementText( "Rho", "\u03a1" ); |
| 645 | 0 | parser.defineEntityReplacementText( "Sigma", "\u03a3" ); |
| 646 | 0 | parser.defineEntityReplacementText( "Tau", "\u03a4" ); |
| 647 | 0 | parser.defineEntityReplacementText( "Upsilon", "\u03a5" ); |
| 648 | 0 | parser.defineEntityReplacementText( "Phi", "\u03a6" ); |
| 649 | 0 | parser.defineEntityReplacementText( "Chi", "\u03a7" ); |
| 650 | 0 | parser.defineEntityReplacementText( "Psi", "\u03a8" ); |
| 651 | 0 | parser.defineEntityReplacementText( "Omega", "\u03a9" ); |
| 652 | 0 | parser.defineEntityReplacementText( "alpha", "\u03b1" ); |
| 653 | 0 | parser.defineEntityReplacementText( "beta", "\u03b2" ); |
| 654 | 0 | parser.defineEntityReplacementText( "gamma", "\u03b3" ); |
| 655 | 0 | parser.defineEntityReplacementText( "delta", "\u03b4" ); |
| 656 | 0 | parser.defineEntityReplacementText( "epsilon", "\u03b5" ); |
| 657 | 0 | parser.defineEntityReplacementText( "zeta", "\u03b6" ); |
| 658 | 0 | parser.defineEntityReplacementText( "eta", "\u03b7" ); |
| 659 | 0 | parser.defineEntityReplacementText( "theta", "\u03b8" ); |
| 660 | 0 | parser.defineEntityReplacementText( "iota", "\u03b9" ); |
| 661 | 0 | parser.defineEntityReplacementText( "kappa", "\u03ba" ); |
| 662 | 0 | parser.defineEntityReplacementText( "lambda", "\u03bb" ); |
| 663 | 0 | parser.defineEntityReplacementText( "mu", "\u03bc" ); |
| 664 | 0 | parser.defineEntityReplacementText( "nu", "\u03bd" ); |
| 665 | 0 | parser.defineEntityReplacementText( "xi", "\u03be" ); |
| 666 | 0 | parser.defineEntityReplacementText( "omicron", "\u03bf" ); |
| 667 | 0 | parser.defineEntityReplacementText( "pi", "\u03c0" ); |
| 668 | 0 | parser.defineEntityReplacementText( "rho", "\u03c1" ); |
| 669 | 0 | parser.defineEntityReplacementText( "sigmaf", "\u03c2" ); |
| 670 | 0 | parser.defineEntityReplacementText( "sigma", "\u03c3" ); |
| 671 | 0 | parser.defineEntityReplacementText( "tau", "\u03c4" ); |
| 672 | 0 | parser.defineEntityReplacementText( "upsilon", "\u03c5" ); |
| 673 | 0 | parser.defineEntityReplacementText( "phi", "\u03c6" ); |
| 674 | 0 | parser.defineEntityReplacementText( "chi", "\u03c7" ); |
| 675 | 0 | parser.defineEntityReplacementText( "psi", "\u03c8" ); |
| 676 | 0 | parser.defineEntityReplacementText( "omega", "\u03c9" ); |
| 677 | 0 | parser.defineEntityReplacementText( "thetasym", "\u03d1" ); |
| 678 | 0 | parser.defineEntityReplacementText( "upsih", "\u03d2" ); |
| 679 | 0 | parser.defineEntityReplacementText( "piv", "\u03d6" ); |
| 680 | 0 | parser.defineEntityReplacementText( "bull", "\u2022" ); |
| 681 | 0 | parser.defineEntityReplacementText( "hellip", "\u2026" ); |
| 682 | 0 | parser.defineEntityReplacementText( "prime", "\u2032" ); |
| 683 | 0 | parser.defineEntityReplacementText( "Prime", "\u2033" ); |
| 684 | 0 | parser.defineEntityReplacementText( "oline", "\u203e" ); |
| 685 | 0 | parser.defineEntityReplacementText( "frasl", "\u2044" ); |
| 686 | 0 | parser.defineEntityReplacementText( "weierp", "\u2118" ); |
| 687 | 0 | parser.defineEntityReplacementText( "image", "\u2111" ); |
| 688 | 0 | parser.defineEntityReplacementText( "real", "\u211c" ); |
| 689 | 0 | parser.defineEntityReplacementText( "trade", "\u2122" ); |
| 690 | 0 | parser.defineEntityReplacementText( "alefsym", "\u2135" ); |
| 691 | 0 | parser.defineEntityReplacementText( "larr", "\u2190" ); |
| 692 | 0 | parser.defineEntityReplacementText( "uarr", "\u2191" ); |
| 693 | 0 | parser.defineEntityReplacementText( "rarr", "\u2192" ); |
| 694 | 0 | parser.defineEntityReplacementText( "darr", "\u2193" ); |
| 695 | 0 | parser.defineEntityReplacementText( "harr", "\u2194" ); |
| 696 | 0 | parser.defineEntityReplacementText( "crarr", "\u21b5" ); |
| 697 | 0 | parser.defineEntityReplacementText( "lArr", "\u21d0" ); |
| 698 | 0 | parser.defineEntityReplacementText( "uArr", "\u21d1" ); |
| 699 | 0 | parser.defineEntityReplacementText( "rArr", "\u21d2" ); |
| 700 | 0 | parser.defineEntityReplacementText( "dArr", "\u21d3" ); |
| 701 | 0 | parser.defineEntityReplacementText( "hArr", "\u21d4" ); |
| 702 | 0 | parser.defineEntityReplacementText( "forall", "\u2200" ); |
| 703 | 0 | parser.defineEntityReplacementText( "part", "\u2202" ); |
| 704 | 0 | parser.defineEntityReplacementText( "exist", "\u2203" ); |
| 705 | 0 | parser.defineEntityReplacementText( "empty", "\u2205" ); |
| 706 | 0 | parser.defineEntityReplacementText( "nabla", "\u2207" ); |
| 707 | 0 | parser.defineEntityReplacementText( "isin", "\u2208" ); |
| 708 | 0 | parser.defineEntityReplacementText( "notin", "\u2209" ); |
| 709 | 0 | parser.defineEntityReplacementText( "ni", "\u220b" ); |
| 710 | 0 | parser.defineEntityReplacementText( "prod", "\u220f" ); |
| 711 | 0 | parser.defineEntityReplacementText( "sum", "\u2211" ); |
| 712 | 0 | parser.defineEntityReplacementText( "minus", "\u2212" ); |
| 713 | 0 | parser.defineEntityReplacementText( "lowast", "\u2217" ); |
| 714 | 0 | parser.defineEntityReplacementText( "radic", "\u221a" ); |
| 715 | 0 | parser.defineEntityReplacementText( "prop", "\u221d" ); |
| 716 | 0 | parser.defineEntityReplacementText( "infin", "\u221e" ); |
| 717 | 0 | parser.defineEntityReplacementText( "ang", "\u2220" ); |
| 718 | 0 | parser.defineEntityReplacementText( "and", "\u2227" ); |
| 719 | 0 | parser.defineEntityReplacementText( "or", "\u2228" ); |
| 720 | 0 | parser.defineEntityReplacementText( "cap", "\u2229" ); |
| 721 | 0 | parser.defineEntityReplacementText( "cup", "\u222a" ); |
| 722 | 0 | parser.defineEntityReplacementText( "int", "\u222b" ); |
| 723 | 0 | parser.defineEntityReplacementText( "there4", "\u2234" ); |
| 724 | 0 | parser.defineEntityReplacementText( "sim", "\u223c" ); |
| 725 | 0 | parser.defineEntityReplacementText( "cong", "\u2245" ); |
| 726 | 0 | parser.defineEntityReplacementText( "asymp", "\u2248" ); |
| 727 | 0 | parser.defineEntityReplacementText( "ne", "\u2260" ); |
| 728 | 0 | parser.defineEntityReplacementText( "equiv", "\u2261" ); |
| 729 | 0 | parser.defineEntityReplacementText( "le", "\u2264" ); |
| 730 | 0 | parser.defineEntityReplacementText( "ge", "\u2265" ); |
| 731 | 0 | parser.defineEntityReplacementText( "sub", "\u2282" ); |
| 732 | 0 | parser.defineEntityReplacementText( "sup", "\u2283" ); |
| 733 | 0 | parser.defineEntityReplacementText( "nsub", "\u2284" ); |
| 734 | 0 | parser.defineEntityReplacementText( "sube", "\u2286" ); |
| 735 | 0 | parser.defineEntityReplacementText( "supe", "\u2287" ); |
| 736 | 0 | parser.defineEntityReplacementText( "oplus", "\u2295" ); |
| 737 | 0 | parser.defineEntityReplacementText( "otimes", "\u2297" ); |
| 738 | 0 | parser.defineEntityReplacementText( "perp", "\u22a5" ); |
| 739 | 0 | parser.defineEntityReplacementText( "sdot", "\u22c5" ); |
| 740 | 0 | parser.defineEntityReplacementText( "lceil", "\u2308" ); |
| 741 | 0 | parser.defineEntityReplacementText( "rceil", "\u2309" ); |
| 742 | 0 | parser.defineEntityReplacementText( "lfloor", "\u230a" ); |
| 743 | 0 | parser.defineEntityReplacementText( "rfloor", "\u230b" ); |
| 744 | 0 | parser.defineEntityReplacementText( "lang", "\u2329" ); |
| 745 | 0 | parser.defineEntityReplacementText( "rang", "\u232a" ); |
| 746 | 0 | parser.defineEntityReplacementText( "loz", "\u25ca" ); |
| 747 | 0 | parser.defineEntityReplacementText( "spades", "\u2660" ); |
| 748 | 0 | parser.defineEntityReplacementText( "clubs", "\u2663" ); |
| 749 | 0 | parser.defineEntityReplacementText( "hearts", "\u2665" ); |
| 750 | 0 | parser.defineEntityReplacementText( "diams", "\u2666" ); |
| 751 | |
|
| 752 | |
} |
| 753 | 0 | } |
| 754 | |
|
| 755 | |
|
| 756 | |
|
| 757 | |
|
| 758 | |
|
| 759 | |
|
| 760 | |
|
| 761 | |
|
| 762 | |
|
| 763 | |
private int nextTag( XmlPullParser parser ) |
| 764 | |
throws IOException, XmlPullParserException |
| 765 | |
{ |
| 766 | 0 | int eventType = parser.next(); |
| 767 | 0 | if ( eventType == XmlPullParser.TEXT ) |
| 768 | |
{ |
| 769 | 0 | eventType = parser.next(); |
| 770 | |
} |
| 771 | 0 | if ( eventType != XmlPullParser.START_TAG && eventType != XmlPullParser.END_TAG ) |
| 772 | |
{ |
| 773 | 0 | throw new XmlPullParserException( "expected START_TAG or END_TAG not " + XmlPullParser.TYPES[eventType], parser, null ); |
| 774 | |
} |
| 775 | 0 | return eventType; |
| 776 | |
} |
| 777 | |
|
| 778 | |
|
| 779 | |
|
| 780 | |
|
| 781 | |
|
| 782 | |
|
| 783 | |
|
| 784 | |
|
| 785 | |
|
| 786 | |
|
| 787 | |
private Dependency parseDependency( XmlPullParser parser, boolean strict ) |
| 788 | |
throws IOException, XmlPullParserException |
| 789 | |
{ |
| 790 | 0 | String tagName = parser.getName(); |
| 791 | 0 | Dependency dependency = new Dependency(); |
| 792 | 0 | for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) |
| 793 | |
{ |
| 794 | 0 | String name = parser.getAttributeName( i ); |
| 795 | 0 | String value = parser.getAttributeValue( i ); |
| 796 | |
|
| 797 | 0 | if ( name.indexOf( ':' ) >= 0 ) |
| 798 | |
{ |
| 799 | |
|
| 800 | |
} |
| 801 | |
else |
| 802 | |
{ |
| 803 | 0 | checkUnknownAttribute( parser, name, tagName, strict ); |
| 804 | |
} |
| 805 | |
} |
| 806 | 0 | java.util.Set parsed = new java.util.HashSet(); |
| 807 | 0 | while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) |
| 808 | |
{ |
| 809 | 0 | if ( checkFieldWithDuplicate( parser, "id", null, parsed ) ) |
| 810 | |
{ |
| 811 | 0 | dependency.setId( getTrimmedValue( parser.nextText() ) ); |
| 812 | |
} |
| 813 | 0 | else if ( checkFieldWithDuplicate( parser, "type", null, parsed ) ) |
| 814 | |
{ |
| 815 | 0 | dependency.setType( getTrimmedValue( parser.nextText() ) ); |
| 816 | |
} |
| 817 | 0 | else if ( checkFieldWithDuplicate( parser, "explicitValue", null, parsed ) ) |
| 818 | |
{ |
| 819 | 0 | dependency.setExplicitValue( getTrimmedValue( parser.nextText() ) ); |
| 820 | |
} |
| 821 | |
else |
| 822 | |
{ |
| 823 | 0 | checkUnknownElement( parser, strict ); |
| 824 | |
} |
| 825 | |
} |
| 826 | 0 | return dependency; |
| 827 | |
} |
| 828 | |
|
| 829 | |
|
| 830 | |
|
| 831 | |
|
| 832 | |
|
| 833 | |
|
| 834 | |
|
| 835 | |
|
| 836 | |
|
| 837 | |
|
| 838 | |
private NbmResource parseNbmResource( XmlPullParser parser, boolean strict ) |
| 839 | |
throws IOException, XmlPullParserException |
| 840 | |
{ |
| 841 | 0 | String tagName = parser.getName(); |
| 842 | 0 | NbmResource nbmResource = new NbmResource(); |
| 843 | 0 | for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) |
| 844 | |
{ |
| 845 | 0 | String name = parser.getAttributeName( i ); |
| 846 | 0 | String value = parser.getAttributeValue( i ); |
| 847 | |
|
| 848 | 0 | if ( name.indexOf( ':' ) >= 0 ) |
| 849 | |
{ |
| 850 | |
|
| 851 | |
} |
| 852 | |
else |
| 853 | |
{ |
| 854 | 0 | checkUnknownAttribute( parser, name, tagName, strict ); |
| 855 | |
} |
| 856 | |
} |
| 857 | 0 | java.util.Set parsed = new java.util.HashSet(); |
| 858 | 0 | while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) |
| 859 | |
{ |
| 860 | 0 | if ( checkFieldWithDuplicate( parser, "baseDirectory", null, parsed ) ) |
| 861 | |
{ |
| 862 | 0 | nbmResource.setBaseDirectory( getTrimmedValue( parser.nextText() ) ); |
| 863 | |
} |
| 864 | 0 | else if ( checkFieldWithDuplicate( parser, "relativeClusterPath", null, parsed ) ) |
| 865 | |
{ |
| 866 | 0 | nbmResource.setRelativeClusterPath( getTrimmedValue( parser.nextText() ) ); |
| 867 | |
} |
| 868 | 0 | else if ( checkFieldWithDuplicate( parser, "includes", null, parsed ) ) |
| 869 | |
{ |
| 870 | 0 | java.util.List includes = new java.util.ArrayList(); |
| 871 | 0 | nbmResource.setIncludes( includes ); |
| 872 | 0 | while ( parser.nextTag() == XmlPullParser.START_TAG ) |
| 873 | |
{ |
| 874 | 0 | if ( "include".equals( parser.getName() ) ) |
| 875 | |
{ |
| 876 | 0 | includes.add( getTrimmedValue( parser.nextText() ) ); |
| 877 | |
} |
| 878 | |
else |
| 879 | |
{ |
| 880 | 0 | checkUnknownElement( parser, strict ); |
| 881 | |
} |
| 882 | |
} |
| 883 | 0 | } |
| 884 | 0 | else if ( checkFieldWithDuplicate( parser, "excludes", null, parsed ) ) |
| 885 | |
{ |
| 886 | 0 | java.util.List excludes = new java.util.ArrayList(); |
| 887 | 0 | nbmResource.setExcludes( excludes ); |
| 888 | 0 | while ( parser.nextTag() == XmlPullParser.START_TAG ) |
| 889 | |
{ |
| 890 | 0 | if ( "exclude".equals( parser.getName() ) ) |
| 891 | |
{ |
| 892 | 0 | excludes.add( getTrimmedValue( parser.nextText() ) ); |
| 893 | |
} |
| 894 | |
else |
| 895 | |
{ |
| 896 | 0 | checkUnknownElement( parser, strict ); |
| 897 | |
} |
| 898 | |
} |
| 899 | 0 | } |
| 900 | |
else |
| 901 | |
{ |
| 902 | 0 | checkUnknownElement( parser, strict ); |
| 903 | |
} |
| 904 | |
} |
| 905 | 0 | return nbmResource; |
| 906 | |
} |
| 907 | |
|
| 908 | |
|
| 909 | |
|
| 910 | |
|
| 911 | |
|
| 912 | |
|
| 913 | |
|
| 914 | |
|
| 915 | |
|
| 916 | |
|
| 917 | |
private NetBeansModule parseNetBeansModule( XmlPullParser parser, boolean strict ) |
| 918 | |
throws IOException, XmlPullParserException |
| 919 | |
{ |
| 920 | 0 | String tagName = parser.getName(); |
| 921 | 0 | NetBeansModule netBeansModule = new NetBeansModule(); |
| 922 | 0 | for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) |
| 923 | |
{ |
| 924 | 0 | String name = parser.getAttributeName( i ); |
| 925 | 0 | String value = parser.getAttributeValue( i ); |
| 926 | |
|
| 927 | 0 | if ( name.indexOf( ':' ) >= 0 ) |
| 928 | |
{ |
| 929 | |
|
| 930 | |
} |
| 931 | 0 | else if ( "xmlns".equals( name ) ) |
| 932 | |
{ |
| 933 | |
|
| 934 | |
} |
| 935 | |
else |
| 936 | |
{ |
| 937 | 0 | checkUnknownAttribute( parser, name, tagName, strict ); |
| 938 | |
} |
| 939 | |
} |
| 940 | 0 | java.util.Set parsed = new java.util.HashSet(); |
| 941 | 0 | while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) |
| 942 | |
{ |
| 943 | 0 | if ( checkFieldWithDuplicate( parser, "moduleType", null, parsed ) ) |
| 944 | |
{ |
| 945 | 0 | netBeansModule.setModuleType( getTrimmedValue( parser.nextText() ) ); |
| 946 | |
} |
| 947 | 0 | else if ( checkFieldWithDuplicate( parser, "codeNameBase", null, parsed ) ) |
| 948 | |
{ |
| 949 | 0 | netBeansModule.setCodeNameBase( getTrimmedValue( parser.nextText() ) ); |
| 950 | |
} |
| 951 | 0 | else if ( checkFieldWithDuplicate( parser, "cluster", null, parsed ) ) |
| 952 | |
{ |
| 953 | 0 | netBeansModule.setCluster( getTrimmedValue( parser.nextText() ) ); |
| 954 | |
} |
| 955 | 0 | else if ( checkFieldWithDuplicate( parser, "requiresRestart", null, parsed ) ) |
| 956 | |
{ |
| 957 | 0 | netBeansModule.setRequiresRestart( getBooleanValue( getTrimmedValue( parser.nextText() ), "requiresRestart", parser, "false" ) ); |
| 958 | |
} |
| 959 | 0 | else if ( checkFieldWithDuplicate( parser, "manifest", null, parsed ) ) |
| 960 | |
{ |
| 961 | 0 | netBeansModule.setManifest( getTrimmedValue( parser.nextText() ) ); |
| 962 | |
} |
| 963 | 0 | else if ( checkFieldWithDuplicate( parser, "homepageUrl", null, parsed ) ) |
| 964 | |
{ |
| 965 | 0 | netBeansModule.setHomepageUrl( getTrimmedValue( parser.nextText() ) ); |
| 966 | |
} |
| 967 | 0 | else if ( checkFieldWithDuplicate( parser, "distributionUrl", null, parsed ) ) |
| 968 | |
{ |
| 969 | 0 | netBeansModule.setDistributionUrl( getTrimmedValue( parser.nextText() ) ); |
| 970 | |
} |
| 971 | 0 | else if ( checkFieldWithDuplicate( parser, "author", null, parsed ) ) |
| 972 | |
{ |
| 973 | 0 | netBeansModule.setAuthor( getTrimmedValue( parser.nextText() ) ); |
| 974 | |
} |
| 975 | 0 | else if ( checkFieldWithDuplicate( parser, "licenseName", null, parsed ) ) |
| 976 | |
{ |
| 977 | 0 | netBeansModule.setLicenseName( getTrimmedValue( parser.nextText() ) ); |
| 978 | |
} |
| 979 | 0 | else if ( checkFieldWithDuplicate( parser, "licenseFile", null, parsed ) ) |
| 980 | |
{ |
| 981 | 0 | netBeansModule.setLicenseFile( getTrimmedValue( parser.nextText() ) ); |
| 982 | |
} |
| 983 | 0 | else if ( checkFieldWithDuplicate( parser, "libraries", null, parsed ) ) |
| 984 | |
{ |
| 985 | 0 | java.util.List libraries = new java.util.ArrayList(); |
| 986 | 0 | netBeansModule.setLibraries( libraries ); |
| 987 | 0 | while ( parser.nextTag() == XmlPullParser.START_TAG ) |
| 988 | |
{ |
| 989 | 0 | if ( "library".equals( parser.getName() ) ) |
| 990 | |
{ |
| 991 | 0 | libraries.add( getTrimmedValue( parser.nextText() ) ); |
| 992 | |
} |
| 993 | |
else |
| 994 | |
{ |
| 995 | 0 | checkUnknownElement( parser, strict ); |
| 996 | |
} |
| 997 | |
} |
| 998 | 0 | } |
| 999 | 0 | else if ( checkFieldWithDuplicate( parser, "dependencies", null, parsed ) ) |
| 1000 | |
{ |
| 1001 | 0 | java.util.List dependencies = new java.util.ArrayList(); |
| 1002 | 0 | netBeansModule.setDependencies( dependencies ); |
| 1003 | 0 | while ( parser.nextTag() == XmlPullParser.START_TAG ) |
| 1004 | |
{ |
| 1005 | 0 | if ( "dependency".equals( parser.getName() ) ) |
| 1006 | |
{ |
| 1007 | 0 | dependencies.add( parseDependency( parser, strict ) ); |
| 1008 | |
} |
| 1009 | |
else |
| 1010 | |
{ |
| 1011 | 0 | checkUnknownElement( parser, strict ); |
| 1012 | |
} |
| 1013 | |
} |
| 1014 | 0 | } |
| 1015 | 0 | else if ( checkFieldWithDuplicate( parser, "nbmResources", null, parsed ) ) |
| 1016 | |
{ |
| 1017 | 0 | java.util.List nbmResources = new java.util.ArrayList(); |
| 1018 | 0 | netBeansModule.setNbmResources( nbmResources ); |
| 1019 | 0 | while ( parser.nextTag() == XmlPullParser.START_TAG ) |
| 1020 | |
{ |
| 1021 | 0 | if ( "nbmResource".equals( parser.getName() ) ) |
| 1022 | |
{ |
| 1023 | 0 | nbmResources.add( parseNbmResource( parser, strict ) ); |
| 1024 | |
} |
| 1025 | |
else |
| 1026 | |
{ |
| 1027 | 0 | checkUnknownElement( parser, strict ); |
| 1028 | |
} |
| 1029 | |
} |
| 1030 | 0 | } |
| 1031 | |
else |
| 1032 | |
{ |
| 1033 | 0 | checkUnknownElement( parser, strict ); |
| 1034 | |
} |
| 1035 | |
} |
| 1036 | 0 | return netBeansModule; |
| 1037 | |
} |
| 1038 | |
|
| 1039 | |
|
| 1040 | |
|
| 1041 | |
|
| 1042 | |
|
| 1043 | |
|
| 1044 | |
|
| 1045 | |
|
| 1046 | |
|
| 1047 | |
|
| 1048 | |
public NetBeansModule read( Reader reader, boolean strict ) |
| 1049 | |
throws IOException, XmlPullParserException |
| 1050 | |
{ |
| 1051 | 0 | XmlPullParser parser = new MXParser(); |
| 1052 | |
|
| 1053 | 0 | parser.setInput( reader ); |
| 1054 | |
|
| 1055 | 0 | initParser( parser ); |
| 1056 | |
|
| 1057 | 0 | return read( parser, strict ); |
| 1058 | |
} |
| 1059 | |
|
| 1060 | |
|
| 1061 | |
|
| 1062 | |
|
| 1063 | |
|
| 1064 | |
|
| 1065 | |
|
| 1066 | |
|
| 1067 | |
|
| 1068 | |
public NetBeansModule read( Reader reader ) |
| 1069 | |
throws IOException, XmlPullParserException |
| 1070 | |
{ |
| 1071 | 0 | return read( reader, true ); |
| 1072 | |
} |
| 1073 | |
|
| 1074 | |
|
| 1075 | |
|
| 1076 | |
|
| 1077 | |
|
| 1078 | |
|
| 1079 | |
|
| 1080 | |
|
| 1081 | |
|
| 1082 | |
|
| 1083 | |
public NetBeansModule read( InputStream in, boolean strict ) |
| 1084 | |
throws IOException, XmlPullParserException |
| 1085 | |
{ |
| 1086 | 0 | return read( ReaderFactory.newXmlReader( in ), strict ); |
| 1087 | |
} |
| 1088 | |
|
| 1089 | |
|
| 1090 | |
|
| 1091 | |
|
| 1092 | |
|
| 1093 | |
|
| 1094 | |
|
| 1095 | |
|
| 1096 | |
|
| 1097 | |
public NetBeansModule read( InputStream in ) |
| 1098 | |
throws IOException, XmlPullParserException |
| 1099 | |
{ |
| 1100 | 0 | return read( ReaderFactory.newXmlReader( in ) ); |
| 1101 | |
} |
| 1102 | |
|
| 1103 | |
|
| 1104 | |
|
| 1105 | |
|
| 1106 | |
|
| 1107 | |
|
| 1108 | |
|
| 1109 | |
|
| 1110 | |
|
| 1111 | |
|
| 1112 | |
private NetBeansModule read( XmlPullParser parser, boolean strict ) |
| 1113 | |
throws IOException, XmlPullParserException |
| 1114 | |
{ |
| 1115 | 0 | int eventType = parser.getEventType(); |
| 1116 | 0 | while ( eventType != XmlPullParser.END_DOCUMENT ) |
| 1117 | |
{ |
| 1118 | 0 | if ( eventType == XmlPullParser.START_TAG ) |
| 1119 | |
{ |
| 1120 | 0 | if ( strict && ! "nbm".equals( parser.getName() ) ) |
| 1121 | |
{ |
| 1122 | 0 | throw new XmlPullParserException( "Expected root element 'nbm' but found '" + parser.getName() + "'", parser, null ); |
| 1123 | |
} |
| 1124 | 0 | NetBeansModule netBeansModule = parseNetBeansModule( parser, strict ); |
| 1125 | 0 | netBeansModule.setModelEncoding( parser.getInputEncoding() ); |
| 1126 | 0 | return netBeansModule; |
| 1127 | |
} |
| 1128 | 0 | eventType = parser.next(); |
| 1129 | |
} |
| 1130 | 0 | throw new XmlPullParserException( "Expected root element 'nbm' but found no element at all: invalid XML document", parser, null ); |
| 1131 | |
} |
| 1132 | |
|
| 1133 | |
|
| 1134 | |
|
| 1135 | |
|
| 1136 | |
|
| 1137 | |
|
| 1138 | |
public void setAddDefaultEntities( boolean addDefaultEntities ) |
| 1139 | |
{ |
| 1140 | 0 | this.addDefaultEntities = addDefaultEntities; |
| 1141 | 0 | } |
| 1142 | |
|
| 1143 | |
} |