View Javadoc

1   /*
2    =================== DO NOT EDIT THIS FILE ====================
3    Generated by Modello 1.1 on 2011-09-18 14:33:27,
4    any modifications will be overwritten.
5    ==============================================================
6    */
7   
8   package org.apache.maven.continuum.model.project.v1_0_9.io.stax;
9   
10    //---------------------------------/
11   //- Imported classes and packages -/
12  //---------------------------------/
13  
14  import java.io.ByteArrayInputStream;
15  import java.io.File;
16  import java.io.FileInputStream;
17  import java.io.IOException;
18  import java.io.InputStreamReader;
19  import java.io.Reader;
20  import java.io.StringReader;
21  import java.io.StringWriter;
22  import java.text.DateFormat;
23  import java.text.ParsePosition;
24  import java.util.Locale;
25  import java.util.regex.Matcher;
26  import java.util.regex.Pattern;
27  import javax.xml.stream.*;
28  import org.apache.maven.continuum.model.project.v1_0_9.BuildDefinition;
29  import org.apache.maven.continuum.model.project.v1_0_9.BuildResult;
30  import org.apache.maven.continuum.model.project.v1_0_9.ContinuumDatabase;
31  import org.apache.maven.continuum.model.project.v1_0_9.Project;
32  import org.apache.maven.continuum.model.project.v1_0_9.ProjectDependency;
33  import org.apache.maven.continuum.model.project.v1_0_9.ProjectDeveloper;
34  import org.apache.maven.continuum.model.project.v1_0_9.ProjectGroup;
35  import org.apache.maven.continuum.model.project.v1_0_9.ProjectNotifier;
36  import org.apache.maven.continuum.model.project.v1_0_9.Schedule;
37  import org.apache.maven.continuum.model.scm.v1_0_9.ChangeFile;
38  import org.apache.maven.continuum.model.scm.v1_0_9.ChangeSet;
39  import org.apache.maven.continuum.model.scm.v1_0_9.ScmResult;
40  import org.apache.maven.continuum.model.scm.v1_0_9.SuiteResult;
41  import org.apache.maven.continuum.model.scm.v1_0_9.TestCaseFailure;
42  import org.apache.maven.continuum.model.scm.v1_0_9.TestResult;
43  import org.apache.maven.continuum.model.system.v1_0_9.NotificationAddress;
44  import org.apache.maven.continuum.model.system.v1_0_9.SystemConfiguration;
45  import org.codehaus.plexus.util.xml.Xpp3Dom;
46  
47  /**
48   * Class ContinuumStaxReader.
49   * 
50   * @version $Revision$ $Date$
51   */
52  @SuppressWarnings( "all" )
53  public class ContinuumStaxReader
54  {
55  
56        //--------------------------/
57       //- Class/Member Variables -/
58      //--------------------------/
59  
60      /**
61       * Field projectGroupInstances.
62       */
63      private java.util.Map projectGroupInstances;
64  
65      /**
66       * Field projectInstances.
67       */
68      private java.util.Map projectInstances;
69  
70      /**
71       * Field projectGroupReferences.
72       */
73      private java.util.Map projectGroupReferences;
74  
75      /**
76       * Field projectReferences.
77       */
78      private java.util.Map projectReferences;
79  
80      /**
81       * Field scheduleReferences.
82       */
83      private java.util.Map scheduleReferences;
84  
85      /**
86       * Field scheduleInstances.
87       */
88      private java.util.Map scheduleInstances;
89  
90  
91        //-----------/
92       //- Methods -/
93      //-----------/
94  
95      /**
96       * Method buildDom.
97       * 
98       * @param xmlStreamReader
99       * @throws XMLStreamException
100      * @return Xpp3Dom
101      */
102     private Xpp3Dom buildDom( XMLStreamReader xmlStreamReader )
103         throws XMLStreamException
104     {
105         java.util.List elements = new java.util.ArrayList();
106         java.util.List values = new java.util.ArrayList();
107         int eventType = xmlStreamReader.getEventType();
108         while ( xmlStreamReader.hasNext() )
109         {
110             if ( eventType == XMLStreamConstants.START_ELEMENT )
111             {
112                 String rawName = xmlStreamReader.getLocalName();
113                 Xpp3Dom childConfiguration = new Xpp3Dom( rawName );
114                 int depth = elements.size();
115                 if ( depth > 0 )
116                 {
117                     Xpp3Dom parent = (Xpp3Dom) elements.get( depth - 1 );
118                     parent.addChild( childConfiguration );
119                 }
120                 elements.add( childConfiguration );
121                 if ( xmlStreamReader.isEndElement() )
122                 {
123                     values.add( null );
124                 }
125                 else
126                 {
127                     values.add( new StringBuffer() );
128                 }
129                 int attributesSize = xmlStreamReader.getAttributeCount();
130                 for ( int i = 0; i < attributesSize; i++ )
131                 {
132                     String name = xmlStreamReader.getAttributeLocalName( i );
133                     String value = xmlStreamReader.getAttributeValue( i );
134                     childConfiguration.setAttribute( name, value );
135                 }
136             }
137             else if ( eventType == XMLStreamConstants.CHARACTERS )
138             {
139                 int depth = values.size() - 1;
140                 StringBuffer valueBuffer = (StringBuffer) values.get( depth );
141                 String text = xmlStreamReader.getText();
142                 text = text.trim();
143                 valueBuffer.append( text );
144             }
145             else if ( eventType == XMLStreamConstants.END_ELEMENT )
146             {
147                 int depth = elements.size() - 1;
148                 Xpp3Dom finishedConfiguration = (Xpp3Dom) elements.remove( depth );
149                 // this Object could be null if it is a singleton tag
150                 Object accumulatedValue = values.remove( depth );
151                 if ( finishedConfiguration.getChildCount() == 0 )
152                 {
153                     if ( accumulatedValue == null )
154                     {
155                         finishedConfiguration.setValue( null );
156                     }
157                     else
158                     {
159                         finishedConfiguration.setValue( accumulatedValue.toString() );
160                     }
161                 }
162                 if ( depth == 0 )
163                 {
164                     return finishedConfiguration;
165                 }
166             }
167             eventType = xmlStreamReader.next();
168         }
169         throw new IllegalStateException( "End of document found before returning to 0 depth" );
170     } //-- Xpp3Dom buildDom( XMLStreamReader )
171 
172     /**
173      * Method checkFieldWithDuplicate.
174      * 
175      * @param xmlStreamReader
176      * @param parsed
177      * @param alias
178      * @param tagName
179      * @throws XMLStreamException
180      * @return boolean
181      */
182     private boolean checkFieldWithDuplicate( XMLStreamReader xmlStreamReader, String tagName, String alias, java.util.Set parsed )
183         throws XMLStreamException
184     {
185         if ( !( xmlStreamReader.getLocalName().equals( tagName ) || xmlStreamReader.getLocalName().equals( alias ) ) )
186         {
187             return false;
188         }
189         if ( parsed.contains( tagName ) )
190         {
191             throw new XMLStreamException( "Duplicated tag: '" + tagName + "'", xmlStreamReader.getLocation() );
192         }
193         parsed.add( tagName );
194         return true;
195     } //-- boolean checkFieldWithDuplicate( XMLStreamReader, String, String, java.util.Set )
196 
197     /**
198      * Method getBooleanValue.
199      * 
200      * @param s
201      * @param xmlStreamReader
202      * @param attribute
203      * @throws XMLStreamException
204      * @return boolean
205      */
206     private boolean getBooleanValue( String s, String attribute, XMLStreamReader xmlStreamReader )
207         throws XMLStreamException
208     {
209         if ( s != null )
210         {
211             return Boolean.valueOf( s ).booleanValue();
212         }
213         return false;
214     } //-- boolean getBooleanValue( String, String, XMLStreamReader )
215 
216     /**
217      * Method getByteValue.
218      * 
219      * @param s
220      * @param strict
221      * @param xmlStreamReader
222      * @param attribute
223      * @throws XMLStreamException
224      * @return byte
225      */
226     private byte getByteValue( String s, String attribute, XMLStreamReader xmlStreamReader, boolean strict )
227         throws XMLStreamException
228     {
229         if ( s != null )
230         {
231             try
232             {
233                 return Byte.valueOf( s ).byteValue();
234             }
235             catch ( NumberFormatException e )
236             {
237                 if ( strict )
238                 {
239                     throw new XMLStreamException( "Unable to parse element '" + attribute + "', must be a byte but was '" + s + "'", xmlStreamReader.getLocation() );
240                 }
241             }
242         }
243         return 0;
244     } //-- byte getByteValue( String, String, XMLStreamReader, boolean )
245 
246     /**
247      * Method getCharacterValue.
248      * 
249      * @param s
250      * @param xmlStreamReader
251      * @param attribute
252      * @throws XMLStreamException
253      * @return char
254      */
255     private char getCharacterValue( String s, String attribute, XMLStreamReader xmlStreamReader )
256         throws XMLStreamException
257     {
258         if ( s != null )
259         {
260             return s.charAt( 0 );
261         }
262         return 0;
263     } //-- char getCharacterValue( String, String, XMLStreamReader )
264 
265     /**
266      * Method getDateValue.
267      * 
268      * @param s
269      * @param xmlStreamReader
270      * @param dateFormat
271      * @param attribute
272      * @throws XMLStreamException
273      * @return Date
274      */
275     private java.util.Date getDateValue( String s, String attribute, String dateFormat, XMLStreamReader xmlStreamReader )
276         throws XMLStreamException
277     {
278         if ( s != null )
279         {
280             String effectiveDateFormat = dateFormat;
281             if ( dateFormat == null )
282             {
283                 effectiveDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS";
284             }
285             if ( "long".equals( effectiveDateFormat ) )
286             {
287                 try
288                 {
289                     return new java.util.Date( Long.parseLong( s ) );
290                 }
291                 catch ( NumberFormatException e )
292                 {
293                     throw new XMLStreamException( e.getMessage() );
294                 }
295             }
296             else
297             {
298                 try
299                 {
300                     DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, Locale.US );
301                     return dateParser.parse( s );
302                 }
303                 catch ( java.text.ParseException e )
304                 {
305                     throw new XMLStreamException( e.getMessage() );
306                 }
307             }
308         }
309         return null;
310     } //-- java.util.Date getDateValue( String, String, String, XMLStreamReader )
311 
312     /**
313      * Method getDefaultValue.
314      * 
315      * @param s
316      * @param v
317      * @return String
318      */
319     private String getDefaultValue( String s, String v )
320     {
321         if ( s == null )
322         {
323             s = v;
324         }
325         return s;
326     } //-- String getDefaultValue( String, String )
327 
328     /**
329      * Method getDoubleValue.
330      * 
331      * @param s
332      * @param strict
333      * @param xmlStreamReader
334      * @param attribute
335      * @throws XMLStreamException
336      * @return double
337      */
338     private double getDoubleValue( String s, String attribute, XMLStreamReader xmlStreamReader, boolean strict )
339         throws XMLStreamException
340     {
341         if ( s != null )
342         {
343             try
344             {
345                 return Double.valueOf( s ).doubleValue();
346             }
347             catch ( NumberFormatException e )
348             {
349                 if ( strict )
350                 {
351                     throw new XMLStreamException( "Unable to parse element '" + attribute + "', must be a floating point number but was '" + s + "'", xmlStreamReader.getLocation() );
352                 }
353             }
354         }
355         return 0;
356     } //-- double getDoubleValue( String, String, XMLStreamReader, boolean )
357 
358     /**
359      * Method getFloatValue.
360      * 
361      * @param s
362      * @param strict
363      * @param xmlStreamReader
364      * @param attribute
365      * @throws XMLStreamException
366      * @return float
367      */
368     private float getFloatValue( String s, String attribute, XMLStreamReader xmlStreamReader, boolean strict )
369         throws XMLStreamException
370     {
371         if ( s != null )
372         {
373             try
374             {
375                 return Float.valueOf( s ).floatValue();
376             }
377             catch ( NumberFormatException e )
378             {
379                 if ( strict )
380                 {
381                     throw new XMLStreamException( "Unable to parse element '" + attribute + "', must be a floating point number but was '" + s + "'", xmlStreamReader.getLocation() );
382                 }
383             }
384         }
385         return 0;
386     } //-- float getFloatValue( String, String, XMLStreamReader, boolean )
387 
388     /**
389      * Method getIntegerValue.
390      * 
391      * @param s
392      * @param strict
393      * @param xmlStreamReader
394      * @param attribute
395      * @throws XMLStreamException
396      * @return int
397      */
398     private int getIntegerValue( String s, String attribute, XMLStreamReader xmlStreamReader, boolean strict )
399         throws XMLStreamException
400     {
401         if ( s != null )
402         {
403             try
404             {
405                 return Integer.valueOf( s ).intValue();
406             }
407             catch ( NumberFormatException e )
408             {
409                 if ( strict )
410                 {
411                     throw new XMLStreamException( "Unable to parse element '" + attribute + "', must be an integer but was '" + s + "'", xmlStreamReader.getLocation() );
412                 }
413             }
414         }
415         return 0;
416     } //-- int getIntegerValue( String, String, XMLStreamReader, boolean )
417 
418     /**
419      * Method getLongValue.
420      * 
421      * @param s
422      * @param strict
423      * @param xmlStreamReader
424      * @param attribute
425      * @throws XMLStreamException
426      * @return long
427      */
428     private long getLongValue( String s, String attribute, XMLStreamReader xmlStreamReader, boolean strict )
429         throws XMLStreamException
430     {
431         if ( s != null )
432         {
433             try
434             {
435                 return Long.valueOf( s ).longValue();
436             }
437             catch ( NumberFormatException e )
438             {
439                 if ( strict )
440                 {
441                     throw new XMLStreamException( "Unable to parse element '" + attribute + "', must be a long integer but was '" + s + "'", xmlStreamReader.getLocation() );
442                 }
443             }
444         }
445         return 0;
446     } //-- long getLongValue( String, String, XMLStreamReader, boolean )
447 
448     /**
449      * Method getRequiredAttributeValue.
450      * 
451      * @param s
452      * @param strict
453      * @param xmlStreamReader
454      * @param attribute
455      * @throws XMLStreamException
456      * @return String
457      */
458     private String getRequiredAttributeValue( String s, String attribute, XMLStreamReader xmlStreamReader, boolean strict )
459         throws XMLStreamException
460     {
461         if ( s == null )
462         {
463             if ( strict )
464             {
465                 throw new XMLStreamException( "Missing required value for attribute '" + attribute + "'", xmlStreamReader.getLocation() );
466             }
467         }
468         return s;
469     } //-- String getRequiredAttributeValue( String, String, XMLStreamReader, boolean )
470 
471     /**
472      * Method getShortValue.
473      * 
474      * @param s
475      * @param strict
476      * @param xmlStreamReader
477      * @param attribute
478      * @throws XMLStreamException
479      * @return short
480      */
481     private short getShortValue( String s, String attribute, XMLStreamReader xmlStreamReader, boolean strict )
482         throws XMLStreamException
483     {
484         if ( s != null )
485         {
486             try
487             {
488                 return Short.valueOf( s ).shortValue();
489             }
490             catch ( NumberFormatException e )
491             {
492                 if ( strict )
493                 {
494                     throw new XMLStreamException( "Unable to parse element '" + attribute + "', must be a short integer but was '" + s + "'", xmlStreamReader.getLocation() );
495                 }
496             }
497         }
498         return 0;
499     } //-- short getShortValue( String, String, XMLStreamReader, boolean )
500 
501     /**
502      * Method getTrimmedValue.
503      * 
504      * @param s
505      * @return String
506      */
507     private String getTrimmedValue( String s )
508     {
509         if ( s != null )
510         {
511             s = s.trim();
512         }
513         return s;
514     } //-- String getTrimmedValue( String )
515 
516     /**
517      * Method parseBuildDefinition.
518      * 
519      * @param tagName
520      * @param encoding
521      * @param strict
522      * @param xmlStreamReader
523      * @throws IOException
524      * @throws XMLStreamException
525      * @return BuildDefinition
526      */
527     private BuildDefinition parseBuildDefinition( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
528         throws IOException, XMLStreamException
529     {
530         BuildDefinition buildDefinition = new BuildDefinition();
531         java.util.Set parsed = new java.util.HashSet();
532         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
533         {
534             if ( checkFieldWithDuplicate( xmlStreamReader, "id", null, parsed ) )
535             {
536                 buildDefinition.setId( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "id", xmlStreamReader, strict ) );
537             }
538             else if ( checkFieldWithDuplicate( xmlStreamReader, "defaultForProject", null, parsed ) )
539             {
540                 buildDefinition.setDefaultForProject( getBooleanValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "false" ) ), "defaultForProject", xmlStreamReader ) );
541             }
542             else if ( checkFieldWithDuplicate( xmlStreamReader, "goals", null, parsed ) )
543             {
544                 buildDefinition.setGoals( getTrimmedValue( xmlStreamReader.getElementText() ) );
545             }
546             else if ( checkFieldWithDuplicate( xmlStreamReader, "arguments", null, parsed ) )
547             {
548                 buildDefinition.setArguments( getTrimmedValue( xmlStreamReader.getElementText() ) );
549             }
550             else if ( checkFieldWithDuplicate( xmlStreamReader, "buildFile", null, parsed ) )
551             {
552                 buildDefinition.setBuildFile( getTrimmedValue( xmlStreamReader.getElementText() ) );
553             }
554             else if ( checkFieldWithDuplicate( xmlStreamReader, "schedule", null, parsed ) )
555             {
556                 String value = xmlStreamReader.getAttributeValue( null, "id" );
557                 if ( value != null )
558                 {
559                     // This is a reference to an element elsewhere in the model
560                     if ( scheduleReferences == null )
561                     {
562                         scheduleReferences = new java.util.HashMap();
563                     }
564                     java.util.Map refs = (java.util.Map) scheduleReferences.get( buildDefinition );
565                     if ( refs == null )
566                     {
567                         refs = new java.util.HashMap();
568                         scheduleReferences.put( buildDefinition, refs );
569                     }
570                     refs.put( "schedule", value );
571                 }
572                 while ( xmlStreamReader.getEventType() != XMLStreamConstants.END_ELEMENT )
573                 {
574                     xmlStreamReader.next();
575                 }
576             }
577             else if ( checkFieldWithDuplicate( xmlStreamReader, "latestBuildId", null, parsed ) )
578             {
579                 buildDefinition.setLatestBuildId( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "latestBuildId", xmlStreamReader, strict ) );
580             }
581             else
582             {
583                 if ( strict )
584                 {
585                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
586                 }
587                 else
588                 {
589                     int unrecognizedTagCount = 1;
590                     while( unrecognizedTagCount != 0 )
591                     {
592                         xmlStreamReader.next();
593                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
594                         {
595                             unrecognizedTagCount++;
596                         }
597                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
598                         {
599                             unrecognizedTagCount--;
600                         }
601                     }
602                 }
603             }
604         }
605         return buildDefinition;
606     } //-- BuildDefinition parseBuildDefinition( String, XMLStreamReader, boolean, String )
607 
608     /**
609      * Method parseBuildResult.
610      * 
611      * @param tagName
612      * @param encoding
613      * @param strict
614      * @param xmlStreamReader
615      * @throws IOException
616      * @throws XMLStreamException
617      * @return BuildResult
618      */
619     private BuildResult parseBuildResult( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
620         throws IOException, XMLStreamException
621     {
622         BuildResult buildResult = new BuildResult();
623         java.util.Set parsed = new java.util.HashSet();
624         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
625         {
626             if ( checkFieldWithDuplicate( xmlStreamReader, "project", null, parsed ) )
627             {
628                 String value = xmlStreamReader.getAttributeValue( null, "id" );
629                 if ( value != null )
630                 {
631                     // This is a reference to an element elsewhere in the model
632                     if ( projectReferences == null )
633                     {
634                         projectReferences = new java.util.HashMap();
635                     }
636                     java.util.Map refs = (java.util.Map) projectReferences.get( buildResult );
637                     if ( refs == null )
638                     {
639                         refs = new java.util.HashMap();
640                         projectReferences.put( buildResult, refs );
641                     }
642                     refs.put( "project", value );
643                 }
644                 while ( xmlStreamReader.getEventType() != XMLStreamConstants.END_ELEMENT )
645                 {
646                     xmlStreamReader.next();
647                 }
648             }
649             else if ( checkFieldWithDuplicate( xmlStreamReader, "id", null, parsed ) )
650             {
651                 buildResult.setId( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "id", xmlStreamReader, strict ) );
652             }
653             else if ( checkFieldWithDuplicate( xmlStreamReader, "buildNumber", null, parsed ) )
654             {
655                 buildResult.setBuildNumber( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "buildNumber", xmlStreamReader, strict ) );
656             }
657             else if ( checkFieldWithDuplicate( xmlStreamReader, "state", null, parsed ) )
658             {
659                 buildResult.setState( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "state", xmlStreamReader, strict ) );
660             }
661             else if ( checkFieldWithDuplicate( xmlStreamReader, "trigger", null, parsed ) )
662             {
663                 buildResult.setTrigger( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "trigger", xmlStreamReader, strict ) );
664             }
665             else if ( checkFieldWithDuplicate( xmlStreamReader, "startTime", null, parsed ) )
666             {
667                 buildResult.setStartTime( getLongValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "startTime", xmlStreamReader, strict ) );
668             }
669             else if ( checkFieldWithDuplicate( xmlStreamReader, "endTime", null, parsed ) )
670             {
671                 buildResult.setEndTime( getLongValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "endTime", xmlStreamReader, strict ) );
672             }
673             else if ( checkFieldWithDuplicate( xmlStreamReader, "error", null, parsed ) )
674             {
675                 buildResult.setError( getTrimmedValue( xmlStreamReader.getElementText() ) );
676             }
677             else if ( checkFieldWithDuplicate( xmlStreamReader, "success", null, parsed ) )
678             {
679                 buildResult.setSuccess( getBooleanValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "false" ) ), "success", xmlStreamReader ) );
680             }
681             else if ( checkFieldWithDuplicate( xmlStreamReader, "exitCode", null, parsed ) )
682             {
683                 buildResult.setExitCode( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "exitCode", xmlStreamReader, strict ) );
684             }
685             else if ( checkFieldWithDuplicate( xmlStreamReader, "scmResult", null, parsed ) )
686             {
687                 buildResult.setScmResult( parseScmResult( "scmResult", xmlStreamReader, strict, encoding ) );
688             }
689             else if ( checkFieldWithDuplicate( xmlStreamReader, "testResult", null, parsed ) )
690             {
691                 buildResult.setTestResult( parseTestResult( "testResult", xmlStreamReader, strict, encoding ) );
692             }
693             else
694             {
695                 if ( strict )
696                 {
697                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
698                 }
699                 else
700                 {
701                     int unrecognizedTagCount = 1;
702                     while( unrecognizedTagCount != 0 )
703                     {
704                         xmlStreamReader.next();
705                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
706                         {
707                             unrecognizedTagCount++;
708                         }
709                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
710                         {
711                             unrecognizedTagCount--;
712                         }
713                     }
714                 }
715             }
716         }
717         return buildResult;
718     } //-- BuildResult parseBuildResult( String, XMLStreamReader, boolean, String )
719 
720     /**
721      * Method parseChangeFile.
722      * 
723      * @param tagName
724      * @param encoding
725      * @param strict
726      * @param xmlStreamReader
727      * @throws IOException
728      * @throws XMLStreamException
729      * @return ChangeFile
730      */
731     private ChangeFile parseChangeFile( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
732         throws IOException, XMLStreamException
733     {
734         ChangeFile changeFile = new ChangeFile();
735         java.util.Set parsed = new java.util.HashSet();
736         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
737         {
738             if ( checkFieldWithDuplicate( xmlStreamReader, "name", null, parsed ) )
739             {
740                 changeFile.setName( getTrimmedValue( xmlStreamReader.getElementText() ) );
741             }
742             else if ( checkFieldWithDuplicate( xmlStreamReader, "revision", null, parsed ) )
743             {
744                 changeFile.setRevision( getTrimmedValue( xmlStreamReader.getElementText() ) );
745             }
746             else if ( checkFieldWithDuplicate( xmlStreamReader, "status", null, parsed ) )
747             {
748                 changeFile.setStatus( getTrimmedValue( xmlStreamReader.getElementText() ) );
749             }
750             else
751             {
752                 if ( strict )
753                 {
754                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
755                 }
756                 else
757                 {
758                     int unrecognizedTagCount = 1;
759                     while( unrecognizedTagCount != 0 )
760                     {
761                         xmlStreamReader.next();
762                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
763                         {
764                             unrecognizedTagCount++;
765                         }
766                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
767                         {
768                             unrecognizedTagCount--;
769                         }
770                     }
771                 }
772             }
773         }
774         return changeFile;
775     } //-- ChangeFile parseChangeFile( String, XMLStreamReader, boolean, String )
776 
777     /**
778      * Method parseChangeSet.
779      * 
780      * @param tagName
781      * @param encoding
782      * @param strict
783      * @param xmlStreamReader
784      * @throws IOException
785      * @throws XMLStreamException
786      * @return ChangeSet
787      */
788     private ChangeSet parseChangeSet( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
789         throws IOException, XMLStreamException
790     {
791         ChangeSet changeSet = new ChangeSet();
792         java.util.Set parsed = new java.util.HashSet();
793         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
794         {
795             if ( checkFieldWithDuplicate( xmlStreamReader, "author", null, parsed ) )
796             {
797                 changeSet.setAuthor( getTrimmedValue( xmlStreamReader.getElementText() ) );
798             }
799             else if ( checkFieldWithDuplicate( xmlStreamReader, "comment", null, parsed ) )
800             {
801                 changeSet.setComment( getTrimmedValue( xmlStreamReader.getElementText() ) );
802             }
803             else if ( checkFieldWithDuplicate( xmlStreamReader, "date", null, parsed ) )
804             {
805                 changeSet.setDate( getLongValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "date", xmlStreamReader, strict ) );
806             }
807             else if ( checkFieldWithDuplicate( xmlStreamReader, "files", null, parsed ) )
808             {
809                 java.util.List files = new java.util.ArrayList/*<ChangeFile>*/();
810                 changeSet.setFiles( files );
811                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
812                 {
813                     if ( xmlStreamReader.getLocalName().equals( "file" ) )
814                     {
815                         changeSet.addFile( parseChangeFile( "file", xmlStreamReader, strict, encoding ) );
816                     }
817                     else
818                     {
819                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
820                     }
821                 }
822             }
823             else
824             {
825                 if ( strict )
826                 {
827                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
828                 }
829                 else
830                 {
831                     int unrecognizedTagCount = 1;
832                     while( unrecognizedTagCount != 0 )
833                     {
834                         xmlStreamReader.next();
835                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
836                         {
837                             unrecognizedTagCount++;
838                         }
839                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
840                         {
841                             unrecognizedTagCount--;
842                         }
843                     }
844                 }
845             }
846         }
847         return changeSet;
848     } //-- ChangeSet parseChangeSet( String, XMLStreamReader, boolean, String )
849 
850     /**
851      * Method parseContinuumDatabase.
852      * 
853      * @param tagName
854      * @param encoding
855      * @param strict
856      * @param xmlStreamReader
857      * @throws IOException
858      * @throws XMLStreamException
859      * @return ContinuumDatabase
860      */
861     private ContinuumDatabase parseContinuumDatabase( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
862         throws IOException, XMLStreamException
863     {
864         ContinuumDatabase continuumDatabase = new ContinuumDatabase();
865         java.util.Set parsed = new java.util.HashSet();
866         continuumDatabase.setModelEncoding( encoding );
867         boolean foundRoot = false;
868         while ( xmlStreamReader.hasNext() )
869         {
870             int eventType = xmlStreamReader.next();
871             if ( eventType == XMLStreamConstants.START_ELEMENT )
872             {
873                 if ( xmlStreamReader.getLocalName().equals( tagName ) )
874                 {
875                     foundRoot = true;
876                 }
877                 else if ( checkFieldWithDuplicate( xmlStreamReader, "projectGroups", null, parsed ) )
878                 {
879                     java.util.List projectGroups = new java.util.ArrayList/*<ProjectGroup>*/();
880                     continuumDatabase.setProjectGroups( projectGroups );
881                     while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
882                     {
883                         if ( xmlStreamReader.getLocalName().equals( "projectGroup" ) )
884                         {
885                             continuumDatabase.addProjectGroup( parseProjectGroup( "projectGroup", xmlStreamReader, strict, encoding ) );
886                         }
887                         else
888                         {
889                             throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
890                         }
891                     }
892                 }
893                 else if ( checkFieldWithDuplicate( xmlStreamReader, "systemConfiguration", null, parsed ) )
894                 {
895                     continuumDatabase.setSystemConfiguration( parseSystemConfiguration( "systemConfiguration", xmlStreamReader, strict, encoding ) );
896                 }
897                 else if ( checkFieldWithDuplicate( xmlStreamReader, "schedules", null, parsed ) )
898                 {
899                     java.util.List schedules = new java.util.ArrayList/*<Schedule>*/();
900                     continuumDatabase.setSchedules( schedules );
901                     while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
902                     {
903                         if ( xmlStreamReader.getLocalName().equals( "schedule" ) )
904                         {
905                             continuumDatabase.addSchedule( parseSchedule( "schedule", xmlStreamReader, strict, encoding ) );
906                         }
907                         else
908                         {
909                             throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
910                         }
911                     }
912                 }
913                 else
914                 {
915                     if ( foundRoot )
916                     {
917                         if ( strict )
918                         {
919                             throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
920                         }
921                     }
922                 }
923             }
924         }
925         return continuumDatabase;
926     } //-- ContinuumDatabase parseContinuumDatabase( String, XMLStreamReader, boolean, String )
927 
928     /**
929      * Method parseNotificationAddress.
930      * 
931      * @param tagName
932      * @param encoding
933      * @param strict
934      * @param xmlStreamReader
935      * @throws IOException
936      * @throws XMLStreamException
937      * @return NotificationAddress
938      */
939     private NotificationAddress parseNotificationAddress( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
940         throws IOException, XMLStreamException
941     {
942         NotificationAddress notificationAddress = new NotificationAddress();
943         java.util.Set parsed = new java.util.HashSet();
944         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
945         {
946             if ( checkFieldWithDuplicate( xmlStreamReader, "type", null, parsed ) )
947             {
948                 notificationAddress.setType( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "mail" ) ) );
949             }
950             else if ( checkFieldWithDuplicate( xmlStreamReader, "address", null, parsed ) )
951             {
952                 notificationAddress.setAddress( getTrimmedValue( xmlStreamReader.getElementText() ) );
953             }
954             else if ( checkFieldWithDuplicate( xmlStreamReader, "configuration", null, parsed ) )
955             {
956                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
957                 {
958                     String key = xmlStreamReader.getLocalName();
959                     String value = xmlStreamReader.getElementText().trim();
960                     notificationAddress.addConfiguration( key, value );
961                 }
962             }
963             else
964             {
965                 if ( strict )
966                 {
967                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
968                 }
969                 else
970                 {
971                     int unrecognizedTagCount = 1;
972                     while( unrecognizedTagCount != 0 )
973                     {
974                         xmlStreamReader.next();
975                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
976                         {
977                             unrecognizedTagCount++;
978                         }
979                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
980                         {
981                             unrecognizedTagCount--;
982                         }
983                     }
984                 }
985             }
986         }
987         return notificationAddress;
988     } //-- NotificationAddress parseNotificationAddress( String, XMLStreamReader, boolean, String )
989 
990     /**
991      * Method parseProject.
992      * 
993      * @param tagName
994      * @param encoding
995      * @param strict
996      * @param xmlStreamReader
997      * @throws IOException
998      * @throws XMLStreamException
999      * @return Project
1000      */
1001     private Project parseProject( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
1002         throws IOException, XMLStreamException
1003     {
1004         Project project = new Project();
1005         java.util.Set parsed = new java.util.HashSet();
1006         if ( projectInstances == null )
1007         {
1008             projectInstances = new java.util.HashMap();
1009         }
1010         String v = xmlStreamReader.getAttributeValue( null, "modello.id" );
1011         if ( v != null )
1012         {
1013             projectInstances.put( v, project );
1014         }
1015         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1016         {
1017             if ( checkFieldWithDuplicate( xmlStreamReader, "id", null, parsed ) )
1018             {
1019                 project.setId( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "id", xmlStreamReader, strict ) );
1020             }
1021             else if ( checkFieldWithDuplicate( xmlStreamReader, "groupId", null, parsed ) )
1022             {
1023                 project.setGroupId( getTrimmedValue( xmlStreamReader.getElementText() ) );
1024             }
1025             else if ( checkFieldWithDuplicate( xmlStreamReader, "artifactId", null, parsed ) )
1026             {
1027                 project.setArtifactId( getTrimmedValue( xmlStreamReader.getElementText() ) );
1028             }
1029             else if ( checkFieldWithDuplicate( xmlStreamReader, "executorId", null, parsed ) )
1030             {
1031                 project.setExecutorId( getTrimmedValue( xmlStreamReader.getElementText() ) );
1032             }
1033             else if ( checkFieldWithDuplicate( xmlStreamReader, "name", null, parsed ) )
1034             {
1035                 project.setName( getTrimmedValue( xmlStreamReader.getElementText() ) );
1036             }
1037             else if ( checkFieldWithDuplicate( xmlStreamReader, "description", null, parsed ) )
1038             {
1039                 project.setDescription( getTrimmedValue( xmlStreamReader.getElementText() ) );
1040             }
1041             else if ( checkFieldWithDuplicate( xmlStreamReader, "url", null, parsed ) )
1042             {
1043                 project.setUrl( getTrimmedValue( xmlStreamReader.getElementText() ) );
1044             }
1045             else if ( checkFieldWithDuplicate( xmlStreamReader, "scmUrl", null, parsed ) )
1046             {
1047                 project.setScmUrl( getTrimmedValue( xmlStreamReader.getElementText() ) );
1048             }
1049             else if ( checkFieldWithDuplicate( xmlStreamReader, "scmTag", null, parsed ) )
1050             {
1051                 project.setScmTag( getTrimmedValue( xmlStreamReader.getElementText() ) );
1052             }
1053             else if ( checkFieldWithDuplicate( xmlStreamReader, "scmUsername", null, parsed ) )
1054             {
1055                 project.setScmUsername( getTrimmedValue( xmlStreamReader.getElementText() ) );
1056             }
1057             else if ( checkFieldWithDuplicate( xmlStreamReader, "scmPassword", null, parsed ) )
1058             {
1059                 project.setScmPassword( getTrimmedValue( xmlStreamReader.getElementText() ) );
1060             }
1061             else if ( checkFieldWithDuplicate( xmlStreamReader, "version", null, parsed ) )
1062             {
1063                 project.setVersion( getTrimmedValue( xmlStreamReader.getElementText() ) );
1064             }
1065             else if ( checkFieldWithDuplicate( xmlStreamReader, "state", null, parsed ) )
1066             {
1067                 project.setState( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "1" ) ), "state", xmlStreamReader, strict ) );
1068             }
1069             else if ( checkFieldWithDuplicate( xmlStreamReader, "oldState", null, parsed ) )
1070             {
1071                 project.setOldState( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "oldState", xmlStreamReader, strict ) );
1072             }
1073             else if ( checkFieldWithDuplicate( xmlStreamReader, "latestBuildId", null, parsed ) )
1074             {
1075                 project.setLatestBuildId( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "latestBuildId", xmlStreamReader, strict ) );
1076             }
1077             else if ( checkFieldWithDuplicate( xmlStreamReader, "buildNumber", null, parsed ) )
1078             {
1079                 project.setBuildNumber( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "buildNumber", xmlStreamReader, strict ) );
1080             }
1081             else if ( checkFieldWithDuplicate( xmlStreamReader, "workingDirectory", null, parsed ) )
1082             {
1083                 project.setWorkingDirectory( getTrimmedValue( xmlStreamReader.getElementText() ) );
1084             }
1085             else if ( checkFieldWithDuplicate( xmlStreamReader, "buildResults", null, parsed ) )
1086             {
1087                 java.util.List buildResults = new java.util.ArrayList/*<BuildResult>*/();
1088                 project.setBuildResults( buildResults );
1089                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1090                 {
1091                     if ( xmlStreamReader.getLocalName().equals( "buildResult" ) )
1092                     {
1093                         project.addBuildResult( parseBuildResult( "buildResult", xmlStreamReader, strict, encoding ) );
1094                     }
1095                     else
1096                     {
1097                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1098                     }
1099                 }
1100             }
1101             else if ( checkFieldWithDuplicate( xmlStreamReader, "checkoutResult", null, parsed ) )
1102             {
1103                 project.setCheckoutResult( parseScmResult( "checkoutResult", xmlStreamReader, strict, encoding ) );
1104             }
1105             else if ( checkFieldWithDuplicate( xmlStreamReader, "developers", null, parsed ) )
1106             {
1107                 java.util.List developers = new java.util.ArrayList/*<ProjectDeveloper>*/();
1108                 project.setDevelopers( developers );
1109                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1110                 {
1111                     if ( xmlStreamReader.getLocalName().equals( "developer" ) )
1112                     {
1113                         project.addDeveloper( parseProjectDeveloper( "developer", xmlStreamReader, strict, encoding ) );
1114                     }
1115                     else
1116                     {
1117                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1118                     }
1119                 }
1120             }
1121             else if ( checkFieldWithDuplicate( xmlStreamReader, "parent", null, parsed ) )
1122             {
1123                 project.setParent( parseProjectDependency( "parent", xmlStreamReader, strict, encoding ) );
1124             }
1125             else if ( checkFieldWithDuplicate( xmlStreamReader, "dependencies", null, parsed ) )
1126             {
1127                 java.util.List dependencies = new java.util.ArrayList/*<ProjectDependency>*/();
1128                 project.setDependencies( dependencies );
1129                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1130                 {
1131                     if ( xmlStreamReader.getLocalName().equals( "dependency" ) )
1132                     {
1133                         project.addDependency( parseProjectDependency( "dependency", xmlStreamReader, strict, encoding ) );
1134                     }
1135                     else
1136                     {
1137                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1138                     }
1139                 }
1140             }
1141             else if ( checkFieldWithDuplicate( xmlStreamReader, "projectGroup", null, parsed ) )
1142             {
1143                 String value = xmlStreamReader.getAttributeValue( null, "id" );
1144                 if ( value != null )
1145                 {
1146                     // This is a reference to an element elsewhere in the model
1147                     if ( projectGroupReferences == null )
1148                     {
1149                         projectGroupReferences = new java.util.HashMap();
1150                     }
1151                     java.util.Map refs = (java.util.Map) projectGroupReferences.get( project );
1152                     if ( refs == null )
1153                     {
1154                         refs = new java.util.HashMap();
1155                         projectGroupReferences.put( project, refs );
1156                     }
1157                     refs.put( "projectGroup", value );
1158                 }
1159                 while ( xmlStreamReader.getEventType() != XMLStreamConstants.END_ELEMENT )
1160                 {
1161                     xmlStreamReader.next();
1162                 }
1163             }
1164             else if ( checkFieldWithDuplicate( xmlStreamReader, "notifiers", null, parsed ) )
1165             {
1166                 java.util.List notifiers = new java.util.ArrayList/*<ProjectNotifier>*/();
1167                 project.setNotifiers( notifiers );
1168                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1169                 {
1170                     if ( xmlStreamReader.getLocalName().equals( "notifier" ) )
1171                     {
1172                         project.addNotifier( parseProjectNotifier( "notifier", xmlStreamReader, strict, encoding ) );
1173                     }
1174                     else
1175                     {
1176                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1177                     }
1178                 }
1179             }
1180             else if ( checkFieldWithDuplicate( xmlStreamReader, "buildDefinitions", null, parsed ) )
1181             {
1182                 java.util.List buildDefinitions = new java.util.ArrayList/*<BuildDefinition>*/();
1183                 project.setBuildDefinitions( buildDefinitions );
1184                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1185                 {
1186                     if ( xmlStreamReader.getLocalName().equals( "buildDefinition" ) )
1187                     {
1188                         project.addBuildDefinition( parseBuildDefinition( "buildDefinition", xmlStreamReader, strict, encoding ) );
1189                     }
1190                     else
1191                     {
1192                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1193                     }
1194                 }
1195             }
1196             else
1197             {
1198                 if ( strict )
1199                 {
1200                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1201                 }
1202                 else
1203                 {
1204                     int unrecognizedTagCount = 1;
1205                     while( unrecognizedTagCount != 0 )
1206                     {
1207                         xmlStreamReader.next();
1208                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
1209                         {
1210                             unrecognizedTagCount++;
1211                         }
1212                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
1213                         {
1214                             unrecognizedTagCount--;
1215                         }
1216                     }
1217                 }
1218             }
1219         }
1220         projectInstances.put( String.valueOf( project.getId() ), project );
1221         return project;
1222     } //-- Project parseProject( String, XMLStreamReader, boolean, String )
1223 
1224     /**
1225      * Method parseProjectDependency.
1226      * 
1227      * @param tagName
1228      * @param encoding
1229      * @param strict
1230      * @param xmlStreamReader
1231      * @throws IOException
1232      * @throws XMLStreamException
1233      * @return ProjectDependency
1234      */
1235     private ProjectDependency parseProjectDependency( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
1236         throws IOException, XMLStreamException
1237     {
1238         ProjectDependency projectDependency = new ProjectDependency();
1239         java.util.Set parsed = new java.util.HashSet();
1240         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1241         {
1242             if ( checkFieldWithDuplicate( xmlStreamReader, "groupId", null, parsed ) )
1243             {
1244                 projectDependency.setGroupId( getTrimmedValue( xmlStreamReader.getElementText() ) );
1245             }
1246             else if ( checkFieldWithDuplicate( xmlStreamReader, "artifactId", null, parsed ) )
1247             {
1248                 projectDependency.setArtifactId( getTrimmedValue( xmlStreamReader.getElementText() ) );
1249             }
1250             else if ( checkFieldWithDuplicate( xmlStreamReader, "version", null, parsed ) )
1251             {
1252                 projectDependency.setVersion( getTrimmedValue( xmlStreamReader.getElementText() ) );
1253             }
1254             else
1255             {
1256                 if ( strict )
1257                 {
1258                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1259                 }
1260                 else
1261                 {
1262                     int unrecognizedTagCount = 1;
1263                     while( unrecognizedTagCount != 0 )
1264                     {
1265                         xmlStreamReader.next();
1266                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
1267                         {
1268                             unrecognizedTagCount++;
1269                         }
1270                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
1271                         {
1272                             unrecognizedTagCount--;
1273                         }
1274                     }
1275                 }
1276             }
1277         }
1278         return projectDependency;
1279     } //-- ProjectDependency parseProjectDependency( String, XMLStreamReader, boolean, String )
1280 
1281     /**
1282      * Method parseProjectDeveloper.
1283      * 
1284      * @param tagName
1285      * @param encoding
1286      * @param strict
1287      * @param xmlStreamReader
1288      * @throws IOException
1289      * @throws XMLStreamException
1290      * @return ProjectDeveloper
1291      */
1292     private ProjectDeveloper parseProjectDeveloper( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
1293         throws IOException, XMLStreamException
1294     {
1295         ProjectDeveloper projectDeveloper = new ProjectDeveloper();
1296         java.util.Set parsed = new java.util.HashSet();
1297         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1298         {
1299             if ( checkFieldWithDuplicate( xmlStreamReader, "scmId", null, parsed ) )
1300             {
1301                 projectDeveloper.setScmId( getTrimmedValue( xmlStreamReader.getElementText() ) );
1302             }
1303             else if ( checkFieldWithDuplicate( xmlStreamReader, "name", null, parsed ) )
1304             {
1305                 projectDeveloper.setName( getTrimmedValue( xmlStreamReader.getElementText() ) );
1306             }
1307             else if ( checkFieldWithDuplicate( xmlStreamReader, "email", null, parsed ) )
1308             {
1309                 projectDeveloper.setEmail( getTrimmedValue( xmlStreamReader.getElementText() ) );
1310             }
1311             else if ( checkFieldWithDuplicate( xmlStreamReader, "continuumId", null, parsed ) )
1312             {
1313                 projectDeveloper.setContinuumId( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "continuumId", xmlStreamReader, strict ) );
1314             }
1315             else
1316             {
1317                 if ( strict )
1318                 {
1319                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1320                 }
1321                 else
1322                 {
1323                     int unrecognizedTagCount = 1;
1324                     while( unrecognizedTagCount != 0 )
1325                     {
1326                         xmlStreamReader.next();
1327                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
1328                         {
1329                             unrecognizedTagCount++;
1330                         }
1331                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
1332                         {
1333                             unrecognizedTagCount--;
1334                         }
1335                     }
1336                 }
1337             }
1338         }
1339         return projectDeveloper;
1340     } //-- ProjectDeveloper parseProjectDeveloper( String, XMLStreamReader, boolean, String )
1341 
1342     /**
1343      * Method parseProjectGroup.
1344      * 
1345      * @param tagName
1346      * @param encoding
1347      * @param strict
1348      * @param xmlStreamReader
1349      * @throws IOException
1350      * @throws XMLStreamException
1351      * @return ProjectGroup
1352      */
1353     private ProjectGroup parseProjectGroup( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
1354         throws IOException, XMLStreamException
1355     {
1356         ProjectGroup projectGroup = new ProjectGroup();
1357         java.util.Set parsed = new java.util.HashSet();
1358         if ( projectGroupInstances == null )
1359         {
1360             projectGroupInstances = new java.util.HashMap();
1361         }
1362         String v = xmlStreamReader.getAttributeValue( null, "modello.id" );
1363         if ( v != null )
1364         {
1365             projectGroupInstances.put( v, projectGroup );
1366         }
1367         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1368         {
1369             if ( checkFieldWithDuplicate( xmlStreamReader, "id", null, parsed ) )
1370             {
1371                 projectGroup.setId( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "id", xmlStreamReader, strict ) );
1372             }
1373             else if ( checkFieldWithDuplicate( xmlStreamReader, "groupId", null, parsed ) )
1374             {
1375                 projectGroup.setGroupId( getTrimmedValue( xmlStreamReader.getElementText() ) );
1376             }
1377             else if ( checkFieldWithDuplicate( xmlStreamReader, "name", null, parsed ) )
1378             {
1379                 projectGroup.setName( getTrimmedValue( xmlStreamReader.getElementText() ) );
1380             }
1381             else if ( checkFieldWithDuplicate( xmlStreamReader, "description", null, parsed ) )
1382             {
1383                 projectGroup.setDescription( getTrimmedValue( xmlStreamReader.getElementText() ) );
1384             }
1385             else if ( checkFieldWithDuplicate( xmlStreamReader, "projects", null, parsed ) )
1386             {
1387                 java.util.List projects = new java.util.ArrayList/*<Project>*/();
1388                 projectGroup.setProjects( projects );
1389                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1390                 {
1391                     if ( xmlStreamReader.getLocalName().equals( "project" ) )
1392                     {
1393                         projectGroup.addProject( parseProject( "project", xmlStreamReader, strict, encoding ) );
1394                     }
1395                     else
1396                     {
1397                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1398                     }
1399                 }
1400             }
1401             else if ( checkFieldWithDuplicate( xmlStreamReader, "notifiers", null, parsed ) )
1402             {
1403                 java.util.List notifiers = new java.util.ArrayList/*<ProjectNotifier>*/();
1404                 projectGroup.setNotifiers( notifiers );
1405                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1406                 {
1407                     if ( xmlStreamReader.getLocalName().equals( "notifier" ) )
1408                     {
1409                         projectGroup.addNotifier( parseProjectNotifier( "notifier", xmlStreamReader, strict, encoding ) );
1410                     }
1411                     else
1412                     {
1413                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1414                     }
1415                 }
1416             }
1417             else if ( checkFieldWithDuplicate( xmlStreamReader, "buildDefinitions", null, parsed ) )
1418             {
1419                 java.util.List buildDefinitions = new java.util.ArrayList/*<BuildDefinition>*/();
1420                 projectGroup.setBuildDefinitions( buildDefinitions );
1421                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1422                 {
1423                     if ( xmlStreamReader.getLocalName().equals( "buildDefinition" ) )
1424                     {
1425                         projectGroup.addBuildDefinition( parseBuildDefinition( "buildDefinition", xmlStreamReader, strict, encoding ) );
1426                     }
1427                     else
1428                     {
1429                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1430                     }
1431                 }
1432             }
1433             else
1434             {
1435                 if ( strict )
1436                 {
1437                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1438                 }
1439                 else
1440                 {
1441                     int unrecognizedTagCount = 1;
1442                     while( unrecognizedTagCount != 0 )
1443                     {
1444                         xmlStreamReader.next();
1445                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
1446                         {
1447                             unrecognizedTagCount++;
1448                         }
1449                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
1450                         {
1451                             unrecognizedTagCount--;
1452                         }
1453                     }
1454                 }
1455             }
1456         }
1457         projectGroupInstances.put( String.valueOf( projectGroup.getId() ), projectGroup );
1458         return projectGroup;
1459     } //-- ProjectGroup parseProjectGroup( String, XMLStreamReader, boolean, String )
1460 
1461     /**
1462      * Method parseProjectNotifier.
1463      * 
1464      * @param tagName
1465      * @param encoding
1466      * @param strict
1467      * @param xmlStreamReader
1468      * @throws IOException
1469      * @throws XMLStreamException
1470      * @return ProjectNotifier
1471      */
1472     private ProjectNotifier parseProjectNotifier( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
1473         throws IOException, XMLStreamException
1474     {
1475         ProjectNotifier projectNotifier = new ProjectNotifier();
1476         java.util.Set parsed = new java.util.HashSet();
1477         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1478         {
1479             if ( checkFieldWithDuplicate( xmlStreamReader, "id", null, parsed ) )
1480             {
1481                 projectNotifier.setId( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "id", xmlStreamReader, strict ) );
1482             }
1483             else if ( checkFieldWithDuplicate( xmlStreamReader, "type", null, parsed ) )
1484             {
1485                 projectNotifier.setType( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "mail" ) ) );
1486             }
1487             else if ( checkFieldWithDuplicate( xmlStreamReader, "from", null, parsed ) )
1488             {
1489                 projectNotifier.setFrom( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "from", xmlStreamReader, strict ) );
1490             }
1491             else if ( checkFieldWithDuplicate( xmlStreamReader, "enabled", null, parsed ) )
1492             {
1493                 projectNotifier.setEnabled( getBooleanValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "true" ) ), "enabled", xmlStreamReader ) );
1494             }
1495             else if ( checkFieldWithDuplicate( xmlStreamReader, "recipientType", null, parsed ) )
1496             {
1497                 projectNotifier.setRecipientType( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "recipientType", xmlStreamReader, strict ) );
1498             }
1499             else if ( checkFieldWithDuplicate( xmlStreamReader, "sendOnSuccess", null, parsed ) )
1500             {
1501                 projectNotifier.setSendOnSuccess( getBooleanValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "true" ) ), "sendOnSuccess", xmlStreamReader ) );
1502             }
1503             else if ( checkFieldWithDuplicate( xmlStreamReader, "sendOnFailure", null, parsed ) )
1504             {
1505                 projectNotifier.setSendOnFailure( getBooleanValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "true" ) ), "sendOnFailure", xmlStreamReader ) );
1506             }
1507             else if ( checkFieldWithDuplicate( xmlStreamReader, "sendOnError", null, parsed ) )
1508             {
1509                 projectNotifier.setSendOnError( getBooleanValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "true" ) ), "sendOnError", xmlStreamReader ) );
1510             }
1511             else if ( checkFieldWithDuplicate( xmlStreamReader, "sendOnWarning", null, parsed ) )
1512             {
1513                 projectNotifier.setSendOnWarning( getBooleanValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "true" ) ), "sendOnWarning", xmlStreamReader ) );
1514             }
1515             else if ( checkFieldWithDuplicate( xmlStreamReader, "configuration", null, parsed ) )
1516             {
1517                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1518                 {
1519                     String key = xmlStreamReader.getLocalName();
1520                     String value = xmlStreamReader.getElementText().trim();
1521                     projectNotifier.addConfiguration( key, value );
1522                 }
1523             }
1524             else
1525             {
1526                 if ( strict )
1527                 {
1528                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1529                 }
1530                 else
1531                 {
1532                     int unrecognizedTagCount = 1;
1533                     while( unrecognizedTagCount != 0 )
1534                     {
1535                         xmlStreamReader.next();
1536                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
1537                         {
1538                             unrecognizedTagCount++;
1539                         }
1540                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
1541                         {
1542                             unrecognizedTagCount--;
1543                         }
1544                     }
1545                 }
1546             }
1547         }
1548         return projectNotifier;
1549     } //-- ProjectNotifier parseProjectNotifier( String, XMLStreamReader, boolean, String )
1550 
1551     /**
1552      * Method parseSchedule.
1553      * 
1554      * @param tagName
1555      * @param encoding
1556      * @param strict
1557      * @param xmlStreamReader
1558      * @throws IOException
1559      * @throws XMLStreamException
1560      * @return Schedule
1561      */
1562     private Schedule parseSchedule( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
1563         throws IOException, XMLStreamException
1564     {
1565         Schedule schedule = new Schedule();
1566         java.util.Set parsed = new java.util.HashSet();
1567         if ( scheduleInstances == null )
1568         {
1569             scheduleInstances = new java.util.HashMap();
1570         }
1571         String v = xmlStreamReader.getAttributeValue( null, "modello.id" );
1572         if ( v != null )
1573         {
1574             scheduleInstances.put( v, schedule );
1575         }
1576         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1577         {
1578             if ( checkFieldWithDuplicate( xmlStreamReader, "id", null, parsed ) )
1579             {
1580                 schedule.setId( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "id", xmlStreamReader, strict ) );
1581             }
1582             else if ( checkFieldWithDuplicate( xmlStreamReader, "active", null, parsed ) )
1583             {
1584                 schedule.setActive( getBooleanValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "false" ) ), "active", xmlStreamReader ) );
1585             }
1586             else if ( checkFieldWithDuplicate( xmlStreamReader, "name", null, parsed ) )
1587             {
1588                 schedule.setName( getTrimmedValue( xmlStreamReader.getElementText() ) );
1589             }
1590             else if ( checkFieldWithDuplicate( xmlStreamReader, "description", null, parsed ) )
1591             {
1592                 schedule.setDescription( getTrimmedValue( xmlStreamReader.getElementText() ) );
1593             }
1594             else if ( checkFieldWithDuplicate( xmlStreamReader, "delay", null, parsed ) )
1595             {
1596                 schedule.setDelay( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "delay", xmlStreamReader, strict ) );
1597             }
1598             else if ( checkFieldWithDuplicate( xmlStreamReader, "maxJobExecutionTime", null, parsed ) )
1599             {
1600                 schedule.setMaxJobExecutionTime( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "3600" ) ), "maxJobExecutionTime", xmlStreamReader, strict ) );
1601             }
1602             else if ( checkFieldWithDuplicate( xmlStreamReader, "cronExpression", null, parsed ) )
1603             {
1604                 schedule.setCronExpression( getTrimmedValue( xmlStreamReader.getElementText() ) );
1605             }
1606             else
1607             {
1608                 if ( strict )
1609                 {
1610                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1611                 }
1612                 else
1613                 {
1614                     int unrecognizedTagCount = 1;
1615                     while( unrecognizedTagCount != 0 )
1616                     {
1617                         xmlStreamReader.next();
1618                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
1619                         {
1620                             unrecognizedTagCount++;
1621                         }
1622                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
1623                         {
1624                             unrecognizedTagCount--;
1625                         }
1626                     }
1627                 }
1628             }
1629         }
1630         scheduleInstances.put( String.valueOf( schedule.getId() ), schedule );
1631         return schedule;
1632     } //-- Schedule parseSchedule( String, XMLStreamReader, boolean, String )
1633 
1634     /**
1635      * Method parseScmResult.
1636      * 
1637      * @param tagName
1638      * @param encoding
1639      * @param strict
1640      * @param xmlStreamReader
1641      * @throws IOException
1642      * @throws XMLStreamException
1643      * @return ScmResult
1644      */
1645     private ScmResult parseScmResult( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
1646         throws IOException, XMLStreamException
1647     {
1648         ScmResult scmResult = new ScmResult();
1649         java.util.Set parsed = new java.util.HashSet();
1650         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1651         {
1652             if ( checkFieldWithDuplicate( xmlStreamReader, "success", null, parsed ) )
1653             {
1654                 scmResult.setSuccess( getBooleanValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "false" ) ), "success", xmlStreamReader ) );
1655             }
1656             else if ( checkFieldWithDuplicate( xmlStreamReader, "commandLine", null, parsed ) )
1657             {
1658                 scmResult.setCommandLine( getTrimmedValue( xmlStreamReader.getElementText() ) );
1659             }
1660             else if ( checkFieldWithDuplicate( xmlStreamReader, "providerMessage", null, parsed ) )
1661             {
1662                 scmResult.setProviderMessage( getTrimmedValue( xmlStreamReader.getElementText() ) );
1663             }
1664             else if ( checkFieldWithDuplicate( xmlStreamReader, "commandOutput", null, parsed ) )
1665             {
1666                 scmResult.setCommandOutput( getTrimmedValue( xmlStreamReader.getElementText() ) );
1667             }
1668             else if ( checkFieldWithDuplicate( xmlStreamReader, "exception", null, parsed ) )
1669             {
1670                 scmResult.setException( getTrimmedValue( xmlStreamReader.getElementText() ) );
1671             }
1672             else if ( checkFieldWithDuplicate( xmlStreamReader, "changes", null, parsed ) )
1673             {
1674                 java.util.List changes = new java.util.ArrayList/*<ChangeSet>*/();
1675                 scmResult.setChanges( changes );
1676                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1677                 {
1678                     if ( xmlStreamReader.getLocalName().equals( "change" ) )
1679                     {
1680                         scmResult.addChange( parseChangeSet( "change", xmlStreamReader, strict, encoding ) );
1681                     }
1682                     else
1683                     {
1684                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1685                     }
1686                 }
1687             }
1688             else
1689             {
1690                 if ( strict )
1691                 {
1692                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1693                 }
1694                 else
1695                 {
1696                     int unrecognizedTagCount = 1;
1697                     while( unrecognizedTagCount != 0 )
1698                     {
1699                         xmlStreamReader.next();
1700                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
1701                         {
1702                             unrecognizedTagCount++;
1703                         }
1704                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
1705                         {
1706                             unrecognizedTagCount--;
1707                         }
1708                     }
1709                 }
1710             }
1711         }
1712         return scmResult;
1713     } //-- ScmResult parseScmResult( String, XMLStreamReader, boolean, String )
1714 
1715     /**
1716      * Method parseSuiteResult.
1717      * 
1718      * @param tagName
1719      * @param encoding
1720      * @param strict
1721      * @param xmlStreamReader
1722      * @throws IOException
1723      * @throws XMLStreamException
1724      * @return SuiteResult
1725      */
1726     private SuiteResult parseSuiteResult( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
1727         throws IOException, XMLStreamException
1728     {
1729         SuiteResult suiteResult = new SuiteResult();
1730         java.util.Set parsed = new java.util.HashSet();
1731         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1732         {
1733             if ( checkFieldWithDuplicate( xmlStreamReader, "name", null, parsed ) )
1734             {
1735                 suiteResult.setName( getTrimmedValue( xmlStreamReader.getElementText() ) );
1736             }
1737             else if ( checkFieldWithDuplicate( xmlStreamReader, "testCount", null, parsed ) )
1738             {
1739                 suiteResult.setTestCount( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "testCount", xmlStreamReader, strict ) );
1740             }
1741             else if ( checkFieldWithDuplicate( xmlStreamReader, "failureCount", null, parsed ) )
1742             {
1743                 suiteResult.setFailureCount( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "failureCount", xmlStreamReader, strict ) );
1744             }
1745             else if ( checkFieldWithDuplicate( xmlStreamReader, "totalTime", null, parsed ) )
1746             {
1747                 suiteResult.setTotalTime( getLongValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "totalTime", xmlStreamReader, strict ) );
1748             }
1749             else if ( checkFieldWithDuplicate( xmlStreamReader, "failures", null, parsed ) )
1750             {
1751                 java.util.List failures = new java.util.ArrayList/*<TestCaseFailure>*/();
1752                 suiteResult.setFailures( failures );
1753                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1754                 {
1755                     if ( xmlStreamReader.getLocalName().equals( "failure" ) )
1756                     {
1757                         suiteResult.addFailure( parseTestCaseFailure( "failure", xmlStreamReader, strict, encoding ) );
1758                     }
1759                     else
1760                     {
1761                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1762                     }
1763                 }
1764             }
1765             else
1766             {
1767                 if ( strict )
1768                 {
1769                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1770                 }
1771                 else
1772                 {
1773                     int unrecognizedTagCount = 1;
1774                     while( unrecognizedTagCount != 0 )
1775                     {
1776                         xmlStreamReader.next();
1777                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
1778                         {
1779                             unrecognizedTagCount++;
1780                         }
1781                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
1782                         {
1783                             unrecognizedTagCount--;
1784                         }
1785                     }
1786                 }
1787             }
1788         }
1789         return suiteResult;
1790     } //-- SuiteResult parseSuiteResult( String, XMLStreamReader, boolean, String )
1791 
1792     /**
1793      * Method parseSystemConfiguration.
1794      * 
1795      * @param tagName
1796      * @param encoding
1797      * @param strict
1798      * @param xmlStreamReader
1799      * @throws IOException
1800      * @throws XMLStreamException
1801      * @return SystemConfiguration
1802      */
1803     private SystemConfiguration parseSystemConfiguration( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
1804         throws IOException, XMLStreamException
1805     {
1806         SystemConfiguration systemConfiguration = new SystemConfiguration();
1807         java.util.Set parsed = new java.util.HashSet();
1808         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1809         {
1810             if ( checkFieldWithDuplicate( xmlStreamReader, "guestAccountEnabled", null, parsed ) )
1811             {
1812                 systemConfiguration.setGuestAccountEnabled( getBooleanValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "true" ) ), "guestAccountEnabled", xmlStreamReader ) );
1813             }
1814             else if ( checkFieldWithDuplicate( xmlStreamReader, "defaultScheduleDescription", null, parsed ) )
1815             {
1816                 systemConfiguration.setDefaultScheduleDescription( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "Run hourly" ) ) );
1817             }
1818             else if ( checkFieldWithDuplicate( xmlStreamReader, "defaultScheduleCronExpression", null, parsed ) )
1819             {
1820                 systemConfiguration.setDefaultScheduleCronExpression( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0 0 * * * ?" ) ) );
1821             }
1822             else if ( checkFieldWithDuplicate( xmlStreamReader, "workingDirectory", null, parsed ) )
1823             {
1824                 systemConfiguration.setWorkingDirectory( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "working-directory" ) ) );
1825             }
1826             else if ( checkFieldWithDuplicate( xmlStreamReader, "buildOutputDirectory", null, parsed ) )
1827             {
1828                 systemConfiguration.setBuildOutputDirectory( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "build-output-directory" ) ) );
1829             }
1830             else if ( checkFieldWithDuplicate( xmlStreamReader, "deploymentRepositoryDirectory", null, parsed ) )
1831             {
1832                 systemConfiguration.setDeploymentRepositoryDirectory( getTrimmedValue( xmlStreamReader.getElementText() ) );
1833             }
1834             else if ( checkFieldWithDuplicate( xmlStreamReader, "baseUrl", null, parsed ) )
1835             {
1836                 systemConfiguration.setBaseUrl( getTrimmedValue( xmlStreamReader.getElementText() ) );
1837             }
1838             else if ( checkFieldWithDuplicate( xmlStreamReader, "initialized", null, parsed ) )
1839             {
1840                 systemConfiguration.setInitialized( getBooleanValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "false" ) ), "initialized", xmlStreamReader ) );
1841             }
1842             else
1843             {
1844                 if ( strict )
1845                 {
1846                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1847                 }
1848                 else
1849                 {
1850                     int unrecognizedTagCount = 1;
1851                     while( unrecognizedTagCount != 0 )
1852                     {
1853                         xmlStreamReader.next();
1854                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
1855                         {
1856                             unrecognizedTagCount++;
1857                         }
1858                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
1859                         {
1860                             unrecognizedTagCount--;
1861                         }
1862                     }
1863                 }
1864             }
1865         }
1866         return systemConfiguration;
1867     } //-- SystemConfiguration parseSystemConfiguration( String, XMLStreamReader, boolean, String )
1868 
1869     /**
1870      * Method parseTestCaseFailure.
1871      * 
1872      * @param tagName
1873      * @param encoding
1874      * @param strict
1875      * @param xmlStreamReader
1876      * @throws IOException
1877      * @throws XMLStreamException
1878      * @return TestCaseFailure
1879      */
1880     private TestCaseFailure parseTestCaseFailure( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
1881         throws IOException, XMLStreamException
1882     {
1883         TestCaseFailure testCaseFailure = new TestCaseFailure();
1884         java.util.Set parsed = new java.util.HashSet();
1885         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1886         {
1887             if ( checkFieldWithDuplicate( xmlStreamReader, "name", null, parsed ) )
1888             {
1889                 testCaseFailure.setName( getTrimmedValue( xmlStreamReader.getElementText() ) );
1890             }
1891             else if ( checkFieldWithDuplicate( xmlStreamReader, "exception", null, parsed ) )
1892             {
1893                 testCaseFailure.setException( getTrimmedValue( xmlStreamReader.getElementText() ) );
1894             }
1895             else
1896             {
1897                 if ( strict )
1898                 {
1899                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1900                 }
1901                 else
1902                 {
1903                     int unrecognizedTagCount = 1;
1904                     while( unrecognizedTagCount != 0 )
1905                     {
1906                         xmlStreamReader.next();
1907                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
1908                         {
1909                             unrecognizedTagCount++;
1910                         }
1911                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
1912                         {
1913                             unrecognizedTagCount--;
1914                         }
1915                     }
1916                 }
1917             }
1918         }
1919         return testCaseFailure;
1920     } //-- TestCaseFailure parseTestCaseFailure( String, XMLStreamReader, boolean, String )
1921 
1922     /**
1923      * Method parseTestResult.
1924      * 
1925      * @param tagName
1926      * @param encoding
1927      * @param strict
1928      * @param xmlStreamReader
1929      * @throws IOException
1930      * @throws XMLStreamException
1931      * @return TestResult
1932      */
1933     private TestResult parseTestResult( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
1934         throws IOException, XMLStreamException
1935     {
1936         TestResult testResult = new TestResult();
1937         java.util.Set parsed = new java.util.HashSet();
1938         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1939         {
1940             if ( checkFieldWithDuplicate( xmlStreamReader, "testCount", null, parsed ) )
1941             {
1942                 testResult.setTestCount( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "testCount", xmlStreamReader, strict ) );
1943             }
1944             else if ( checkFieldWithDuplicate( xmlStreamReader, "failureCount", null, parsed ) )
1945             {
1946                 testResult.setFailureCount( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "failureCount", xmlStreamReader, strict ) );
1947             }
1948             else if ( checkFieldWithDuplicate( xmlStreamReader, "totalTime", null, parsed ) )
1949             {
1950                 testResult.setTotalTime( getLongValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "totalTime", xmlStreamReader, strict ) );
1951             }
1952             else if ( checkFieldWithDuplicate( xmlStreamReader, "suiteResults", null, parsed ) )
1953             {
1954                 java.util.List suiteResults = new java.util.ArrayList/*<SuiteResult>*/();
1955                 testResult.setSuiteResults( suiteResults );
1956                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1957                 {
1958                     if ( xmlStreamReader.getLocalName().equals( "suiteResult" ) )
1959                     {
1960                         testResult.addSuiteResult( parseSuiteResult( "suiteResult", xmlStreamReader, strict, encoding ) );
1961                     }
1962                     else
1963                     {
1964                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1965                     }
1966                 }
1967             }
1968             else
1969             {
1970                 if ( strict )
1971                 {
1972                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1973                 }
1974                 else
1975                 {
1976                     int unrecognizedTagCount = 1;
1977                     while( unrecognizedTagCount != 0 )
1978                     {
1979                         xmlStreamReader.next();
1980                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
1981                         {
1982                             unrecognizedTagCount++;
1983                         }
1984                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
1985                         {
1986                             unrecognizedTagCount--;
1987                         }
1988                     }
1989                 }
1990             }
1991         }
1992         return testResult;
1993     } //-- TestResult parseTestResult( String, XMLStreamReader, boolean, String )
1994 
1995     /**
1996      * Method read.
1997      * 
1998      * @param reader
1999      * @param strict
2000      * @throws IOException
2001      * @throws XMLStreamException
2002      * @return ContinuumDatabase
2003      */
2004     public ContinuumDatabase read( Reader reader, boolean strict )
2005         throws IOException, XMLStreamException
2006     {
2007         XMLStreamReader xmlStreamReader = XMLInputFactory.newInstance().createXMLStreamReader( reader );
2008 
2009         String encoding = xmlStreamReader.getCharacterEncodingScheme();
2010         ContinuumDatabase value = parseContinuumDatabase( "continuumDatabase", xmlStreamReader, strict, encoding );
2011         resolveReferences( value );
2012         return value;
2013     } //-- ContinuumDatabase read( Reader, boolean )
2014 
2015     /**
2016      * Method read.
2017      * 
2018      * @param reader
2019      * @throws IOException
2020      * @throws XMLStreamException
2021      * @return ContinuumDatabase
2022      */
2023     public ContinuumDatabase read( Reader reader )
2024         throws IOException, XMLStreamException
2025     {
2026         return read( reader, true );
2027     } //-- ContinuumDatabase read( Reader )
2028 
2029     /**
2030      * Method read.
2031      * 
2032      * @param filePath
2033      * @param strict
2034      * @throws IOException
2035      * @throws XMLStreamException
2036      * @return ContinuumDatabase
2037      */
2038     public ContinuumDatabase read( String filePath, boolean strict )
2039         throws IOException, XMLStreamException
2040     {
2041         File file = new File(filePath);
2042         XMLStreamReader xmlStreamReader = XMLInputFactory.newInstance().createXMLStreamReader( file.toURL().toExternalForm(), new FileInputStream(file) );
2043 
2044         String encoding = xmlStreamReader.getCharacterEncodingScheme();
2045         ContinuumDatabase value = parseContinuumDatabase( "continuumDatabase", xmlStreamReader, strict, encoding );
2046         resolveReferences( value );
2047         return value;
2048     } //-- ContinuumDatabase read( String, boolean )
2049 
2050     /**
2051      * Method read.
2052      * 
2053      * @param filePath
2054      * @throws IOException
2055      * @throws XMLStreamException
2056      * @return ContinuumDatabase
2057      */
2058     public ContinuumDatabase read( String filePath )
2059         throws IOException, XMLStreamException
2060     {
2061         return read( filePath, true );
2062     } //-- ContinuumDatabase read( String )
2063 
2064     /**
2065      * Method resolveReferences.
2066      * 
2067      * @param value
2068      */
2069     private void resolveReferences( ContinuumDatabase value )
2070     {
2071         java.util.Map refs;
2072         for ( java.util.Iterator i = value.getProjectGroups().iterator(); i.hasNext(); )
2073         {
2074             resolveReferences( (ProjectGroup) i.next() );
2075         }
2076     } //-- void resolveReferences( ContinuumDatabase )
2077 
2078     /**
2079      * Method resolveReferences.
2080      * 
2081      * @param value
2082      */
2083     private void resolveReferences( ProjectGroup value )
2084     {
2085         java.util.Map refs;
2086         for ( java.util.Iterator i = value.getProjects().iterator(); i.hasNext(); )
2087         {
2088             resolveReferences( (Project) i.next() );
2089         }
2090         for ( java.util.Iterator i = value.getBuildDefinitions().iterator(); i.hasNext(); )
2091         {
2092             resolveReferences( (BuildDefinition) i.next() );
2093         }
2094     } //-- void resolveReferences( ProjectGroup )
2095 
2096     /**
2097      * Method resolveReferences.
2098      * 
2099      * @param value
2100      */
2101     private void resolveReferences( BuildDefinition value )
2102     {
2103         java.util.Map refs;
2104         if ( scheduleReferences != null )
2105         {
2106             refs = (java.util.Map) scheduleReferences.get( value );
2107             if ( refs != null )
2108             {
2109                 String id = (String) refs.get( "schedule" );
2110                 Schedule ref = (Schedule) scheduleInstances.get( id );
2111                 if ( ref != null && !ref.equals( value.getSchedule() ) )
2112                 {
2113                     value.setSchedule( ref );
2114                 }
2115             }
2116         }
2117     } //-- void resolveReferences( BuildDefinition )
2118 
2119     /**
2120      * Method resolveReferences.
2121      * 
2122      * @param value
2123      */
2124     private void resolveReferences( Project value )
2125     {
2126         java.util.Map refs;
2127         for ( java.util.Iterator i = value.getBuildResults().iterator(); i.hasNext(); )
2128         {
2129             resolveReferences( (BuildResult) i.next() );
2130         }
2131         if ( projectGroupReferences != null )
2132         {
2133             refs = (java.util.Map) projectGroupReferences.get( value );
2134             if ( refs != null )
2135             {
2136                 String id = (String) refs.get( "projectGroup" );
2137                 ProjectGroup ref = (ProjectGroup) projectGroupInstances.get( id );
2138                 if ( ref != null && !ref.equals( value.getProjectGroup() ) )
2139                 {
2140                     value.setProjectGroup( ref );
2141                 }
2142             }
2143         }
2144         for ( java.util.Iterator i = value.getBuildDefinitions().iterator(); i.hasNext(); )
2145         {
2146             resolveReferences( (BuildDefinition) i.next() );
2147         }
2148     } //-- void resolveReferences( Project )
2149 
2150     /**
2151      * Method resolveReferences.
2152      * 
2153      * @param value
2154      */
2155     private void resolveReferences( BuildResult value )
2156     {
2157         java.util.Map refs;
2158         if ( projectReferences != null )
2159         {
2160             refs = (java.util.Map) projectReferences.get( value );
2161             if ( refs != null )
2162             {
2163                 String id = (String) refs.get( "project" );
2164                 Project ref = (Project) projectInstances.get( id );
2165                 if ( ref != null && !ref.equals( value.getProject() ) )
2166                 {
2167                     value.setProject( ref );
2168                 }
2169             }
2170         }
2171     } //-- void resolveReferences( BuildResult )
2172 
2173 }