View Javadoc

1   /*
2    =================== DO NOT EDIT THIS FILE ====================
3    Generated by Modello 1.4.1 on 2013-06-25 18:20:17,
4    any modifications will be overwritten.
5    ==============================================================
6    */
7   
8   package org.apache.maven.plugin.javadoc.options.io.xpp3;
9   
10    //---------------------------------/
11   //- Imported classes and packages -/
12  //---------------------------------/
13  
14  import java.io.OutputStream;
15  import java.io.Writer;
16  import java.text.DateFormat;
17  import java.util.Iterator;
18  import java.util.Locale;
19  import org.apache.maven.plugin.javadoc.options.BootclasspathArtifact;
20  import org.apache.maven.plugin.javadoc.options.DocletArtifact;
21  import org.apache.maven.plugin.javadoc.options.Group;
22  import org.apache.maven.plugin.javadoc.options.JavadocOptions;
23  import org.apache.maven.plugin.javadoc.options.JavadocPathArtifact;
24  import org.apache.maven.plugin.javadoc.options.OfflineLink;
25  import org.apache.maven.plugin.javadoc.options.ResourcesArtifact;
26  import org.apache.maven.plugin.javadoc.options.Tag;
27  import org.apache.maven.plugin.javadoc.options.Taglet;
28  import org.apache.maven.plugin.javadoc.options.TagletArtifact;
29  import org.codehaus.plexus.util.xml.pull.MXSerializer;
30  import org.codehaus.plexus.util.xml.pull.XmlSerializer;
31  
32  /**
33   * Class JavadocOptionsXpp3Writer.
34   * 
35   * @version $Revision: 867347 $ $Date: 2013-06-25 08:23:16 +0000 (Tue, 25 Jun 2013) $
36   */
37  @SuppressWarnings( "all" )
38  public class JavadocOptionsXpp3Writer
39  {
40  
41        //--------------------------/
42       //- Class/Member Variables -/
43      //--------------------------/
44  
45      /**
46       * Field NAMESPACE.
47       */
48      private static final String NAMESPACE = null;
49  
50  
51        //-----------/
52       //- Methods -/
53      //-----------/
54  
55      /**
56       * Method write.
57       * 
58       * @param writer
59       * @param javadocOptions
60       * @throws java.io.IOException
61       */
62      public void write( Writer writer, JavadocOptions javadocOptions )
63          throws java.io.IOException
64      {
65          XmlSerializer serializer = new MXSerializer();
66          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
67          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
68          serializer.setOutput( writer );
69          serializer.startDocument( javadocOptions.getModelEncoding(), null );
70          writeJavadocOptions( javadocOptions, "javadocOptions", serializer );
71          serializer.endDocument();
72      } //-- void write( Writer, JavadocOptions )
73  
74      /**
75       * Method write.
76       * 
77       * @param stream
78       * @param javadocOptions
79       * @throws java.io.IOException
80       */
81      public void write( OutputStream stream, JavadocOptions javadocOptions )
82          throws java.io.IOException
83      {
84          XmlSerializer serializer = new MXSerializer();
85          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
86          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
87          serializer.setOutput( stream, javadocOptions.getModelEncoding() );
88          serializer.startDocument( javadocOptions.getModelEncoding(), null );
89          writeJavadocOptions( javadocOptions, "javadocOptions", serializer );
90          serializer.endDocument();
91      } //-- void write( OutputStream, JavadocOptions )
92  
93      /**
94       * Method writeBootclasspathArtifact.
95       * 
96       * @param bootclasspathArtifact
97       * @param serializer
98       * @param tagName
99       * @throws java.io.IOException
100      */
101     private void writeBootclasspathArtifact( BootclasspathArtifact bootclasspathArtifact, String tagName, XmlSerializer serializer )
102         throws java.io.IOException
103     {
104         serializer.startTag( NAMESPACE, tagName );
105         if ( bootclasspathArtifact.getGroupId() != null )
106         {
107             serializer.startTag( NAMESPACE, "groupId" ).text( bootclasspathArtifact.getGroupId() ).endTag( NAMESPACE, "groupId" );
108         }
109         if ( bootclasspathArtifact.getArtifactId() != null )
110         {
111             serializer.startTag( NAMESPACE, "artifactId" ).text( bootclasspathArtifact.getArtifactId() ).endTag( NAMESPACE, "artifactId" );
112         }
113         if ( bootclasspathArtifact.getVersion() != null )
114         {
115             serializer.startTag( NAMESPACE, "version" ).text( bootclasspathArtifact.getVersion() ).endTag( NAMESPACE, "version" );
116         }
117         serializer.endTag( NAMESPACE, tagName );
118     } //-- void writeBootclasspathArtifact( BootclasspathArtifact, String, XmlSerializer )
119 
120     /**
121      * Method writeDocletArtifact.
122      * 
123      * @param docletArtifact
124      * @param serializer
125      * @param tagName
126      * @throws java.io.IOException
127      */
128     private void writeDocletArtifact( DocletArtifact docletArtifact, String tagName, XmlSerializer serializer )
129         throws java.io.IOException
130     {
131         serializer.startTag( NAMESPACE, tagName );
132         if ( docletArtifact.getGroupId() != null )
133         {
134             serializer.startTag( NAMESPACE, "groupId" ).text( docletArtifact.getGroupId() ).endTag( NAMESPACE, "groupId" );
135         }
136         if ( docletArtifact.getArtifactId() != null )
137         {
138             serializer.startTag( NAMESPACE, "artifactId" ).text( docletArtifact.getArtifactId() ).endTag( NAMESPACE, "artifactId" );
139         }
140         if ( docletArtifact.getVersion() != null )
141         {
142             serializer.startTag( NAMESPACE, "version" ).text( docletArtifact.getVersion() ).endTag( NAMESPACE, "version" );
143         }
144         serializer.endTag( NAMESPACE, tagName );
145     } //-- void writeDocletArtifact( DocletArtifact, String, XmlSerializer )
146 
147     /**
148      * Method writeGroup.
149      * 
150      * @param group
151      * @param serializer
152      * @param tagName
153      * @throws java.io.IOException
154      */
155     private void writeGroup( Group group, String tagName, XmlSerializer serializer )
156         throws java.io.IOException
157     {
158         serializer.startTag( NAMESPACE, tagName );
159         if ( group.getTitle() != null )
160         {
161             serializer.startTag( NAMESPACE, "title" ).text( group.getTitle() ).endTag( NAMESPACE, "title" );
162         }
163         if ( group.getPackages() != null )
164         {
165             serializer.startTag( NAMESPACE, "packages" ).text( group.getPackages() ).endTag( NAMESPACE, "packages" );
166         }
167         serializer.endTag( NAMESPACE, tagName );
168     } //-- void writeGroup( Group, String, XmlSerializer )
169 
170     /**
171      * Method writeJavadocOptions.
172      * 
173      * @param javadocOptions
174      * @param serializer
175      * @param tagName
176      * @throws java.io.IOException
177      */
178     private void writeJavadocOptions( JavadocOptions javadocOptions, String tagName, XmlSerializer serializer )
179         throws java.io.IOException
180     {
181         serializer.startTag( NAMESPACE, tagName );
182         if ( ( javadocOptions.getGroups() != null ) && ( javadocOptions.getGroups().size() > 0 ) )
183         {
184             serializer.startTag( NAMESPACE, "groups" );
185             for ( Iterator iter = javadocOptions.getGroups().iterator(); iter.hasNext(); )
186             {
187                 Group o = (Group) iter.next();
188                 writeGroup( o, "group", serializer );
189             }
190             serializer.endTag( NAMESPACE, "groups" );
191         }
192         if ( ( javadocOptions.getTags() != null ) && ( javadocOptions.getTags().size() > 0 ) )
193         {
194             serializer.startTag( NAMESPACE, "tags" );
195             for ( Iterator iter = javadocOptions.getTags().iterator(); iter.hasNext(); )
196             {
197                 Tag o = (Tag) iter.next();
198                 writeTag( o, "tag", serializer );
199             }
200             serializer.endTag( NAMESPACE, "tags" );
201         }
202         if ( ( javadocOptions.getDocletArtifacts() != null ) && ( javadocOptions.getDocletArtifacts().size() > 0 ) )
203         {
204             serializer.startTag( NAMESPACE, "docletArtifacts" );
205             for ( Iterator iter = javadocOptions.getDocletArtifacts().iterator(); iter.hasNext(); )
206             {
207                 DocletArtifact o = (DocletArtifact) iter.next();
208                 writeDocletArtifact( o, "docletArtifact", serializer );
209             }
210             serializer.endTag( NAMESPACE, "docletArtifacts" );
211         }
212         if ( ( javadocOptions.getTaglets() != null ) && ( javadocOptions.getTaglets().size() > 0 ) )
213         {
214             serializer.startTag( NAMESPACE, "taglets" );
215             for ( Iterator iter = javadocOptions.getTaglets().iterator(); iter.hasNext(); )
216             {
217                 Taglet o = (Taglet) iter.next();
218                 writeTaglet( o, "taglet", serializer );
219             }
220             serializer.endTag( NAMESPACE, "taglets" );
221         }
222         if ( ( javadocOptions.getOfflineLinks() != null ) && ( javadocOptions.getOfflineLinks().size() > 0 ) )
223         {
224             serializer.startTag( NAMESPACE, "offlineLinks" );
225             for ( Iterator iter = javadocOptions.getOfflineLinks().iterator(); iter.hasNext(); )
226             {
227                 OfflineLink o = (OfflineLink) iter.next();
228                 writeOfflineLink( o, "offlineLink", serializer );
229             }
230             serializer.endTag( NAMESPACE, "offlineLinks" );
231         }
232         if ( ( javadocOptions.getTagletArtifacts() != null ) && ( javadocOptions.getTagletArtifacts().size() > 0 ) )
233         {
234             serializer.startTag( NAMESPACE, "tagletArtifacts" );
235             for ( Iterator iter = javadocOptions.getTagletArtifacts().iterator(); iter.hasNext(); )
236             {
237                 TagletArtifact o = (TagletArtifact) iter.next();
238                 writeTagletArtifact( o, "tagletArtifact", serializer );
239             }
240             serializer.endTag( NAMESPACE, "tagletArtifacts" );
241         }
242         if ( ( javadocOptions.getResourcesArtifacts() != null ) && ( javadocOptions.getResourcesArtifacts().size() > 0 ) )
243         {
244             serializer.startTag( NAMESPACE, "resourcesArtifacts" );
245             for ( Iterator iter = javadocOptions.getResourcesArtifacts().iterator(); iter.hasNext(); )
246             {
247                 ResourcesArtifact o = (ResourcesArtifact) iter.next();
248                 writeResourcesArtifact( o, "resourcesArtifact", serializer );
249             }
250             serializer.endTag( NAMESPACE, "resourcesArtifacts" );
251         }
252         if ( ( javadocOptions.getBootclasspathArtifacts() != null ) && ( javadocOptions.getBootclasspathArtifacts().size() > 0 ) )
253         {
254             serializer.startTag( NAMESPACE, "bootclasspathArtifacts" );
255             for ( Iterator iter = javadocOptions.getBootclasspathArtifacts().iterator(); iter.hasNext(); )
256             {
257                 BootclasspathArtifact o = (BootclasspathArtifact) iter.next();
258                 writeBootclasspathArtifact( o, "bootclasspathArtifact", serializer );
259             }
260             serializer.endTag( NAMESPACE, "bootclasspathArtifacts" );
261         }
262         if ( ( javadocOptions.getLinks() != null ) && ( javadocOptions.getLinks().size() > 0 ) )
263         {
264             serializer.startTag( NAMESPACE, "links" );
265             for ( Iterator iter = javadocOptions.getLinks().iterator(); iter.hasNext(); )
266             {
267                 String link = (String) iter.next();
268                 serializer.startTag( NAMESPACE, "link" ).text( link ).endTag( NAMESPACE, "link" );
269             }
270             serializer.endTag( NAMESPACE, "links" );
271         }
272         if ( ( javadocOptions.getExcludePackageNames() != null ) && ( javadocOptions.getExcludePackageNames().size() > 0 ) )
273         {
274             serializer.startTag( NAMESPACE, "excludePackageNames" );
275             for ( Iterator iter = javadocOptions.getExcludePackageNames().iterator(); iter.hasNext(); )
276             {
277                 String excludePackageName = (String) iter.next();
278                 serializer.startTag( NAMESPACE, "excludePackageName" ).text( excludePackageName ).endTag( NAMESPACE, "excludePackageName" );
279             }
280             serializer.endTag( NAMESPACE, "excludePackageNames" );
281         }
282         if ( javadocOptions.isDocfilesSubdirsUsed() != false )
283         {
284             serializer.startTag( NAMESPACE, "docfilesSubdirsUsed" ).text( String.valueOf( javadocOptions.isDocfilesSubdirsUsed() ) ).endTag( NAMESPACE, "docfilesSubdirsUsed" );
285         }
286         if ( javadocOptions.getExcludedDocfilesSubdirs() != null )
287         {
288             serializer.startTag( NAMESPACE, "excludedDocfilesSubdirs" ).text( javadocOptions.getExcludedDocfilesSubdirs() ).endTag( NAMESPACE, "excludedDocfilesSubdirs" );
289         }
290         if ( javadocOptions.getJavadocResourcesDirectory() != null )
291         {
292             serializer.startTag( NAMESPACE, "javadocResourcesDirectory" ).text( javadocOptions.getJavadocResourcesDirectory() ).endTag( NAMESPACE, "javadocResourcesDirectory" );
293         }
294         serializer.endTag( NAMESPACE, tagName );
295     } //-- void writeJavadocOptions( JavadocOptions, String, XmlSerializer )
296 
297     /**
298      * Method writeJavadocPathArtifact.
299      * 
300      * @param javadocPathArtifact
301      * @param serializer
302      * @param tagName
303      * @throws java.io.IOException
304      */
305     private void writeJavadocPathArtifact( JavadocPathArtifact javadocPathArtifact, String tagName, XmlSerializer serializer )
306         throws java.io.IOException
307     {
308         serializer.startTag( NAMESPACE, tagName );
309         if ( javadocPathArtifact.getGroupId() != null )
310         {
311             serializer.startTag( NAMESPACE, "groupId" ).text( javadocPathArtifact.getGroupId() ).endTag( NAMESPACE, "groupId" );
312         }
313         if ( javadocPathArtifact.getArtifactId() != null )
314         {
315             serializer.startTag( NAMESPACE, "artifactId" ).text( javadocPathArtifact.getArtifactId() ).endTag( NAMESPACE, "artifactId" );
316         }
317         if ( javadocPathArtifact.getVersion() != null )
318         {
319             serializer.startTag( NAMESPACE, "version" ).text( javadocPathArtifact.getVersion() ).endTag( NAMESPACE, "version" );
320         }
321         serializer.endTag( NAMESPACE, tagName );
322     } //-- void writeJavadocPathArtifact( JavadocPathArtifact, String, XmlSerializer )
323 
324     /**
325      * Method writeOfflineLink.
326      * 
327      * @param offlineLink
328      * @param serializer
329      * @param tagName
330      * @throws java.io.IOException
331      */
332     private void writeOfflineLink( OfflineLink offlineLink, String tagName, XmlSerializer serializer )
333         throws java.io.IOException
334     {
335         serializer.startTag( NAMESPACE, tagName );
336         if ( offlineLink.getUrl() != null )
337         {
338             serializer.startTag( NAMESPACE, "url" ).text( offlineLink.getUrl() ).endTag( NAMESPACE, "url" );
339         }
340         if ( offlineLink.getLocation() != null )
341         {
342             serializer.startTag( NAMESPACE, "location" ).text( offlineLink.getLocation() ).endTag( NAMESPACE, "location" );
343         }
344         serializer.endTag( NAMESPACE, tagName );
345     } //-- void writeOfflineLink( OfflineLink, String, XmlSerializer )
346 
347     /**
348      * Method writeResourcesArtifact.
349      * 
350      * @param resourcesArtifact
351      * @param serializer
352      * @param tagName
353      * @throws java.io.IOException
354      */
355     private void writeResourcesArtifact( ResourcesArtifact resourcesArtifact, String tagName, XmlSerializer serializer )
356         throws java.io.IOException
357     {
358         serializer.startTag( NAMESPACE, tagName );
359         if ( resourcesArtifact.getGroupId() != null )
360         {
361             serializer.startTag( NAMESPACE, "groupId" ).text( resourcesArtifact.getGroupId() ).endTag( NAMESPACE, "groupId" );
362         }
363         if ( resourcesArtifact.getArtifactId() != null )
364         {
365             serializer.startTag( NAMESPACE, "artifactId" ).text( resourcesArtifact.getArtifactId() ).endTag( NAMESPACE, "artifactId" );
366         }
367         if ( resourcesArtifact.getVersion() != null )
368         {
369             serializer.startTag( NAMESPACE, "version" ).text( resourcesArtifact.getVersion() ).endTag( NAMESPACE, "version" );
370         }
371         serializer.endTag( NAMESPACE, tagName );
372     } //-- void writeResourcesArtifact( ResourcesArtifact, String, XmlSerializer )
373 
374     /**
375      * Method writeTag.
376      * 
377      * @param tag
378      * @param serializer
379      * @param tagName
380      * @throws java.io.IOException
381      */
382     private void writeTag( Tag tag, String tagName, XmlSerializer serializer )
383         throws java.io.IOException
384     {
385         serializer.startTag( NAMESPACE, tagName );
386         if ( tag.getName() != null )
387         {
388             serializer.startTag( NAMESPACE, "name" ).text( tag.getName() ).endTag( NAMESPACE, "name" );
389         }
390         if ( tag.getHead() != null )
391         {
392             serializer.startTag( NAMESPACE, "head" ).text( tag.getHead() ).endTag( NAMESPACE, "head" );
393         }
394         serializer.endTag( NAMESPACE, tagName );
395     } //-- void writeTag( Tag, String, XmlSerializer )
396 
397     /**
398      * Method writeTaglet.
399      * 
400      * @param taglet
401      * @param serializer
402      * @param tagName
403      * @throws java.io.IOException
404      */
405     private void writeTaglet( Taglet taglet, String tagName, XmlSerializer serializer )
406         throws java.io.IOException
407     {
408         serializer.startTag( NAMESPACE, tagName );
409         if ( taglet.getTagletClass() != null )
410         {
411             serializer.startTag( NAMESPACE, "tagletClass" ).text( taglet.getTagletClass() ).endTag( NAMESPACE, "tagletClass" );
412         }
413         if ( taglet.getTagletpath() != null )
414         {
415             serializer.startTag( NAMESPACE, "tagletpath" ).text( taglet.getTagletpath() ).endTag( NAMESPACE, "tagletpath" );
416         }
417         if ( taglet.getTagletArtifact() != null )
418         {
419             writeTagletArtifact( (TagletArtifact) taglet.getTagletArtifact(), "tagletArtifact", serializer );
420         }
421         serializer.endTag( NAMESPACE, tagName );
422     } //-- void writeTaglet( Taglet, String, XmlSerializer )
423 
424     /**
425      * Method writeTagletArtifact.
426      * 
427      * @param tagletArtifact
428      * @param serializer
429      * @param tagName
430      * @throws java.io.IOException
431      */
432     private void writeTagletArtifact( TagletArtifact tagletArtifact, String tagName, XmlSerializer serializer )
433         throws java.io.IOException
434     {
435         serializer.startTag( NAMESPACE, tagName );
436         if ( tagletArtifact.getGroupId() != null )
437         {
438             serializer.startTag( NAMESPACE, "groupId" ).text( tagletArtifact.getGroupId() ).endTag( NAMESPACE, "groupId" );
439         }
440         if ( tagletArtifact.getArtifactId() != null )
441         {
442             serializer.startTag( NAMESPACE, "artifactId" ).text( tagletArtifact.getArtifactId() ).endTag( NAMESPACE, "artifactId" );
443         }
444         if ( tagletArtifact.getVersion() != null )
445         {
446             serializer.startTag( NAMESPACE, "version" ).text( tagletArtifact.getVersion() ).endTag( NAMESPACE, "version" );
447         }
448         serializer.endTag( NAMESPACE, tagName );
449     } //-- void writeTagletArtifact( TagletArtifact, String, XmlSerializer )
450 
451 }