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