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