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