View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   // Generated by Modello 1.9.1,
3   // any modifications will be overwritten.
4   // ==============================================================
5   
6   package org.apache.maven.consumer.model.io.xpp3;
7   
8     //---------------------------------/
9    //- Imported classes and packages -/
10  //---------------------------------/
11  
12  import java.io.OutputStream;
13  import java.io.Writer;
14  import java.util.Iterator;
15  import org.apache.maven.consumer.model.Activation;
16  import org.apache.maven.consumer.model.ActivationOS;
17  import org.apache.maven.consumer.model.Contributor;
18  import org.apache.maven.consumer.model.Dependency;
19  import org.apache.maven.consumer.model.Developer;
20  import org.apache.maven.consumer.model.Exclusion;
21  import org.apache.maven.consumer.model.IssueManagement;
22  import org.apache.maven.consumer.model.License;
23  import org.apache.maven.consumer.model.MailingList;
24  import org.apache.maven.consumer.model.Model;
25  import org.apache.maven.consumer.model.ModelBase;
26  import org.apache.maven.consumer.model.Organization;
27  import org.apache.maven.consumer.model.Prerequisites;
28  import org.apache.maven.consumer.model.Profile;
29  import org.apache.maven.consumer.model.Relocation;
30  import org.apache.maven.consumer.model.Repository;
31  import org.apache.maven.consumer.model.RepositoryBase;
32  import org.apache.maven.consumer.model.RepositoryPolicy;
33  import org.apache.maven.consumer.model.Scm;
34  import org.codehaus.plexus.util.xml.pull.MXSerializer;
35  import org.codehaus.plexus.util.xml.pull.XmlSerializer;
36  
37  /**
38   * Class MavenConsumerXpp3Writer.
39   * 
40   * @version $Revision$ $Date$
41   */
42  @SuppressWarnings( "all" )
43  public class MavenConsumerXpp3Writer
44  {
45  
46        //--------------------------/
47       //- Class/Member Variables -/
48      //--------------------------/
49  
50      /**
51       * Field NAMESPACE.
52       */
53      private static final String NAMESPACE = null;
54  
55      /**
56       * Field fileComment.
57       */
58      private String fileComment = null;
59  
60  
61        //-----------/
62       //- Methods -/
63      //-----------/
64  
65      /**
66       * Method setFileComment.
67       * 
68       * @param fileComment
69       */
70      public void setFileComment( String fileComment )
71      {
72          this.fileComment = fileComment;
73      } //-- void setFileComment( String )
74  
75      /**
76       * Method write.
77       * 
78       * @param writer
79       * @param model
80       * @throws java.io.IOException
81       */
82      public void write( Writer writer, Model model )
83          throws java.io.IOException
84      {
85          XmlSerializer serializer = new MXSerializer();
86          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
87          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
88          serializer.setOutput( writer );
89          serializer.startDocument( model.getModelEncoding(), null );
90          writeModel( model, "project", serializer );
91          serializer.endDocument();
92      } //-- void write( Writer, Model )
93  
94      /**
95       * Method write.
96       * 
97       * @param stream
98       * @param model
99       * @throws java.io.IOException
100      */
101     public void write( OutputStream stream, Model model )
102         throws java.io.IOException
103     {
104         XmlSerializer serializer = new MXSerializer();
105         serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
106         serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
107         serializer.setOutput( stream, model.getModelEncoding() );
108         serializer.startDocument( model.getModelEncoding(), null );
109         writeModel( model, "project", serializer );
110         serializer.endDocument();
111     } //-- void write( OutputStream, Model )
112 
113     /**
114      * Method writeActivation.
115      * 
116      * @param activation
117      * @param serializer
118      * @param tagName
119      * @throws java.io.IOException
120      */
121     private void writeActivation( Activation activation, String tagName, XmlSerializer serializer )
122         throws java.io.IOException
123     {
124         serializer.startTag( NAMESPACE, tagName );
125         if ( activation.isActiveByDefault() != false )
126         {
127             serializer.startTag( NAMESPACE, "activeByDefault" ).text( String.valueOf( activation.isActiveByDefault() ) ).endTag( NAMESPACE, "activeByDefault" );
128         }
129         if ( activation.getJdk() != null )
130         {
131             serializer.startTag( NAMESPACE, "jdk" ).text( activation.getJdk() ).endTag( NAMESPACE, "jdk" );
132         }
133         if ( activation.getOs() != null )
134         {
135             writeActivationOS( (ActivationOS) activation.getOs(), "os", serializer );
136         }
137         serializer.endTag( NAMESPACE, tagName );
138     } //-- void writeActivation( Activation, String, XmlSerializer )
139 
140     /**
141      * Method writeActivationOS.
142      * 
143      * @param activationOS
144      * @param serializer
145      * @param tagName
146      * @throws java.io.IOException
147      */
148     private void writeActivationOS( ActivationOS activationOS, String tagName, XmlSerializer serializer )
149         throws java.io.IOException
150     {
151         serializer.startTag( NAMESPACE, tagName );
152         if ( activationOS.getName() != null )
153         {
154             serializer.startTag( NAMESPACE, "name" ).text( activationOS.getName() ).endTag( NAMESPACE, "name" );
155         }
156         if ( activationOS.getFamily() != null )
157         {
158             serializer.startTag( NAMESPACE, "family" ).text( activationOS.getFamily() ).endTag( NAMESPACE, "family" );
159         }
160         if ( activationOS.getArch() != null )
161         {
162             serializer.startTag( NAMESPACE, "arch" ).text( activationOS.getArch() ).endTag( NAMESPACE, "arch" );
163         }
164         if ( activationOS.getVersion() != null )
165         {
166             serializer.startTag( NAMESPACE, "version" ).text( activationOS.getVersion() ).endTag( NAMESPACE, "version" );
167         }
168         serializer.endTag( NAMESPACE, tagName );
169     } //-- void writeActivationOS( ActivationOS, String, XmlSerializer )
170 
171     /**
172      * Method writeContributor.
173      * 
174      * @param contributor
175      * @param serializer
176      * @param tagName
177      * @throws java.io.IOException
178      */
179     private void writeContributor( Contributor contributor, String tagName, XmlSerializer serializer )
180         throws java.io.IOException
181     {
182         serializer.startTag( NAMESPACE, tagName );
183         if ( contributor.getName() != null )
184         {
185             serializer.startTag( NAMESPACE, "name" ).text( contributor.getName() ).endTag( NAMESPACE, "name" );
186         }
187         if ( contributor.getEmail() != null )
188         {
189             serializer.startTag( NAMESPACE, "email" ).text( contributor.getEmail() ).endTag( NAMESPACE, "email" );
190         }
191         if ( contributor.getUrl() != null )
192         {
193             serializer.startTag( NAMESPACE, "url" ).text( contributor.getUrl() ).endTag( NAMESPACE, "url" );
194         }
195         if ( contributor.getOrganization() != null )
196         {
197             serializer.startTag( NAMESPACE, "organization" ).text( contributor.getOrganization() ).endTag( NAMESPACE, "organization" );
198         }
199         if ( contributor.getOrganizationUrl() != null )
200         {
201             serializer.startTag( NAMESPACE, "organizationUrl" ).text( contributor.getOrganizationUrl() ).endTag( NAMESPACE, "organizationUrl" );
202         }
203         if ( ( contributor.getRoles() != null ) && ( contributor.getRoles().size() > 0 ) )
204         {
205             serializer.startTag( NAMESPACE, "roles" );
206             for ( Iterator iter = contributor.getRoles().iterator(); iter.hasNext(); )
207             {
208                 String role = (String) iter.next();
209                 serializer.startTag( NAMESPACE, "role" ).text( role ).endTag( NAMESPACE, "role" );
210             }
211             serializer.endTag( NAMESPACE, "roles" );
212         }
213         if ( contributor.getTimezone() != null )
214         {
215             serializer.startTag( NAMESPACE, "timezone" ).text( contributor.getTimezone() ).endTag( NAMESPACE, "timezone" );
216         }
217         if ( ( contributor.getProperties() != null ) && ( contributor.getProperties().size() > 0 ) )
218         {
219             serializer.startTag( NAMESPACE, "properties" );
220             for ( Iterator iter = contributor.getProperties().keySet().iterator(); iter.hasNext(); )
221             {
222                 String key = (String) iter.next();
223                 String value = (String) contributor.getProperties().get( key );
224                 serializer.startTag( NAMESPACE, "" + key + "" ).text( value ).endTag( NAMESPACE, "" + key + "" );
225             }
226             serializer.endTag( NAMESPACE, "properties" );
227         }
228         serializer.endTag( NAMESPACE, tagName );
229     } //-- void writeContributor( Contributor, String, XmlSerializer )
230 
231     /**
232      * Method writeDependency.
233      * 
234      * @param dependency
235      * @param serializer
236      * @param tagName
237      * @throws java.io.IOException
238      */
239     private void writeDependency( Dependency dependency, String tagName, XmlSerializer serializer )
240         throws java.io.IOException
241     {
242         serializer.startTag( NAMESPACE, tagName );
243         if ( dependency.getGroupId() != null )
244         {
245             serializer.startTag( NAMESPACE, "groupId" ).text( dependency.getGroupId() ).endTag( NAMESPACE, "groupId" );
246         }
247         if ( dependency.getArtifactId() != null )
248         {
249             serializer.startTag( NAMESPACE, "artifactId" ).text( dependency.getArtifactId() ).endTag( NAMESPACE, "artifactId" );
250         }
251         if ( dependency.getVersion() != null )
252         {
253             serializer.startTag( NAMESPACE, "version" ).text( dependency.getVersion() ).endTag( NAMESPACE, "version" );
254         }
255         if ( ( dependency.getType() != null ) && !dependency.getType().equals( "jar" ) )
256         {
257             serializer.startTag( NAMESPACE, "type" ).text( dependency.getType() ).endTag( NAMESPACE, "type" );
258         }
259         if ( dependency.getClassifier() != null )
260         {
261             serializer.startTag( NAMESPACE, "classifier" ).text( dependency.getClassifier() ).endTag( NAMESPACE, "classifier" );
262         }
263         if ( dependency.getScope() != null )
264         {
265             serializer.startTag( NAMESPACE, "scope" ).text( dependency.getScope() ).endTag( NAMESPACE, "scope" );
266         }
267         if ( dependency.getSystemPath() != null )
268         {
269             serializer.startTag( NAMESPACE, "systemPath" ).text( dependency.getSystemPath() ).endTag( NAMESPACE, "systemPath" );
270         }
271         if ( ( dependency.getExclusions() != null ) && ( dependency.getExclusions().size() > 0 ) )
272         {
273             serializer.startTag( NAMESPACE, "exclusions" );
274             for ( Iterator iter = dependency.getExclusions().iterator(); iter.hasNext(); )
275             {
276                 Exclusion o = (Exclusion) iter.next();
277                 writeExclusion( o, "exclusion", serializer );
278             }
279             serializer.endTag( NAMESPACE, "exclusions" );
280         }
281         if ( dependency.getOptional() != null )
282         {
283             serializer.startTag( NAMESPACE, "optional" ).text( dependency.getOptional() ).endTag( NAMESPACE, "optional" );
284         }
285         serializer.endTag( NAMESPACE, tagName );
286     } //-- void writeDependency( Dependency, String, XmlSerializer )
287 
288     /**
289      * Method writeDeveloper.
290      * 
291      * @param developer
292      * @param serializer
293      * @param tagName
294      * @throws java.io.IOException
295      */
296     private void writeDeveloper( Developer developer, String tagName, XmlSerializer serializer )
297         throws java.io.IOException
298     {
299         serializer.startTag( NAMESPACE, tagName );
300         if ( developer.getId() != null )
301         {
302             serializer.startTag( NAMESPACE, "id" ).text( developer.getId() ).endTag( NAMESPACE, "id" );
303         }
304         if ( developer.getName() != null )
305         {
306             serializer.startTag( NAMESPACE, "name" ).text( developer.getName() ).endTag( NAMESPACE, "name" );
307         }
308         if ( developer.getEmail() != null )
309         {
310             serializer.startTag( NAMESPACE, "email" ).text( developer.getEmail() ).endTag( NAMESPACE, "email" );
311         }
312         if ( developer.getUrl() != null )
313         {
314             serializer.startTag( NAMESPACE, "url" ).text( developer.getUrl() ).endTag( NAMESPACE, "url" );
315         }
316         if ( developer.getOrganization() != null )
317         {
318             serializer.startTag( NAMESPACE, "organization" ).text( developer.getOrganization() ).endTag( NAMESPACE, "organization" );
319         }
320         if ( developer.getOrganizationUrl() != null )
321         {
322             serializer.startTag( NAMESPACE, "organizationUrl" ).text( developer.getOrganizationUrl() ).endTag( NAMESPACE, "organizationUrl" );
323         }
324         if ( ( developer.getRoles() != null ) && ( developer.getRoles().size() > 0 ) )
325         {
326             serializer.startTag( NAMESPACE, "roles" );
327             for ( Iterator iter = developer.getRoles().iterator(); iter.hasNext(); )
328             {
329                 String role = (String) iter.next();
330                 serializer.startTag( NAMESPACE, "role" ).text( role ).endTag( NAMESPACE, "role" );
331             }
332             serializer.endTag( NAMESPACE, "roles" );
333         }
334         if ( developer.getTimezone() != null )
335         {
336             serializer.startTag( NAMESPACE, "timezone" ).text( developer.getTimezone() ).endTag( NAMESPACE, "timezone" );
337         }
338         if ( ( developer.getProperties() != null ) && ( developer.getProperties().size() > 0 ) )
339         {
340             serializer.startTag( NAMESPACE, "properties" );
341             for ( Iterator iter = developer.getProperties().keySet().iterator(); iter.hasNext(); )
342             {
343                 String key = (String) iter.next();
344                 String value = (String) developer.getProperties().get( key );
345                 serializer.startTag( NAMESPACE, "" + key + "" ).text( value ).endTag( NAMESPACE, "" + key + "" );
346             }
347             serializer.endTag( NAMESPACE, "properties" );
348         }
349         serializer.endTag( NAMESPACE, tagName );
350     } //-- void writeDeveloper( Developer, String, XmlSerializer )
351 
352     /**
353      * Method writeExclusion.
354      * 
355      * @param exclusion
356      * @param serializer
357      * @param tagName
358      * @throws java.io.IOException
359      */
360     private void writeExclusion( Exclusion exclusion, String tagName, XmlSerializer serializer )
361         throws java.io.IOException
362     {
363         serializer.startTag( NAMESPACE, tagName );
364         if ( exclusion.getArtifactId() != null )
365         {
366             serializer.startTag( NAMESPACE, "artifactId" ).text( exclusion.getArtifactId() ).endTag( NAMESPACE, "artifactId" );
367         }
368         if ( exclusion.getGroupId() != null )
369         {
370             serializer.startTag( NAMESPACE, "groupId" ).text( exclusion.getGroupId() ).endTag( NAMESPACE, "groupId" );
371         }
372         serializer.endTag( NAMESPACE, tagName );
373     } //-- void writeExclusion( Exclusion, String, XmlSerializer )
374 
375     /**
376      * Method writeIssueManagement.
377      * 
378      * @param issueManagement
379      * @param serializer
380      * @param tagName
381      * @throws java.io.IOException
382      */
383     private void writeIssueManagement( IssueManagement issueManagement, String tagName, XmlSerializer serializer )
384         throws java.io.IOException
385     {
386         serializer.startTag( NAMESPACE, tagName );
387         if ( issueManagement.getSystem() != null )
388         {
389             serializer.startTag( NAMESPACE, "system" ).text( issueManagement.getSystem() ).endTag( NAMESPACE, "system" );
390         }
391         if ( issueManagement.getUrl() != null )
392         {
393             serializer.startTag( NAMESPACE, "url" ).text( issueManagement.getUrl() ).endTag( NAMESPACE, "url" );
394         }
395         serializer.endTag( NAMESPACE, tagName );
396     } //-- void writeIssueManagement( IssueManagement, String, XmlSerializer )
397 
398     /**
399      * Method writeLicense.
400      * 
401      * @param license
402      * @param serializer
403      * @param tagName
404      * @throws java.io.IOException
405      */
406     private void writeLicense( License license, String tagName, XmlSerializer serializer )
407         throws java.io.IOException
408     {
409         serializer.startTag( NAMESPACE, tagName );
410         if ( license.getName() != null )
411         {
412             serializer.startTag( NAMESPACE, "name" ).text( license.getName() ).endTag( NAMESPACE, "name" );
413         }
414         if ( license.getUrl() != null )
415         {
416             serializer.startTag( NAMESPACE, "url" ).text( license.getUrl() ).endTag( NAMESPACE, "url" );
417         }
418         if ( license.getDistribution() != null )
419         {
420             serializer.startTag( NAMESPACE, "distribution" ).text( license.getDistribution() ).endTag( NAMESPACE, "distribution" );
421         }
422         if ( license.getComments() != null )
423         {
424             serializer.startTag( NAMESPACE, "comments" ).text( license.getComments() ).endTag( NAMESPACE, "comments" );
425         }
426         serializer.endTag( NAMESPACE, tagName );
427     } //-- void writeLicense( License, String, XmlSerializer )
428 
429     /**
430      * Method writeMailingList.
431      * 
432      * @param mailingList
433      * @param serializer
434      * @param tagName
435      * @throws java.io.IOException
436      */
437     private void writeMailingList( MailingList mailingList, String tagName, XmlSerializer serializer )
438         throws java.io.IOException
439     {
440         serializer.startTag( NAMESPACE, tagName );
441         if ( mailingList.getName() != null )
442         {
443             serializer.startTag( NAMESPACE, "name" ).text( mailingList.getName() ).endTag( NAMESPACE, "name" );
444         }
445         if ( mailingList.getSubscribe() != null )
446         {
447             serializer.startTag( NAMESPACE, "subscribe" ).text( mailingList.getSubscribe() ).endTag( NAMESPACE, "subscribe" );
448         }
449         if ( mailingList.getUnsubscribe() != null )
450         {
451             serializer.startTag( NAMESPACE, "unsubscribe" ).text( mailingList.getUnsubscribe() ).endTag( NAMESPACE, "unsubscribe" );
452         }
453         if ( mailingList.getPost() != null )
454         {
455             serializer.startTag( NAMESPACE, "post" ).text( mailingList.getPost() ).endTag( NAMESPACE, "post" );
456         }
457         if ( mailingList.getArchive() != null )
458         {
459             serializer.startTag( NAMESPACE, "archive" ).text( mailingList.getArchive() ).endTag( NAMESPACE, "archive" );
460         }
461         if ( ( mailingList.getOtherArchives() != null ) && ( mailingList.getOtherArchives().size() > 0 ) )
462         {
463             serializer.startTag( NAMESPACE, "otherArchives" );
464             for ( Iterator iter = mailingList.getOtherArchives().iterator(); iter.hasNext(); )
465             {
466                 String otherArchive = (String) iter.next();
467                 serializer.startTag( NAMESPACE, "otherArchive" ).text( otherArchive ).endTag( NAMESPACE, "otherArchive" );
468             }
469             serializer.endTag( NAMESPACE, "otherArchives" );
470         }
471         serializer.endTag( NAMESPACE, tagName );
472     } //-- void writeMailingList( MailingList, String, XmlSerializer )
473 
474     /**
475      * Method writeModel.
476      * 
477      * @param model
478      * @param serializer
479      * @param tagName
480      * @throws java.io.IOException
481      */
482     private void writeModel( Model model, String tagName, XmlSerializer serializer )
483         throws java.io.IOException
484     {
485         if ( this.fileComment != null )
486         {
487         serializer.comment(this.fileComment);
488         }
489         serializer.setPrefix( "", "http://maven.apache.org/POM/4.0.0" );
490         serializer.setPrefix( "xsi", "http://www.w3.org/2001/XMLSchema-instance" );
491         serializer.startTag( NAMESPACE, tagName );
492         serializer.attribute( "", "xsi:schemaLocation", "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-consumer-4.0.0.xsd" );
493         if ( model.getModelVersion() != null )
494         {
495             serializer.startTag( NAMESPACE, "modelVersion" ).text( model.getModelVersion() ).endTag( NAMESPACE, "modelVersion" );
496         }
497         if ( model.getGroupId() != null )
498         {
499             serializer.startTag( NAMESPACE, "groupId" ).text( model.getGroupId() ).endTag( NAMESPACE, "groupId" );
500         }
501         if ( model.getArtifactId() != null )
502         {
503             serializer.startTag( NAMESPACE, "artifactId" ).text( model.getArtifactId() ).endTag( NAMESPACE, "artifactId" );
504         }
505         if ( model.getVersion() != null )
506         {
507             serializer.startTag( NAMESPACE, "version" ).text( model.getVersion() ).endTag( NAMESPACE, "version" );
508         }
509         if ( ( model.getPackaging() != null ) && !model.getPackaging().equals( "jar" ) )
510         {
511             serializer.startTag( NAMESPACE, "packaging" ).text( model.getPackaging() ).endTag( NAMESPACE, "packaging" );
512         }
513         if ( model.getName() != null )
514         {
515             serializer.startTag( NAMESPACE, "name" ).text( model.getName() ).endTag( NAMESPACE, "name" );
516         }
517         if ( model.getDescription() != null )
518         {
519             serializer.startTag( NAMESPACE, "description" ).text( model.getDescription() ).endTag( NAMESPACE, "description" );
520         }
521         if ( model.getUrl() != null )
522         {
523             serializer.startTag( NAMESPACE, "url" ).text( model.getUrl() ).endTag( NAMESPACE, "url" );
524         }
525         if ( model.getInceptionYear() != null )
526         {
527             serializer.startTag( NAMESPACE, "inceptionYear" ).text( model.getInceptionYear() ).endTag( NAMESPACE, "inceptionYear" );
528         }
529         if ( model.getOrganization() != null )
530         {
531             writeOrganization( (Organization) model.getOrganization(), "organization", serializer );
532         }
533         if ( ( model.getLicenses() != null ) && ( model.getLicenses().size() > 0 ) )
534         {
535             serializer.startTag( NAMESPACE, "licenses" );
536             for ( Iterator iter = model.getLicenses().iterator(); iter.hasNext(); )
537             {
538                 License o = (License) iter.next();
539                 writeLicense( o, "license", serializer );
540             }
541             serializer.endTag( NAMESPACE, "licenses" );
542         }
543         if ( ( model.getDevelopers() != null ) && ( model.getDevelopers().size() > 0 ) )
544         {
545             serializer.startTag( NAMESPACE, "developers" );
546             for ( Iterator iter = model.getDevelopers().iterator(); iter.hasNext(); )
547             {
548                 Developer o = (Developer) iter.next();
549                 writeDeveloper( o, "developer", serializer );
550             }
551             serializer.endTag( NAMESPACE, "developers" );
552         }
553         if ( ( model.getContributors() != null ) && ( model.getContributors().size() > 0 ) )
554         {
555             serializer.startTag( NAMESPACE, "contributors" );
556             for ( Iterator iter = model.getContributors().iterator(); iter.hasNext(); )
557             {
558                 Contributor o = (Contributor) iter.next();
559                 writeContributor( o, "contributor", serializer );
560             }
561             serializer.endTag( NAMESPACE, "contributors" );
562         }
563         if ( ( model.getMailingLists() != null ) && ( model.getMailingLists().size() > 0 ) )
564         {
565             serializer.startTag( NAMESPACE, "mailingLists" );
566             for ( Iterator iter = model.getMailingLists().iterator(); iter.hasNext(); )
567             {
568                 MailingList o = (MailingList) iter.next();
569                 writeMailingList( o, "mailingList", serializer );
570             }
571             serializer.endTag( NAMESPACE, "mailingLists" );
572         }
573         if ( model.getPrerequisites() != null )
574         {
575             writePrerequisites( (Prerequisites) model.getPrerequisites(), "prerequisites", serializer );
576         }
577         if ( model.getScm() != null )
578         {
579             writeScm( (Scm) model.getScm(), "scm", serializer );
580         }
581         if ( model.getIssueManagement() != null )
582         {
583             writeIssueManagement( (IssueManagement) model.getIssueManagement(), "issueManagement", serializer );
584         }
585         if ( ( model.getDependencies() != null ) && ( model.getDependencies().size() > 0 ) )
586         {
587             serializer.startTag( NAMESPACE, "dependencies" );
588             for ( Iterator iter = model.getDependencies().iterator(); iter.hasNext(); )
589             {
590                 Dependency o = (Dependency) iter.next();
591                 writeDependency( o, "dependency", serializer );
592             }
593             serializer.endTag( NAMESPACE, "dependencies" );
594         }
595         if ( ( model.getRepositories() != null ) && ( model.getRepositories().size() > 0 ) )
596         {
597             serializer.startTag( NAMESPACE, "repositories" );
598             for ( Iterator iter = model.getRepositories().iterator(); iter.hasNext(); )
599             {
600                 Repository o = (Repository) iter.next();
601                 writeRepository( o, "repository", serializer );
602             }
603             serializer.endTag( NAMESPACE, "repositories" );
604         }
605         if ( ( model.getProfiles() != null ) && ( model.getProfiles().size() > 0 ) )
606         {
607             serializer.startTag( NAMESPACE, "profiles" );
608             for ( Iterator iter = model.getProfiles().iterator(); iter.hasNext(); )
609             {
610                 Profile o = (Profile) iter.next();
611                 writeProfile( o, "profile", serializer );
612             }
613             serializer.endTag( NAMESPACE, "profiles" );
614         }
615         serializer.endTag( NAMESPACE, tagName );
616     } //-- void writeModel( Model, String, XmlSerializer )
617 
618     /**
619      * Method writeModelBase.
620      * 
621      * @param modelBase
622      * @param serializer
623      * @param tagName
624      * @throws java.io.IOException
625      */
626     private void writeModelBase( ModelBase modelBase, String tagName, XmlSerializer serializer )
627         throws java.io.IOException
628     {
629         serializer.startTag( NAMESPACE, tagName );
630         if ( ( modelBase.getDependencies() != null ) && ( modelBase.getDependencies().size() > 0 ) )
631         {
632             serializer.startTag( NAMESPACE, "dependencies" );
633             for ( Iterator iter = modelBase.getDependencies().iterator(); iter.hasNext(); )
634             {
635                 Dependency o = (Dependency) iter.next();
636                 writeDependency( o, "dependency", serializer );
637             }
638             serializer.endTag( NAMESPACE, "dependencies" );
639         }
640         if ( ( modelBase.getRepositories() != null ) && ( modelBase.getRepositories().size() > 0 ) )
641         {
642             serializer.startTag( NAMESPACE, "repositories" );
643             for ( Iterator iter = modelBase.getRepositories().iterator(); iter.hasNext(); )
644             {
645                 Repository o = (Repository) iter.next();
646                 writeRepository( o, "repository", serializer );
647             }
648             serializer.endTag( NAMESPACE, "repositories" );
649         }
650         serializer.endTag( NAMESPACE, tagName );
651     } //-- void writeModelBase( ModelBase, String, XmlSerializer )
652 
653     /**
654      * Method writeOrganization.
655      * 
656      * @param organization
657      * @param serializer
658      * @param tagName
659      * @throws java.io.IOException
660      */
661     private void writeOrganization( Organization organization, String tagName, XmlSerializer serializer )
662         throws java.io.IOException
663     {
664         serializer.startTag( NAMESPACE, tagName );
665         if ( organization.getName() != null )
666         {
667             serializer.startTag( NAMESPACE, "name" ).text( organization.getName() ).endTag( NAMESPACE, "name" );
668         }
669         if ( organization.getUrl() != null )
670         {
671             serializer.startTag( NAMESPACE, "url" ).text( organization.getUrl() ).endTag( NAMESPACE, "url" );
672         }
673         serializer.endTag( NAMESPACE, tagName );
674     } //-- void writeOrganization( Organization, String, XmlSerializer )
675 
676     /**
677      * Method writePrerequisites.
678      * 
679      * @param prerequisites
680      * @param serializer
681      * @param tagName
682      * @throws java.io.IOException
683      */
684     private void writePrerequisites( Prerequisites prerequisites, String tagName, XmlSerializer serializer )
685         throws java.io.IOException
686     {
687         serializer.startTag( NAMESPACE, tagName );
688         if ( ( prerequisites.getMaven() != null ) && !prerequisites.getMaven().equals( "2.0" ) )
689         {
690             serializer.startTag( NAMESPACE, "maven" ).text( prerequisites.getMaven() ).endTag( NAMESPACE, "maven" );
691         }
692         serializer.endTag( NAMESPACE, tagName );
693     } //-- void writePrerequisites( Prerequisites, String, XmlSerializer )
694 
695     /**
696      * Method writeProfile.
697      * 
698      * @param profile
699      * @param serializer
700      * @param tagName
701      * @throws java.io.IOException
702      */
703     private void writeProfile( Profile profile, String tagName, XmlSerializer serializer )
704         throws java.io.IOException
705     {
706         serializer.startTag( NAMESPACE, tagName );
707         if ( ( profile.getId() != null ) && !profile.getId().equals( "default" ) )
708         {
709             serializer.startTag( NAMESPACE, "id" ).text( profile.getId() ).endTag( NAMESPACE, "id" );
710         }
711         if ( profile.getActivation() != null )
712         {
713             writeActivation( (Activation) profile.getActivation(), "activation", serializer );
714         }
715         if ( ( profile.getDependencies() != null ) && ( profile.getDependencies().size() > 0 ) )
716         {
717             serializer.startTag( NAMESPACE, "dependencies" );
718             for ( Iterator iter = profile.getDependencies().iterator(); iter.hasNext(); )
719             {
720                 Dependency o = (Dependency) iter.next();
721                 writeDependency( o, "dependency", serializer );
722             }
723             serializer.endTag( NAMESPACE, "dependencies" );
724         }
725         if ( ( profile.getRepositories() != null ) && ( profile.getRepositories().size() > 0 ) )
726         {
727             serializer.startTag( NAMESPACE, "repositories" );
728             for ( Iterator iter = profile.getRepositories().iterator(); iter.hasNext(); )
729             {
730                 Repository o = (Repository) iter.next();
731                 writeRepository( o, "repository", serializer );
732             }
733             serializer.endTag( NAMESPACE, "repositories" );
734         }
735         serializer.endTag( NAMESPACE, tagName );
736     } //-- void writeProfile( Profile, String, XmlSerializer )
737 
738     /**
739      * Method writeRelocation.
740      * 
741      * @param relocation
742      * @param serializer
743      * @param tagName
744      * @throws java.io.IOException
745      */
746     private void writeRelocation( Relocation relocation, String tagName, XmlSerializer serializer )
747         throws java.io.IOException
748     {
749         serializer.startTag( NAMESPACE, tagName );
750         if ( relocation.getGroupId() != null )
751         {
752             serializer.startTag( NAMESPACE, "groupId" ).text( relocation.getGroupId() ).endTag( NAMESPACE, "groupId" );
753         }
754         if ( relocation.getArtifactId() != null )
755         {
756             serializer.startTag( NAMESPACE, "artifactId" ).text( relocation.getArtifactId() ).endTag( NAMESPACE, "artifactId" );
757         }
758         if ( relocation.getVersion() != null )
759         {
760             serializer.startTag( NAMESPACE, "version" ).text( relocation.getVersion() ).endTag( NAMESPACE, "version" );
761         }
762         if ( relocation.getMessage() != null )
763         {
764             serializer.startTag( NAMESPACE, "message" ).text( relocation.getMessage() ).endTag( NAMESPACE, "message" );
765         }
766         serializer.endTag( NAMESPACE, tagName );
767     } //-- void writeRelocation( Relocation, String, XmlSerializer )
768 
769     /**
770      * Method writeRepository.
771      * 
772      * @param repository
773      * @param serializer
774      * @param tagName
775      * @throws java.io.IOException
776      */
777     private void writeRepository( Repository repository, String tagName, XmlSerializer serializer )
778         throws java.io.IOException
779     {
780         serializer.startTag( NAMESPACE, tagName );
781         if ( repository.getReleases() != null )
782         {
783             writeRepositoryPolicy( (RepositoryPolicy) repository.getReleases(), "releases", serializer );
784         }
785         if ( repository.getSnapshots() != null )
786         {
787             writeRepositoryPolicy( (RepositoryPolicy) repository.getSnapshots(), "snapshots", serializer );
788         }
789         if ( repository.getId() != null )
790         {
791             serializer.startTag( NAMESPACE, "id" ).text( repository.getId() ).endTag( NAMESPACE, "id" );
792         }
793         if ( repository.getName() != null )
794         {
795             serializer.startTag( NAMESPACE, "name" ).text( repository.getName() ).endTag( NAMESPACE, "name" );
796         }
797         if ( repository.getUrl() != null )
798         {
799             serializer.startTag( NAMESPACE, "url" ).text( repository.getUrl() ).endTag( NAMESPACE, "url" );
800         }
801         if ( ( repository.getLayout() != null ) && !repository.getLayout().equals( "default" ) )
802         {
803             serializer.startTag( NAMESPACE, "layout" ).text( repository.getLayout() ).endTag( NAMESPACE, "layout" );
804         }
805         serializer.endTag( NAMESPACE, tagName );
806     } //-- void writeRepository( Repository, String, XmlSerializer )
807 
808     /**
809      * Method writeRepositoryBase.
810      * 
811      * @param repositoryBase
812      * @param serializer
813      * @param tagName
814      * @throws java.io.IOException
815      */
816     private void writeRepositoryBase( RepositoryBase repositoryBase, String tagName, XmlSerializer serializer )
817         throws java.io.IOException
818     {
819         serializer.startTag( NAMESPACE, tagName );
820         if ( repositoryBase.getId() != null )
821         {
822             serializer.startTag( NAMESPACE, "id" ).text( repositoryBase.getId() ).endTag( NAMESPACE, "id" );
823         }
824         if ( repositoryBase.getName() != null )
825         {
826             serializer.startTag( NAMESPACE, "name" ).text( repositoryBase.getName() ).endTag( NAMESPACE, "name" );
827         }
828         if ( repositoryBase.getUrl() != null )
829         {
830             serializer.startTag( NAMESPACE, "url" ).text( repositoryBase.getUrl() ).endTag( NAMESPACE, "url" );
831         }
832         if ( ( repositoryBase.getLayout() != null ) && !repositoryBase.getLayout().equals( "default" ) )
833         {
834             serializer.startTag( NAMESPACE, "layout" ).text( repositoryBase.getLayout() ).endTag( NAMESPACE, "layout" );
835         }
836         serializer.endTag( NAMESPACE, tagName );
837     } //-- void writeRepositoryBase( RepositoryBase, String, XmlSerializer )
838 
839     /**
840      * Method writeRepositoryPolicy.
841      * 
842      * @param repositoryPolicy
843      * @param serializer
844      * @param tagName
845      * @throws java.io.IOException
846      */
847     private void writeRepositoryPolicy( RepositoryPolicy repositoryPolicy, String tagName, XmlSerializer serializer )
848         throws java.io.IOException
849     {
850         serializer.startTag( NAMESPACE, tagName );
851         if ( repositoryPolicy.getEnabled() != null )
852         {
853             serializer.startTag( NAMESPACE, "enabled" ).text( repositoryPolicy.getEnabled() ).endTag( NAMESPACE, "enabled" );
854         }
855         if ( repositoryPolicy.getUpdatePolicy() != null )
856         {
857             serializer.startTag( NAMESPACE, "updatePolicy" ).text( repositoryPolicy.getUpdatePolicy() ).endTag( NAMESPACE, "updatePolicy" );
858         }
859         if ( repositoryPolicy.getChecksumPolicy() != null )
860         {
861             serializer.startTag( NAMESPACE, "checksumPolicy" ).text( repositoryPolicy.getChecksumPolicy() ).endTag( NAMESPACE, "checksumPolicy" );
862         }
863         serializer.endTag( NAMESPACE, tagName );
864     } //-- void writeRepositoryPolicy( RepositoryPolicy, String, XmlSerializer )
865 
866     /**
867      * Method writeScm.
868      * 
869      * @param scm
870      * @param serializer
871      * @param tagName
872      * @throws java.io.IOException
873      */
874     private void writeScm( Scm scm, String tagName, XmlSerializer serializer )
875         throws java.io.IOException
876     {
877         serializer.startTag( NAMESPACE, tagName );
878         if ( scm.getConnection() != null )
879         {
880             serializer.startTag( NAMESPACE, "connection" ).text( scm.getConnection() ).endTag( NAMESPACE, "connection" );
881         }
882         if ( scm.getDeveloperConnection() != null )
883         {
884             serializer.startTag( NAMESPACE, "developerConnection" ).text( scm.getDeveloperConnection() ).endTag( NAMESPACE, "developerConnection" );
885         }
886         if ( ( scm.getTag() != null ) && !scm.getTag().equals( "HEAD" ) )
887         {
888             serializer.startTag( NAMESPACE, "tag" ).text( scm.getTag() ).endTag( NAMESPACE, "tag" );
889         }
890         if ( scm.getUrl() != null )
891         {
892             serializer.startTag( NAMESPACE, "url" ).text( scm.getUrl() ).endTag( NAMESPACE, "url" );
893         }
894         serializer.endTag( NAMESPACE, tagName );
895     } //-- void writeScm( Scm, String, XmlSerializer )
896 
897 }