View Javadoc

1   /*
2    =================== DO NOT EDIT THIS FILE ====================
3    Generated by Modello
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, "username", null, parsed ) )
666             {
667                 buildResult.setUsername( getTrimmedValue( xmlStreamReader.getElementText() ) );
668             }
669             else if ( checkFieldWithDuplicate( xmlStreamReader, "startTime", null, parsed ) )
670             {
671                 buildResult.setStartTime( getLongValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "startTime", xmlStreamReader, strict ) );
672             }
673             else if ( checkFieldWithDuplicate( xmlStreamReader, "endTime", null, parsed ) )
674             {
675                 buildResult.setEndTime( getLongValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "endTime", xmlStreamReader, strict ) );
676             }
677             else if ( checkFieldWithDuplicate( xmlStreamReader, "error", null, parsed ) )
678             {
679                 buildResult.setError( getTrimmedValue( xmlStreamReader.getElementText() ) );
680             }
681             else if ( checkFieldWithDuplicate( xmlStreamReader, "success", null, parsed ) )
682             {
683                 buildResult.setSuccess( getBooleanValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "false" ) ), "success", xmlStreamReader ) );
684             }
685             else if ( checkFieldWithDuplicate( xmlStreamReader, "exitCode", null, parsed ) )
686             {
687                 buildResult.setExitCode( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "exitCode", xmlStreamReader, strict ) );
688             }
689             else if ( checkFieldWithDuplicate( xmlStreamReader, "scmResult", null, parsed ) )
690             {
691                 buildResult.setScmResult( parseScmResult( "scmResult", xmlStreamReader, strict, encoding ) );
692             }
693             else if ( checkFieldWithDuplicate( xmlStreamReader, "testResult", null, parsed ) )
694             {
695                 buildResult.setTestResult( parseTestResult( "testResult", xmlStreamReader, strict, encoding ) );
696             }
697             else
698             {
699                 if ( strict )
700                 {
701                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
702                 }
703                 else
704                 {
705                     int unrecognizedTagCount = 1;
706                     while( unrecognizedTagCount != 0 )
707                     {
708                         xmlStreamReader.next();
709                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
710                         {
711                             unrecognizedTagCount++;
712                         }
713                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
714                         {
715                             unrecognizedTagCount--;
716                         }
717                     }
718                 }
719             }
720         }
721         return buildResult;
722     } //-- BuildResult parseBuildResult( String, XMLStreamReader, boolean, String )
723 
724     /**
725      * Method parseChangeFile.
726      * 
727      * @param tagName
728      * @param encoding
729      * @param strict
730      * @param xmlStreamReader
731      * @throws IOException
732      * @throws XMLStreamException
733      * @return ChangeFile
734      */
735     private ChangeFile parseChangeFile( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
736         throws IOException, XMLStreamException
737     {
738         ChangeFile changeFile = new ChangeFile();
739         java.util.Set parsed = new java.util.HashSet();
740         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
741         {
742             if ( checkFieldWithDuplicate( xmlStreamReader, "name", null, parsed ) )
743             {
744                 changeFile.setName( getTrimmedValue( xmlStreamReader.getElementText() ) );
745             }
746             else if ( checkFieldWithDuplicate( xmlStreamReader, "revision", null, parsed ) )
747             {
748                 changeFile.setRevision( getTrimmedValue( xmlStreamReader.getElementText() ) );
749             }
750             else if ( checkFieldWithDuplicate( xmlStreamReader, "status", null, parsed ) )
751             {
752                 changeFile.setStatus( getTrimmedValue( xmlStreamReader.getElementText() ) );
753             }
754             else
755             {
756                 if ( strict )
757                 {
758                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
759                 }
760                 else
761                 {
762                     int unrecognizedTagCount = 1;
763                     while( unrecognizedTagCount != 0 )
764                     {
765                         xmlStreamReader.next();
766                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
767                         {
768                             unrecognizedTagCount++;
769                         }
770                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
771                         {
772                             unrecognizedTagCount--;
773                         }
774                     }
775                 }
776             }
777         }
778         return changeFile;
779     } //-- ChangeFile parseChangeFile( String, XMLStreamReader, boolean, String )
780 
781     /**
782      * Method parseChangeSet.
783      * 
784      * @param tagName
785      * @param encoding
786      * @param strict
787      * @param xmlStreamReader
788      * @throws IOException
789      * @throws XMLStreamException
790      * @return ChangeSet
791      */
792     private ChangeSet parseChangeSet( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
793         throws IOException, XMLStreamException
794     {
795         ChangeSet changeSet = new ChangeSet();
796         java.util.Set parsed = new java.util.HashSet();
797         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
798         {
799             if ( checkFieldWithDuplicate( xmlStreamReader, "author", null, parsed ) )
800             {
801                 changeSet.setAuthor( getTrimmedValue( xmlStreamReader.getElementText() ) );
802             }
803             else if ( checkFieldWithDuplicate( xmlStreamReader, "comment", null, parsed ) )
804             {
805                 changeSet.setComment( getTrimmedValue( xmlStreamReader.getElementText() ) );
806             }
807             else if ( checkFieldWithDuplicate( xmlStreamReader, "date", null, parsed ) )
808             {
809                 changeSet.setDate( getLongValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "date", xmlStreamReader, strict ) );
810             }
811             else if ( checkFieldWithDuplicate( xmlStreamReader, "files", null, parsed ) )
812             {
813                 java.util.List files = new java.util.ArrayList/*<ChangeFile>*/();
814                 changeSet.setFiles( files );
815                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
816                 {
817                     if ( xmlStreamReader.getLocalName().equals( "file" ) )
818                     {
819                         changeSet.addFile( parseChangeFile( "file", xmlStreamReader, strict, encoding ) );
820                     }
821                     else
822                     {
823                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
824                     }
825                 }
826             }
827             else
828             {
829                 if ( strict )
830                 {
831                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
832                 }
833                 else
834                 {
835                     int unrecognizedTagCount = 1;
836                     while( unrecognizedTagCount != 0 )
837                     {
838                         xmlStreamReader.next();
839                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
840                         {
841                             unrecognizedTagCount++;
842                         }
843                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
844                         {
845                             unrecognizedTagCount--;
846                         }
847                     }
848                 }
849             }
850         }
851         return changeSet;
852     } //-- ChangeSet parseChangeSet( String, XMLStreamReader, boolean, String )
853 
854     /**
855      * Method parseContinuumDatabase.
856      * 
857      * @param tagName
858      * @param encoding
859      * @param strict
860      * @param xmlStreamReader
861      * @throws IOException
862      * @throws XMLStreamException
863      * @return ContinuumDatabase
864      */
865     private ContinuumDatabase parseContinuumDatabase( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
866         throws IOException, XMLStreamException
867     {
868         ContinuumDatabase continuumDatabase = new ContinuumDatabase();
869         java.util.Set parsed = new java.util.HashSet();
870         continuumDatabase.setModelEncoding( encoding );
871         boolean foundRoot = false;
872         while ( xmlStreamReader.hasNext() )
873         {
874             int eventType = xmlStreamReader.next();
875             if ( eventType == XMLStreamConstants.START_ELEMENT )
876             {
877                 if ( xmlStreamReader.getLocalName().equals( tagName ) )
878                 {
879                     foundRoot = true;
880                 }
881                 else if ( checkFieldWithDuplicate( xmlStreamReader, "projectGroups", null, parsed ) )
882                 {
883                     java.util.List projectGroups = new java.util.ArrayList/*<ProjectGroup>*/();
884                     continuumDatabase.setProjectGroups( projectGroups );
885                     while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
886                     {
887                         if ( xmlStreamReader.getLocalName().equals( "projectGroup" ) )
888                         {
889                             continuumDatabase.addProjectGroup( parseProjectGroup( "projectGroup", xmlStreamReader, strict, encoding ) );
890                         }
891                         else
892                         {
893                             throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
894                         }
895                     }
896                 }
897                 else if ( checkFieldWithDuplicate( xmlStreamReader, "systemConfiguration", null, parsed ) )
898                 {
899                     continuumDatabase.setSystemConfiguration( parseSystemConfiguration( "systemConfiguration", xmlStreamReader, strict, encoding ) );
900                 }
901                 else if ( checkFieldWithDuplicate( xmlStreamReader, "schedules", null, parsed ) )
902                 {
903                     java.util.List schedules = new java.util.ArrayList/*<Schedule>*/();
904                     continuumDatabase.setSchedules( schedules );
905                     while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
906                     {
907                         if ( xmlStreamReader.getLocalName().equals( "schedule" ) )
908                         {
909                             continuumDatabase.addSchedule( parseSchedule( "schedule", xmlStreamReader, strict, encoding ) );
910                         }
911                         else
912                         {
913                             throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
914                         }
915                     }
916                 }
917                 else
918                 {
919                     if ( foundRoot )
920                     {
921                         if ( strict )
922                         {
923                             throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
924                         }
925                     }
926                 }
927             }
928         }
929         return continuumDatabase;
930     } //-- ContinuumDatabase parseContinuumDatabase( String, XMLStreamReader, boolean, String )
931 
932     /**
933      * Method parseNotificationAddress.
934      * 
935      * @param tagName
936      * @param encoding
937      * @param strict
938      * @param xmlStreamReader
939      * @throws IOException
940      * @throws XMLStreamException
941      * @return NotificationAddress
942      */
943     private NotificationAddress parseNotificationAddress( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
944         throws IOException, XMLStreamException
945     {
946         NotificationAddress notificationAddress = new NotificationAddress();
947         java.util.Set parsed = new java.util.HashSet();
948         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
949         {
950             if ( checkFieldWithDuplicate( xmlStreamReader, "type", null, parsed ) )
951             {
952                 notificationAddress.setType( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "mail" ) ) );
953             }
954             else if ( checkFieldWithDuplicate( xmlStreamReader, "address", null, parsed ) )
955             {
956                 notificationAddress.setAddress( getTrimmedValue( xmlStreamReader.getElementText() ) );
957             }
958             else if ( checkFieldWithDuplicate( xmlStreamReader, "configuration", null, parsed ) )
959             {
960                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
961                 {
962                     String key = xmlStreamReader.getLocalName();
963                     String value = xmlStreamReader.getElementText().trim();
964                     notificationAddress.addConfiguration( key, value );
965                 }
966             }
967             else
968             {
969                 if ( strict )
970                 {
971                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
972                 }
973                 else
974                 {
975                     int unrecognizedTagCount = 1;
976                     while( unrecognizedTagCount != 0 )
977                     {
978                         xmlStreamReader.next();
979                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
980                         {
981                             unrecognizedTagCount++;
982                         }
983                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
984                         {
985                             unrecognizedTagCount--;
986                         }
987                     }
988                 }
989             }
990         }
991         return notificationAddress;
992     } //-- NotificationAddress parseNotificationAddress( String, XMLStreamReader, boolean, String )
993 
994     /**
995      * Method parseProject.
996      * 
997      * @param tagName
998      * @param encoding
999      * @param strict
1000      * @param xmlStreamReader
1001      * @throws IOException
1002      * @throws XMLStreamException
1003      * @return Project
1004      */
1005     private Project parseProject( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
1006         throws IOException, XMLStreamException
1007     {
1008         Project project = new Project();
1009         java.util.Set parsed = new java.util.HashSet();
1010         if ( projectInstances == null )
1011         {
1012             projectInstances = new java.util.HashMap();
1013         }
1014         String v = xmlStreamReader.getAttributeValue( null, "modello.id" );
1015         if ( v != null )
1016         {
1017             projectInstances.put( v, project );
1018         }
1019         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1020         {
1021             if ( checkFieldWithDuplicate( xmlStreamReader, "id", null, parsed ) )
1022             {
1023                 project.setId( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "id", xmlStreamReader, strict ) );
1024             }
1025             else if ( checkFieldWithDuplicate( xmlStreamReader, "groupId", null, parsed ) )
1026             {
1027                 project.setGroupId( getTrimmedValue( xmlStreamReader.getElementText() ) );
1028             }
1029             else if ( checkFieldWithDuplicate( xmlStreamReader, "artifactId", null, parsed ) )
1030             {
1031                 project.setArtifactId( getTrimmedValue( xmlStreamReader.getElementText() ) );
1032             }
1033             else if ( checkFieldWithDuplicate( xmlStreamReader, "executorId", null, parsed ) )
1034             {
1035                 project.setExecutorId( getTrimmedValue( xmlStreamReader.getElementText() ) );
1036             }
1037             else if ( checkFieldWithDuplicate( xmlStreamReader, "name", null, parsed ) )
1038             {
1039                 project.setName( getTrimmedValue( xmlStreamReader.getElementText() ) );
1040             }
1041             else if ( checkFieldWithDuplicate( xmlStreamReader, "description", null, parsed ) )
1042             {
1043                 project.setDescription( getTrimmedValue( xmlStreamReader.getElementText() ) );
1044             }
1045             else if ( checkFieldWithDuplicate( xmlStreamReader, "url", null, parsed ) )
1046             {
1047                 project.setUrl( getTrimmedValue( xmlStreamReader.getElementText() ) );
1048             }
1049             else if ( checkFieldWithDuplicate( xmlStreamReader, "scmUrl", null, parsed ) )
1050             {
1051                 project.setScmUrl( getTrimmedValue( xmlStreamReader.getElementText() ) );
1052             }
1053             else if ( checkFieldWithDuplicate( xmlStreamReader, "scmTag", null, parsed ) )
1054             {
1055                 project.setScmTag( getTrimmedValue( xmlStreamReader.getElementText() ) );
1056             }
1057             else if ( checkFieldWithDuplicate( xmlStreamReader, "scmUsername", null, parsed ) )
1058             {
1059                 project.setScmUsername( getTrimmedValue( xmlStreamReader.getElementText() ) );
1060             }
1061             else if ( checkFieldWithDuplicate( xmlStreamReader, "scmPassword", null, parsed ) )
1062             {
1063                 project.setScmPassword( getTrimmedValue( xmlStreamReader.getElementText() ) );
1064             }
1065             else if ( checkFieldWithDuplicate( xmlStreamReader, "version", null, parsed ) )
1066             {
1067                 project.setVersion( getTrimmedValue( xmlStreamReader.getElementText() ) );
1068             }
1069             else if ( checkFieldWithDuplicate( xmlStreamReader, "state", null, parsed ) )
1070             {
1071                 project.setState( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "1" ) ), "state", xmlStreamReader, strict ) );
1072             }
1073             else if ( checkFieldWithDuplicate( xmlStreamReader, "oldState", null, parsed ) )
1074             {
1075                 project.setOldState( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "oldState", xmlStreamReader, strict ) );
1076             }
1077             else if ( checkFieldWithDuplicate( xmlStreamReader, "latestBuildId", null, parsed ) )
1078             {
1079                 project.setLatestBuildId( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "latestBuildId", xmlStreamReader, strict ) );
1080             }
1081             else if ( checkFieldWithDuplicate( xmlStreamReader, "buildNumber", null, parsed ) )
1082             {
1083                 project.setBuildNumber( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "buildNumber", xmlStreamReader, strict ) );
1084             }
1085             else if ( checkFieldWithDuplicate( xmlStreamReader, "workingDirectory", null, parsed ) )
1086             {
1087                 project.setWorkingDirectory( getTrimmedValue( xmlStreamReader.getElementText() ) );
1088             }
1089             else if ( checkFieldWithDuplicate( xmlStreamReader, "buildResults", null, parsed ) )
1090             {
1091                 java.util.List buildResults = new java.util.ArrayList/*<BuildResult>*/();
1092                 project.setBuildResults( buildResults );
1093                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1094                 {
1095                     if ( xmlStreamReader.getLocalName().equals( "buildResult" ) )
1096                     {
1097                         project.addBuildResult( parseBuildResult( "buildResult", xmlStreamReader, strict, encoding ) );
1098                     }
1099                     else
1100                     {
1101                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1102                     }
1103                 }
1104             }
1105             else if ( checkFieldWithDuplicate( xmlStreamReader, "checkoutResult", null, parsed ) )
1106             {
1107                 project.setCheckoutResult( parseScmResult( "checkoutResult", xmlStreamReader, strict, encoding ) );
1108             }
1109             else if ( checkFieldWithDuplicate( xmlStreamReader, "developers", null, parsed ) )
1110             {
1111                 java.util.List developers = new java.util.ArrayList/*<ProjectDeveloper>*/();
1112                 project.setDevelopers( developers );
1113                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1114                 {
1115                     if ( xmlStreamReader.getLocalName().equals( "developer" ) )
1116                     {
1117                         project.addDeveloper( parseProjectDeveloper( "developer", xmlStreamReader, strict, encoding ) );
1118                     }
1119                     else
1120                     {
1121                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1122                     }
1123                 }
1124             }
1125             else if ( checkFieldWithDuplicate( xmlStreamReader, "parent", null, parsed ) )
1126             {
1127                 project.setParent( parseProjectDependency( "parent", xmlStreamReader, strict, encoding ) );
1128             }
1129             else if ( checkFieldWithDuplicate( xmlStreamReader, "dependencies", null, parsed ) )
1130             {
1131                 java.util.List dependencies = new java.util.ArrayList/*<ProjectDependency>*/();
1132                 project.setDependencies( dependencies );
1133                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1134                 {
1135                     if ( xmlStreamReader.getLocalName().equals( "dependency" ) )
1136                     {
1137                         project.addDependency( parseProjectDependency( "dependency", xmlStreamReader, strict, encoding ) );
1138                     }
1139                     else
1140                     {
1141                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1142                     }
1143                 }
1144             }
1145             else if ( checkFieldWithDuplicate( xmlStreamReader, "projectGroup", null, parsed ) )
1146             {
1147                 String value = xmlStreamReader.getAttributeValue( null, "id" );
1148                 if ( value != null )
1149                 {
1150                     // This is a reference to an element elsewhere in the model
1151                     if ( projectGroupReferences == null )
1152                     {
1153                         projectGroupReferences = new java.util.HashMap();
1154                     }
1155                     java.util.Map refs = (java.util.Map) projectGroupReferences.get( project );
1156                     if ( refs == null )
1157                     {
1158                         refs = new java.util.HashMap();
1159                         projectGroupReferences.put( project, refs );
1160                     }
1161                     refs.put( "projectGroup", value );
1162                 }
1163                 while ( xmlStreamReader.getEventType() != XMLStreamConstants.END_ELEMENT )
1164                 {
1165                     xmlStreamReader.next();
1166                 }
1167             }
1168             else if ( checkFieldWithDuplicate( xmlStreamReader, "notifiers", null, parsed ) )
1169             {
1170                 java.util.List notifiers = new java.util.ArrayList/*<ProjectNotifier>*/();
1171                 project.setNotifiers( notifiers );
1172                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1173                 {
1174                     if ( xmlStreamReader.getLocalName().equals( "notifier" ) )
1175                     {
1176                         project.addNotifier( parseProjectNotifier( "notifier", xmlStreamReader, strict, encoding ) );
1177                     }
1178                     else
1179                     {
1180                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1181                     }
1182                 }
1183             }
1184             else if ( checkFieldWithDuplicate( xmlStreamReader, "buildDefinitions", null, parsed ) )
1185             {
1186                 java.util.List buildDefinitions = new java.util.ArrayList/*<BuildDefinition>*/();
1187                 project.setBuildDefinitions( buildDefinitions );
1188                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1189                 {
1190                     if ( xmlStreamReader.getLocalName().equals( "buildDefinition" ) )
1191                     {
1192                         project.addBuildDefinition( parseBuildDefinition( "buildDefinition", xmlStreamReader, strict, encoding ) );
1193                     }
1194                     else
1195                     {
1196                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1197                     }
1198                 }
1199             }
1200             else
1201             {
1202                 if ( strict )
1203                 {
1204                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1205                 }
1206                 else
1207                 {
1208                     int unrecognizedTagCount = 1;
1209                     while( unrecognizedTagCount != 0 )
1210                     {
1211                         xmlStreamReader.next();
1212                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
1213                         {
1214                             unrecognizedTagCount++;
1215                         }
1216                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
1217                         {
1218                             unrecognizedTagCount--;
1219                         }
1220                     }
1221                 }
1222             }
1223         }
1224         projectInstances.put( String.valueOf( project.getId() ), project );
1225         return project;
1226     } //-- Project parseProject( String, XMLStreamReader, boolean, String )
1227 
1228     /**
1229      * Method parseProjectDependency.
1230      * 
1231      * @param tagName
1232      * @param encoding
1233      * @param strict
1234      * @param xmlStreamReader
1235      * @throws IOException
1236      * @throws XMLStreamException
1237      * @return ProjectDependency
1238      */
1239     private ProjectDependency parseProjectDependency( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
1240         throws IOException, XMLStreamException
1241     {
1242         ProjectDependency projectDependency = new ProjectDependency();
1243         java.util.Set parsed = new java.util.HashSet();
1244         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1245         {
1246             if ( checkFieldWithDuplicate( xmlStreamReader, "groupId", null, parsed ) )
1247             {
1248                 projectDependency.setGroupId( getTrimmedValue( xmlStreamReader.getElementText() ) );
1249             }
1250             else if ( checkFieldWithDuplicate( xmlStreamReader, "artifactId", null, parsed ) )
1251             {
1252                 projectDependency.setArtifactId( getTrimmedValue( xmlStreamReader.getElementText() ) );
1253             }
1254             else if ( checkFieldWithDuplicate( xmlStreamReader, "version", null, parsed ) )
1255             {
1256                 projectDependency.setVersion( getTrimmedValue( xmlStreamReader.getElementText() ) );
1257             }
1258             else
1259             {
1260                 if ( strict )
1261                 {
1262                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1263                 }
1264                 else
1265                 {
1266                     int unrecognizedTagCount = 1;
1267                     while( unrecognizedTagCount != 0 )
1268                     {
1269                         xmlStreamReader.next();
1270                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
1271                         {
1272                             unrecognizedTagCount++;
1273                         }
1274                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
1275                         {
1276                             unrecognizedTagCount--;
1277                         }
1278                     }
1279                 }
1280             }
1281         }
1282         return projectDependency;
1283     } //-- ProjectDependency parseProjectDependency( String, XMLStreamReader, boolean, String )
1284 
1285     /**
1286      * Method parseProjectDeveloper.
1287      * 
1288      * @param tagName
1289      * @param encoding
1290      * @param strict
1291      * @param xmlStreamReader
1292      * @throws IOException
1293      * @throws XMLStreamException
1294      * @return ProjectDeveloper
1295      */
1296     private ProjectDeveloper parseProjectDeveloper( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
1297         throws IOException, XMLStreamException
1298     {
1299         ProjectDeveloper projectDeveloper = new ProjectDeveloper();
1300         java.util.Set parsed = new java.util.HashSet();
1301         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1302         {
1303             if ( checkFieldWithDuplicate( xmlStreamReader, "scmId", null, parsed ) )
1304             {
1305                 projectDeveloper.setScmId( getTrimmedValue( xmlStreamReader.getElementText() ) );
1306             }
1307             else if ( checkFieldWithDuplicate( xmlStreamReader, "name", null, parsed ) )
1308             {
1309                 projectDeveloper.setName( getTrimmedValue( xmlStreamReader.getElementText() ) );
1310             }
1311             else if ( checkFieldWithDuplicate( xmlStreamReader, "email", null, parsed ) )
1312             {
1313                 projectDeveloper.setEmail( getTrimmedValue( xmlStreamReader.getElementText() ) );
1314             }
1315             else if ( checkFieldWithDuplicate( xmlStreamReader, "continuumId", null, parsed ) )
1316             {
1317                 projectDeveloper.setContinuumId( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "continuumId", xmlStreamReader, strict ) );
1318             }
1319             else
1320             {
1321                 if ( strict )
1322                 {
1323                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1324                 }
1325                 else
1326                 {
1327                     int unrecognizedTagCount = 1;
1328                     while( unrecognizedTagCount != 0 )
1329                     {
1330                         xmlStreamReader.next();
1331                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
1332                         {
1333                             unrecognizedTagCount++;
1334                         }
1335                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
1336                         {
1337                             unrecognizedTagCount--;
1338                         }
1339                     }
1340                 }
1341             }
1342         }
1343         return projectDeveloper;
1344     } //-- ProjectDeveloper parseProjectDeveloper( String, XMLStreamReader, boolean, String )
1345 
1346     /**
1347      * Method parseProjectGroup.
1348      * 
1349      * @param tagName
1350      * @param encoding
1351      * @param strict
1352      * @param xmlStreamReader
1353      * @throws IOException
1354      * @throws XMLStreamException
1355      * @return ProjectGroup
1356      */
1357     private ProjectGroup parseProjectGroup( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
1358         throws IOException, XMLStreamException
1359     {
1360         ProjectGroup projectGroup = new ProjectGroup();
1361         java.util.Set parsed = new java.util.HashSet();
1362         if ( projectGroupInstances == null )
1363         {
1364             projectGroupInstances = new java.util.HashMap();
1365         }
1366         String v = xmlStreamReader.getAttributeValue( null, "modello.id" );
1367         if ( v != null )
1368         {
1369             projectGroupInstances.put( v, projectGroup );
1370         }
1371         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1372         {
1373             if ( checkFieldWithDuplicate( xmlStreamReader, "id", null, parsed ) )
1374             {
1375                 projectGroup.setId( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "id", xmlStreamReader, strict ) );
1376             }
1377             else if ( checkFieldWithDuplicate( xmlStreamReader, "groupId", null, parsed ) )
1378             {
1379                 projectGroup.setGroupId( getTrimmedValue( xmlStreamReader.getElementText() ) );
1380             }
1381             else if ( checkFieldWithDuplicate( xmlStreamReader, "name", null, parsed ) )
1382             {
1383                 projectGroup.setName( getTrimmedValue( xmlStreamReader.getElementText() ) );
1384             }
1385             else if ( checkFieldWithDuplicate( xmlStreamReader, "description", null, parsed ) )
1386             {
1387                 projectGroup.setDescription( getTrimmedValue( xmlStreamReader.getElementText() ) );
1388             }
1389             else if ( checkFieldWithDuplicate( xmlStreamReader, "projects", null, parsed ) )
1390             {
1391                 java.util.List projects = new java.util.ArrayList/*<Project>*/();
1392                 projectGroup.setProjects( projects );
1393                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1394                 {
1395                     if ( xmlStreamReader.getLocalName().equals( "project" ) )
1396                     {
1397                         projectGroup.addProject( parseProject( "project", xmlStreamReader, strict, encoding ) );
1398                     }
1399                     else
1400                     {
1401                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1402                     }
1403                 }
1404             }
1405             else if ( checkFieldWithDuplicate( xmlStreamReader, "notifiers", null, parsed ) )
1406             {
1407                 java.util.List notifiers = new java.util.ArrayList/*<ProjectNotifier>*/();
1408                 projectGroup.setNotifiers( notifiers );
1409                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1410                 {
1411                     if ( xmlStreamReader.getLocalName().equals( "notifier" ) )
1412                     {
1413                         projectGroup.addNotifier( parseProjectNotifier( "notifier", xmlStreamReader, strict, encoding ) );
1414                     }
1415                     else
1416                     {
1417                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1418                     }
1419                 }
1420             }
1421             else if ( checkFieldWithDuplicate( xmlStreamReader, "buildDefinitions", null, parsed ) )
1422             {
1423                 java.util.List buildDefinitions = new java.util.ArrayList/*<BuildDefinition>*/();
1424                 projectGroup.setBuildDefinitions( buildDefinitions );
1425                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1426                 {
1427                     if ( xmlStreamReader.getLocalName().equals( "buildDefinition" ) )
1428                     {
1429                         projectGroup.addBuildDefinition( parseBuildDefinition( "buildDefinition", xmlStreamReader, strict, encoding ) );
1430                     }
1431                     else
1432                     {
1433                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1434                     }
1435                 }
1436             }
1437             else
1438             {
1439                 if ( strict )
1440                 {
1441                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1442                 }
1443                 else
1444                 {
1445                     int unrecognizedTagCount = 1;
1446                     while( unrecognizedTagCount != 0 )
1447                     {
1448                         xmlStreamReader.next();
1449                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
1450                         {
1451                             unrecognizedTagCount++;
1452                         }
1453                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
1454                         {
1455                             unrecognizedTagCount--;
1456                         }
1457                     }
1458                 }
1459             }
1460         }
1461         projectGroupInstances.put( String.valueOf( projectGroup.getId() ), projectGroup );
1462         return projectGroup;
1463     } //-- ProjectGroup parseProjectGroup( String, XMLStreamReader, boolean, String )
1464 
1465     /**
1466      * Method parseProjectNotifier.
1467      * 
1468      * @param tagName
1469      * @param encoding
1470      * @param strict
1471      * @param xmlStreamReader
1472      * @throws IOException
1473      * @throws XMLStreamException
1474      * @return ProjectNotifier
1475      */
1476     private ProjectNotifier parseProjectNotifier( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
1477         throws IOException, XMLStreamException
1478     {
1479         ProjectNotifier projectNotifier = new ProjectNotifier();
1480         java.util.Set parsed = new java.util.HashSet();
1481         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1482         {
1483             if ( checkFieldWithDuplicate( xmlStreamReader, "id", null, parsed ) )
1484             {
1485                 projectNotifier.setId( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "id", xmlStreamReader, strict ) );
1486             }
1487             else if ( checkFieldWithDuplicate( xmlStreamReader, "type", null, parsed ) )
1488             {
1489                 projectNotifier.setType( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "mail" ) ) );
1490             }
1491             else if ( checkFieldWithDuplicate( xmlStreamReader, "from", null, parsed ) )
1492             {
1493                 projectNotifier.setFrom( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "from", xmlStreamReader, strict ) );
1494             }
1495             else if ( checkFieldWithDuplicate( xmlStreamReader, "enabled", null, parsed ) )
1496             {
1497                 projectNotifier.setEnabled( getBooleanValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "true" ) ), "enabled", xmlStreamReader ) );
1498             }
1499             else if ( checkFieldWithDuplicate( xmlStreamReader, "recipientType", null, parsed ) )
1500             {
1501                 projectNotifier.setRecipientType( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "recipientType", xmlStreamReader, strict ) );
1502             }
1503             else if ( checkFieldWithDuplicate( xmlStreamReader, "sendOnSuccess", null, parsed ) )
1504             {
1505                 projectNotifier.setSendOnSuccess( getBooleanValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "true" ) ), "sendOnSuccess", xmlStreamReader ) );
1506             }
1507             else if ( checkFieldWithDuplicate( xmlStreamReader, "sendOnFailure", null, parsed ) )
1508             {
1509                 projectNotifier.setSendOnFailure( getBooleanValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "true" ) ), "sendOnFailure", xmlStreamReader ) );
1510             }
1511             else if ( checkFieldWithDuplicate( xmlStreamReader, "sendOnError", null, parsed ) )
1512             {
1513                 projectNotifier.setSendOnError( getBooleanValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "true" ) ), "sendOnError", xmlStreamReader ) );
1514             }
1515             else if ( checkFieldWithDuplicate( xmlStreamReader, "sendOnWarning", null, parsed ) )
1516             {
1517                 projectNotifier.setSendOnWarning( getBooleanValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "true" ) ), "sendOnWarning", xmlStreamReader ) );
1518             }
1519             else if ( checkFieldWithDuplicate( xmlStreamReader, "configuration", null, parsed ) )
1520             {
1521                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1522                 {
1523                     String key = xmlStreamReader.getLocalName();
1524                     String value = xmlStreamReader.getElementText().trim();
1525                     projectNotifier.addConfiguration( key, value );
1526                 }
1527             }
1528             else
1529             {
1530                 if ( strict )
1531                 {
1532                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1533                 }
1534                 else
1535                 {
1536                     int unrecognizedTagCount = 1;
1537                     while( unrecognizedTagCount != 0 )
1538                     {
1539                         xmlStreamReader.next();
1540                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
1541                         {
1542                             unrecognizedTagCount++;
1543                         }
1544                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
1545                         {
1546                             unrecognizedTagCount--;
1547                         }
1548                     }
1549                 }
1550             }
1551         }
1552         return projectNotifier;
1553     } //-- ProjectNotifier parseProjectNotifier( String, XMLStreamReader, boolean, String )
1554 
1555     /**
1556      * Method parseSchedule.
1557      * 
1558      * @param tagName
1559      * @param encoding
1560      * @param strict
1561      * @param xmlStreamReader
1562      * @throws IOException
1563      * @throws XMLStreamException
1564      * @return Schedule
1565      */
1566     private Schedule parseSchedule( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
1567         throws IOException, XMLStreamException
1568     {
1569         Schedule schedule = new Schedule();
1570         java.util.Set parsed = new java.util.HashSet();
1571         if ( scheduleInstances == null )
1572         {
1573             scheduleInstances = new java.util.HashMap();
1574         }
1575         String v = xmlStreamReader.getAttributeValue( null, "modello.id" );
1576         if ( v != null )
1577         {
1578             scheduleInstances.put( v, schedule );
1579         }
1580         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1581         {
1582             if ( checkFieldWithDuplicate( xmlStreamReader, "id", null, parsed ) )
1583             {
1584                 schedule.setId( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "id", xmlStreamReader, strict ) );
1585             }
1586             else if ( checkFieldWithDuplicate( xmlStreamReader, "active", null, parsed ) )
1587             {
1588                 schedule.setActive( getBooleanValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "false" ) ), "active", xmlStreamReader ) );
1589             }
1590             else if ( checkFieldWithDuplicate( xmlStreamReader, "name", null, parsed ) )
1591             {
1592                 schedule.setName( getTrimmedValue( xmlStreamReader.getElementText() ) );
1593             }
1594             else if ( checkFieldWithDuplicate( xmlStreamReader, "description", null, parsed ) )
1595             {
1596                 schedule.setDescription( getTrimmedValue( xmlStreamReader.getElementText() ) );
1597             }
1598             else if ( checkFieldWithDuplicate( xmlStreamReader, "delay", null, parsed ) )
1599             {
1600                 schedule.setDelay( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "delay", xmlStreamReader, strict ) );
1601             }
1602             else if ( checkFieldWithDuplicate( xmlStreamReader, "maxJobExecutionTime", null, parsed ) )
1603             {
1604                 schedule.setMaxJobExecutionTime( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "3600" ) ), "maxJobExecutionTime", xmlStreamReader, strict ) );
1605             }
1606             else if ( checkFieldWithDuplicate( xmlStreamReader, "cronExpression", null, parsed ) )
1607             {
1608                 schedule.setCronExpression( getTrimmedValue( xmlStreamReader.getElementText() ) );
1609             }
1610             else
1611             {
1612                 if ( strict )
1613                 {
1614                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1615                 }
1616                 else
1617                 {
1618                     int unrecognizedTagCount = 1;
1619                     while( unrecognizedTagCount != 0 )
1620                     {
1621                         xmlStreamReader.next();
1622                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
1623                         {
1624                             unrecognizedTagCount++;
1625                         }
1626                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
1627                         {
1628                             unrecognizedTagCount--;
1629                         }
1630                     }
1631                 }
1632             }
1633         }
1634         scheduleInstances.put( String.valueOf( schedule.getId() ), schedule );
1635         return schedule;
1636     } //-- Schedule parseSchedule( String, XMLStreamReader, boolean, String )
1637 
1638     /**
1639      * Method parseScmResult.
1640      * 
1641      * @param tagName
1642      * @param encoding
1643      * @param strict
1644      * @param xmlStreamReader
1645      * @throws IOException
1646      * @throws XMLStreamException
1647      * @return ScmResult
1648      */
1649     private ScmResult parseScmResult( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
1650         throws IOException, XMLStreamException
1651     {
1652         ScmResult scmResult = new ScmResult();
1653         java.util.Set parsed = new java.util.HashSet();
1654         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1655         {
1656             if ( checkFieldWithDuplicate( xmlStreamReader, "success", null, parsed ) )
1657             {
1658                 scmResult.setSuccess( getBooleanValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "false" ) ), "success", xmlStreamReader ) );
1659             }
1660             else if ( checkFieldWithDuplicate( xmlStreamReader, "commandLine", null, parsed ) )
1661             {
1662                 scmResult.setCommandLine( getTrimmedValue( xmlStreamReader.getElementText() ) );
1663             }
1664             else if ( checkFieldWithDuplicate( xmlStreamReader, "providerMessage", null, parsed ) )
1665             {
1666                 scmResult.setProviderMessage( getTrimmedValue( xmlStreamReader.getElementText() ) );
1667             }
1668             else if ( checkFieldWithDuplicate( xmlStreamReader, "commandOutput", null, parsed ) )
1669             {
1670                 scmResult.setCommandOutput( getTrimmedValue( xmlStreamReader.getElementText() ) );
1671             }
1672             else if ( checkFieldWithDuplicate( xmlStreamReader, "exception", null, parsed ) )
1673             {
1674                 scmResult.setException( getTrimmedValue( xmlStreamReader.getElementText() ) );
1675             }
1676             else if ( checkFieldWithDuplicate( xmlStreamReader, "changes", null, parsed ) )
1677             {
1678                 java.util.List changes = new java.util.ArrayList/*<ChangeSet>*/();
1679                 scmResult.setChanges( changes );
1680                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1681                 {
1682                     if ( xmlStreamReader.getLocalName().equals( "change" ) )
1683                     {
1684                         scmResult.addChange( parseChangeSet( "change", xmlStreamReader, strict, encoding ) );
1685                     }
1686                     else
1687                     {
1688                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1689                     }
1690                 }
1691             }
1692             else
1693             {
1694                 if ( strict )
1695                 {
1696                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1697                 }
1698                 else
1699                 {
1700                     int unrecognizedTagCount = 1;
1701                     while( unrecognizedTagCount != 0 )
1702                     {
1703                         xmlStreamReader.next();
1704                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
1705                         {
1706                             unrecognizedTagCount++;
1707                         }
1708                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
1709                         {
1710                             unrecognizedTagCount--;
1711                         }
1712                     }
1713                 }
1714             }
1715         }
1716         return scmResult;
1717     } //-- ScmResult parseScmResult( String, XMLStreamReader, boolean, String )
1718 
1719     /**
1720      * Method parseSuiteResult.
1721      * 
1722      * @param tagName
1723      * @param encoding
1724      * @param strict
1725      * @param xmlStreamReader
1726      * @throws IOException
1727      * @throws XMLStreamException
1728      * @return SuiteResult
1729      */
1730     private SuiteResult parseSuiteResult( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
1731         throws IOException, XMLStreamException
1732     {
1733         SuiteResult suiteResult = new SuiteResult();
1734         java.util.Set parsed = new java.util.HashSet();
1735         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1736         {
1737             if ( checkFieldWithDuplicate( xmlStreamReader, "name", null, parsed ) )
1738             {
1739                 suiteResult.setName( getTrimmedValue( xmlStreamReader.getElementText() ) );
1740             }
1741             else if ( checkFieldWithDuplicate( xmlStreamReader, "testCount", null, parsed ) )
1742             {
1743                 suiteResult.setTestCount( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "testCount", xmlStreamReader, strict ) );
1744             }
1745             else if ( checkFieldWithDuplicate( xmlStreamReader, "failureCount", null, parsed ) )
1746             {
1747                 suiteResult.setFailureCount( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "failureCount", xmlStreamReader, strict ) );
1748             }
1749             else if ( checkFieldWithDuplicate( xmlStreamReader, "totalTime", null, parsed ) )
1750             {
1751                 suiteResult.setTotalTime( getLongValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "totalTime", xmlStreamReader, strict ) );
1752             }
1753             else if ( checkFieldWithDuplicate( xmlStreamReader, "failures", null, parsed ) )
1754             {
1755                 java.util.List failures = new java.util.ArrayList/*<TestCaseFailure>*/();
1756                 suiteResult.setFailures( failures );
1757                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1758                 {
1759                     if ( xmlStreamReader.getLocalName().equals( "failure" ) )
1760                     {
1761                         suiteResult.addFailure( parseTestCaseFailure( "failure", xmlStreamReader, strict, encoding ) );
1762                     }
1763                     else
1764                     {
1765                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1766                     }
1767                 }
1768             }
1769             else
1770             {
1771                 if ( strict )
1772                 {
1773                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1774                 }
1775                 else
1776                 {
1777                     int unrecognizedTagCount = 1;
1778                     while( unrecognizedTagCount != 0 )
1779                     {
1780                         xmlStreamReader.next();
1781                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
1782                         {
1783                             unrecognizedTagCount++;
1784                         }
1785                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
1786                         {
1787                             unrecognizedTagCount--;
1788                         }
1789                     }
1790                 }
1791             }
1792         }
1793         return suiteResult;
1794     } //-- SuiteResult parseSuiteResult( String, XMLStreamReader, boolean, String )
1795 
1796     /**
1797      * Method parseSystemConfiguration.
1798      * 
1799      * @param tagName
1800      * @param encoding
1801      * @param strict
1802      * @param xmlStreamReader
1803      * @throws IOException
1804      * @throws XMLStreamException
1805      * @return SystemConfiguration
1806      */
1807     private SystemConfiguration parseSystemConfiguration( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
1808         throws IOException, XMLStreamException
1809     {
1810         SystemConfiguration systemConfiguration = new SystemConfiguration();
1811         java.util.Set parsed = new java.util.HashSet();
1812         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1813         {
1814             if ( checkFieldWithDuplicate( xmlStreamReader, "guestAccountEnabled", null, parsed ) )
1815             {
1816                 systemConfiguration.setGuestAccountEnabled( getBooleanValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "true" ) ), "guestAccountEnabled", xmlStreamReader ) );
1817             }
1818             else if ( checkFieldWithDuplicate( xmlStreamReader, "defaultScheduleDescription", null, parsed ) )
1819             {
1820                 systemConfiguration.setDefaultScheduleDescription( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "Run hourly" ) ) );
1821             }
1822             else if ( checkFieldWithDuplicate( xmlStreamReader, "defaultScheduleCronExpression", null, parsed ) )
1823             {
1824                 systemConfiguration.setDefaultScheduleCronExpression( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0 0 * * * ?" ) ) );
1825             }
1826             else if ( checkFieldWithDuplicate( xmlStreamReader, "workingDirectory", null, parsed ) )
1827             {
1828                 systemConfiguration.setWorkingDirectory( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "working-directory" ) ) );
1829             }
1830             else if ( checkFieldWithDuplicate( xmlStreamReader, "buildOutputDirectory", null, parsed ) )
1831             {
1832                 systemConfiguration.setBuildOutputDirectory( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "build-output-directory" ) ) );
1833             }
1834             else if ( checkFieldWithDuplicate( xmlStreamReader, "deploymentRepositoryDirectory", null, parsed ) )
1835             {
1836                 systemConfiguration.setDeploymentRepositoryDirectory( getTrimmedValue( xmlStreamReader.getElementText() ) );
1837             }
1838             else if ( checkFieldWithDuplicate( xmlStreamReader, "baseUrl", null, parsed ) )
1839             {
1840                 systemConfiguration.setBaseUrl( getTrimmedValue( xmlStreamReader.getElementText() ) );
1841             }
1842             else if ( checkFieldWithDuplicate( xmlStreamReader, "initialized", null, parsed ) )
1843             {
1844                 systemConfiguration.setInitialized( getBooleanValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "false" ) ), "initialized", xmlStreamReader ) );
1845             }
1846             else
1847             {
1848                 if ( strict )
1849                 {
1850                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1851                 }
1852                 else
1853                 {
1854                     int unrecognizedTagCount = 1;
1855                     while( unrecognizedTagCount != 0 )
1856                     {
1857                         xmlStreamReader.next();
1858                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
1859                         {
1860                             unrecognizedTagCount++;
1861                         }
1862                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
1863                         {
1864                             unrecognizedTagCount--;
1865                         }
1866                     }
1867                 }
1868             }
1869         }
1870         return systemConfiguration;
1871     } //-- SystemConfiguration parseSystemConfiguration( String, XMLStreamReader, boolean, String )
1872 
1873     /**
1874      * Method parseTestCaseFailure.
1875      * 
1876      * @param tagName
1877      * @param encoding
1878      * @param strict
1879      * @param xmlStreamReader
1880      * @throws IOException
1881      * @throws XMLStreamException
1882      * @return TestCaseFailure
1883      */
1884     private TestCaseFailure parseTestCaseFailure( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
1885         throws IOException, XMLStreamException
1886     {
1887         TestCaseFailure testCaseFailure = new TestCaseFailure();
1888         java.util.Set parsed = new java.util.HashSet();
1889         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1890         {
1891             if ( checkFieldWithDuplicate( xmlStreamReader, "name", null, parsed ) )
1892             {
1893                 testCaseFailure.setName( getTrimmedValue( xmlStreamReader.getElementText() ) );
1894             }
1895             else if ( checkFieldWithDuplicate( xmlStreamReader, "exception", null, parsed ) )
1896             {
1897                 testCaseFailure.setException( getTrimmedValue( xmlStreamReader.getElementText() ) );
1898             }
1899             else
1900             {
1901                 if ( strict )
1902                 {
1903                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1904                 }
1905                 else
1906                 {
1907                     int unrecognizedTagCount = 1;
1908                     while( unrecognizedTagCount != 0 )
1909                     {
1910                         xmlStreamReader.next();
1911                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
1912                         {
1913                             unrecognizedTagCount++;
1914                         }
1915                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
1916                         {
1917                             unrecognizedTagCount--;
1918                         }
1919                     }
1920                 }
1921             }
1922         }
1923         return testCaseFailure;
1924     } //-- TestCaseFailure parseTestCaseFailure( String, XMLStreamReader, boolean, String )
1925 
1926     /**
1927      * Method parseTestResult.
1928      * 
1929      * @param tagName
1930      * @param encoding
1931      * @param strict
1932      * @param xmlStreamReader
1933      * @throws IOException
1934      * @throws XMLStreamException
1935      * @return TestResult
1936      */
1937     private TestResult parseTestResult( String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding )
1938         throws IOException, XMLStreamException
1939     {
1940         TestResult testResult = new TestResult();
1941         java.util.Set parsed = new java.util.HashSet();
1942         while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1943         {
1944             if ( checkFieldWithDuplicate( xmlStreamReader, "testCount", null, parsed ) )
1945             {
1946                 testResult.setTestCount( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "testCount", xmlStreamReader, strict ) );
1947             }
1948             else if ( checkFieldWithDuplicate( xmlStreamReader, "failureCount", null, parsed ) )
1949             {
1950                 testResult.setFailureCount( getIntegerValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "failureCount", xmlStreamReader, strict ) );
1951             }
1952             else if ( checkFieldWithDuplicate( xmlStreamReader, "totalTime", null, parsed ) )
1953             {
1954                 testResult.setTotalTime( getLongValue( getTrimmedValue( getDefaultValue( xmlStreamReader.getElementText(), "0" ) ), "totalTime", xmlStreamReader, strict ) );
1955             }
1956             else if ( checkFieldWithDuplicate( xmlStreamReader, "suiteResults", null, parsed ) )
1957             {
1958                 java.util.List suiteResults = new java.util.ArrayList/*<SuiteResult>*/();
1959                 testResult.setSuiteResults( suiteResults );
1960                 while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
1961                 {
1962                     if ( xmlStreamReader.getLocalName().equals( "suiteResult" ) )
1963                     {
1964                         testResult.addSuiteResult( parseSuiteResult( "suiteResult", xmlStreamReader, strict, encoding ) );
1965                     }
1966                     else
1967                     {
1968                         throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1969                     }
1970                 }
1971             }
1972             else
1973             {
1974                 if ( strict )
1975                 {
1976                     throw new XMLStreamException( "Unrecognised tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
1977                 }
1978                 else
1979                 {
1980                     int unrecognizedTagCount = 1;
1981                     while( unrecognizedTagCount != 0 )
1982                     {
1983                         xmlStreamReader.next();
1984                         if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )
1985                         {
1986                             unrecognizedTagCount++;
1987                         }
1988                         else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )
1989                         {
1990                             unrecognizedTagCount--;
1991                         }
1992                     }
1993                 }
1994             }
1995         }
1996         return testResult;
1997     } //-- TestResult parseTestResult( String, XMLStreamReader, boolean, String )
1998 
1999     /**
2000      * Method read.
2001      * 
2002      * @param reader
2003      * @param strict
2004      * @throws IOException
2005      * @throws XMLStreamException
2006      * @return ContinuumDatabase
2007      */
2008     public ContinuumDatabase read( Reader reader, boolean strict )
2009         throws IOException, XMLStreamException
2010     {
2011         XMLStreamReader xmlStreamReader = XMLInputFactory.newInstance().createXMLStreamReader( reader );
2012 
2013         String encoding = xmlStreamReader.getCharacterEncodingScheme();
2014         ContinuumDatabase value = parseContinuumDatabase( "continuumDatabase", xmlStreamReader, strict, encoding );
2015         resolveReferences( value );
2016         return value;
2017     } //-- ContinuumDatabase read( Reader, boolean )
2018 
2019     /**
2020      * Method read.
2021      * 
2022      * @param reader
2023      * @throws IOException
2024      * @throws XMLStreamException
2025      * @return ContinuumDatabase
2026      */
2027     public ContinuumDatabase read( Reader reader )
2028         throws IOException, XMLStreamException
2029     {
2030         return read( reader, true );
2031     } //-- ContinuumDatabase read( Reader )
2032 
2033     /**
2034      * Method read.
2035      * 
2036      * @param filePath
2037      * @param strict
2038      * @throws IOException
2039      * @throws XMLStreamException
2040      * @return ContinuumDatabase
2041      */
2042     public ContinuumDatabase read( String filePath, boolean strict )
2043         throws IOException, XMLStreamException
2044     {
2045         File file = new File(filePath);
2046         XMLStreamReader xmlStreamReader = XMLInputFactory.newInstance().createXMLStreamReader( file.toURL().toExternalForm(), new FileInputStream(file) );
2047 
2048         String encoding = xmlStreamReader.getCharacterEncodingScheme();
2049         ContinuumDatabase value = parseContinuumDatabase( "continuumDatabase", xmlStreamReader, strict, encoding );
2050         resolveReferences( value );
2051         return value;
2052     } //-- ContinuumDatabase read( String, boolean )
2053 
2054     /**
2055      * Method read.
2056      * 
2057      * @param filePath
2058      * @throws IOException
2059      * @throws XMLStreamException
2060      * @return ContinuumDatabase
2061      */
2062     public ContinuumDatabase read( String filePath )
2063         throws IOException, XMLStreamException
2064     {
2065         return read( filePath, true );
2066     } //-- ContinuumDatabase read( String )
2067 
2068     /**
2069      * Method resolveReferences.
2070      * 
2071      * @param value
2072      */
2073     private void resolveReferences( ContinuumDatabase value )
2074     {
2075         java.util.Map refs;
2076         for ( java.util.Iterator i = value.getProjectGroups().iterator(); i.hasNext(); )
2077         {
2078             resolveReferences( (ProjectGroup) i.next() );
2079         }
2080     } //-- void resolveReferences( ContinuumDatabase )
2081 
2082     /**
2083      * Method resolveReferences.
2084      * 
2085      * @param value
2086      */
2087     private void resolveReferences( ProjectGroup value )
2088     {
2089         java.util.Map refs;
2090         for ( java.util.Iterator i = value.getProjects().iterator(); i.hasNext(); )
2091         {
2092             resolveReferences( (Project) i.next() );
2093         }
2094         for ( java.util.Iterator i = value.getBuildDefinitions().iterator(); i.hasNext(); )
2095         {
2096             resolveReferences( (BuildDefinition) i.next() );
2097         }
2098     } //-- void resolveReferences( ProjectGroup )
2099 
2100     /**
2101      * Method resolveReferences.
2102      * 
2103      * @param value
2104      */
2105     private void resolveReferences( BuildDefinition value )
2106     {
2107         java.util.Map refs;
2108         if ( scheduleReferences != null )
2109         {
2110             refs = (java.util.Map) scheduleReferences.get( value );
2111             if ( refs != null )
2112             {
2113                 String id = (String) refs.get( "schedule" );
2114                 Schedule ref = (Schedule) scheduleInstances.get( id );
2115                 if ( ref != null && !ref.equals( value.getSchedule() ) )
2116                 {
2117                     value.setSchedule( ref );
2118                 }
2119             }
2120         }
2121     } //-- void resolveReferences( BuildDefinition )
2122 
2123     /**
2124      * Method resolveReferences.
2125      * 
2126      * @param value
2127      */
2128     private void resolveReferences( Project value )
2129     {
2130         java.util.Map refs;
2131         for ( java.util.Iterator i = value.getBuildResults().iterator(); i.hasNext(); )
2132         {
2133             resolveReferences( (BuildResult) i.next() );
2134         }
2135         if ( projectGroupReferences != null )
2136         {
2137             refs = (java.util.Map) projectGroupReferences.get( value );
2138             if ( refs != null )
2139             {
2140                 String id = (String) refs.get( "projectGroup" );
2141                 ProjectGroup ref = (ProjectGroup) projectGroupInstances.get( id );
2142                 if ( ref != null && !ref.equals( value.getProjectGroup() ) )
2143                 {
2144                     value.setProjectGroup( ref );
2145                 }
2146             }
2147         }
2148         for ( java.util.Iterator i = value.getBuildDefinitions().iterator(); i.hasNext(); )
2149         {
2150             resolveReferences( (BuildDefinition) i.next() );
2151         }
2152     } //-- void resolveReferences( Project )
2153 
2154     /**
2155      * Method resolveReferences.
2156      * 
2157      * @param value
2158      */
2159     private void resolveReferences( BuildResult value )
2160     {
2161         java.util.Map refs;
2162         if ( projectReferences != null )
2163         {
2164             refs = (java.util.Map) projectReferences.get( value );
2165             if ( refs != null )
2166             {
2167                 String id = (String) refs.get( "project" );
2168                 Project ref = (Project) projectInstances.get( id );
2169                 if ( ref != null && !ref.equals( value.getProject() ) )
2170                 {
2171                     value.setProject( ref );
2172                 }
2173             }
2174         }
2175     } //-- void resolveReferences( BuildResult )
2176 
2177 }