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.tools.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.plugin.tools.model.Component;
16  import org.apache.maven.plugin.tools.model.LifecycleExecution;
17  import org.apache.maven.plugin.tools.model.Mojo;
18  import org.apache.maven.plugin.tools.model.Parameter;
19  import org.apache.maven.plugin.tools.model.PluginMetadata;
20  import org.codehaus.plexus.util.xml.pull.MXSerializer;
21  import org.codehaus.plexus.util.xml.pull.XmlSerializer;
22  
23  /**
24   * Class PluginMetadataXpp3Writer.
25   * 
26   * @version $Revision: 907040 $ $Date: 2014-04-27 09:50:12 +0000 (Sun, 27 Apr 2014) $
27   */
28  @SuppressWarnings( "all" )
29  public class PluginMetadataXpp3Writer
30  {
31  
32        //--------------------------/
33       //- Class/Member Variables -/
34      //--------------------------/
35  
36      /**
37       * Field NAMESPACE.
38       */
39      private static final String NAMESPACE = null;
40  
41  
42        //-----------/
43       //- Methods -/
44      //-----------/
45  
46      /**
47       * Method write.
48       * 
49       * @param writer
50       * @param pluginMetadata
51       * @throws java.io.IOException
52       */
53      public void write( Writer writer, PluginMetadata pluginMetadata )
54          throws java.io.IOException
55      {
56          XmlSerializer serializer = new MXSerializer();
57          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
58          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
59          serializer.setOutput( writer );
60          serializer.startDocument( pluginMetadata.getModelEncoding(), null );
61          writePluginMetadata( pluginMetadata, "pluginMetadata", serializer );
62          serializer.endDocument();
63      } //-- void write( Writer, PluginMetadata )
64  
65      /**
66       * Method write.
67       * 
68       * @param stream
69       * @param pluginMetadata
70       * @throws java.io.IOException
71       */
72      public void write( OutputStream stream, PluginMetadata pluginMetadata )
73          throws java.io.IOException
74      {
75          XmlSerializer serializer = new MXSerializer();
76          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
77          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
78          serializer.setOutput( stream, pluginMetadata.getModelEncoding() );
79          serializer.startDocument( pluginMetadata.getModelEncoding(), null );
80          writePluginMetadata( pluginMetadata, "pluginMetadata", serializer );
81          serializer.endDocument();
82      } //-- void write( OutputStream, PluginMetadata )
83  
84      /**
85       * Method writeComponent.
86       * 
87       * @param component
88       * @param serializer
89       * @param tagName
90       * @throws java.io.IOException
91       */
92      private void writeComponent( Component component, String tagName, XmlSerializer serializer )
93          throws java.io.IOException
94      {
95          serializer.startTag( NAMESPACE, tagName );
96          if ( component.getRole() != null )
97          {
98              serializer.startTag( NAMESPACE, "role" ).text( component.getRole() ).endTag( NAMESPACE, "role" );
99          }
100         if ( component.getHint() != null )
101         {
102             serializer.startTag( NAMESPACE, "hint" ).text( component.getHint() ).endTag( NAMESPACE, "hint" );
103         }
104         serializer.endTag( NAMESPACE, tagName );
105     } //-- void writeComponent( Component, String, XmlSerializer )
106 
107     /**
108      * Method writeLifecycleExecution.
109      * 
110      * @param lifecycleExecution
111      * @param serializer
112      * @param tagName
113      * @throws java.io.IOException
114      */
115     private void writeLifecycleExecution( LifecycleExecution lifecycleExecution, String tagName, XmlSerializer serializer )
116         throws java.io.IOException
117     {
118         serializer.startTag( NAMESPACE, tagName );
119         if ( lifecycleExecution.getLifecycle() != null )
120         {
121             serializer.startTag( NAMESPACE, "lifecycle" ).text( lifecycleExecution.getLifecycle() ).endTag( NAMESPACE, "lifecycle" );
122         }
123         if ( lifecycleExecution.getPhase() != null )
124         {
125             serializer.startTag( NAMESPACE, "phase" ).text( lifecycleExecution.getPhase() ).endTag( NAMESPACE, "phase" );
126         }
127         if ( lifecycleExecution.getGoal() != null )
128         {
129             serializer.startTag( NAMESPACE, "goal" ).text( lifecycleExecution.getGoal() ).endTag( NAMESPACE, "goal" );
130         }
131         serializer.endTag( NAMESPACE, tagName );
132     } //-- void writeLifecycleExecution( LifecycleExecution, String, XmlSerializer )
133 
134     /**
135      * Method writeMojo.
136      * 
137      * @param mojo
138      * @param serializer
139      * @param tagName
140      * @throws java.io.IOException
141      */
142     private void writeMojo( Mojo mojo, String tagName, XmlSerializer serializer )
143         throws java.io.IOException
144     {
145         serializer.startTag( NAMESPACE, tagName );
146         if ( mojo.getGoal() != null )
147         {
148             serializer.startTag( NAMESPACE, "goal" ).text( mojo.getGoal() ).endTag( NAMESPACE, "goal" );
149         }
150         if ( mojo.getPhase() != null )
151         {
152             serializer.startTag( NAMESPACE, "phase" ).text( mojo.getPhase() ).endTag( NAMESPACE, "phase" );
153         }
154         if ( mojo.isAggregator() != false )
155         {
156             serializer.startTag( NAMESPACE, "aggregator" ).text( String.valueOf( mojo.isAggregator() ) ).endTag( NAMESPACE, "aggregator" );
157         }
158         if ( mojo.getRequiresDependencyResolution() != null )
159         {
160             serializer.startTag( NAMESPACE, "requiresDependencyResolution" ).text( mojo.getRequiresDependencyResolution() ).endTag( NAMESPACE, "requiresDependencyResolution" );
161         }
162         if ( mojo.isRequiresProject() != false )
163         {
164             serializer.startTag( NAMESPACE, "requiresProject" ).text( String.valueOf( mojo.isRequiresProject() ) ).endTag( NAMESPACE, "requiresProject" );
165         }
166         if ( mojo.isRequiresReports() != false )
167         {
168             serializer.startTag( NAMESPACE, "requiresReports" ).text( String.valueOf( mojo.isRequiresReports() ) ).endTag( NAMESPACE, "requiresReports" );
169         }
170         if ( mojo.isRequiresOnline() != false )
171         {
172             serializer.startTag( NAMESPACE, "requiresOnline" ).text( String.valueOf( mojo.isRequiresOnline() ) ).endTag( NAMESPACE, "requiresOnline" );
173         }
174         if ( mojo.isInheritByDefault() != false )
175         {
176             serializer.startTag( NAMESPACE, "inheritByDefault" ).text( String.valueOf( mojo.isInheritByDefault() ) ).endTag( NAMESPACE, "inheritByDefault" );
177         }
178         if ( mojo.isRequiresDirectInvocation() != false )
179         {
180             serializer.startTag( NAMESPACE, "requiresDirectInvocation" ).text( String.valueOf( mojo.isRequiresDirectInvocation() ) ).endTag( NAMESPACE, "requiresDirectInvocation" );
181         }
182         if ( mojo.getExecution() != null )
183         {
184             writeLifecycleExecution( (LifecycleExecution) mojo.getExecution(), "execution", serializer );
185         }
186         if ( ( mojo.getComponents() != null ) && ( mojo.getComponents().size() > 0 ) )
187         {
188             serializer.startTag( NAMESPACE, "components" );
189             for ( Iterator iter = mojo.getComponents().iterator(); iter.hasNext(); )
190             {
191                 Component o = (Component) iter.next();
192                 writeComponent( o, "component", serializer );
193             }
194             serializer.endTag( NAMESPACE, "components" );
195         }
196         if ( ( mojo.getParameters() != null ) && ( mojo.getParameters().size() > 0 ) )
197         {
198             serializer.startTag( NAMESPACE, "parameters" );
199             for ( Iterator iter = mojo.getParameters().iterator(); iter.hasNext(); )
200             {
201                 Parameter o = (Parameter) iter.next();
202                 writeParameter( o, "parameter", serializer );
203             }
204             serializer.endTag( NAMESPACE, "parameters" );
205         }
206         if ( mojo.getDescription() != null )
207         {
208             serializer.startTag( NAMESPACE, "description" ).text( mojo.getDescription() ).endTag( NAMESPACE, "description" );
209         }
210         if ( mojo.getDeprecation() != null )
211         {
212             serializer.startTag( NAMESPACE, "deprecated" ).text( mojo.getDeprecation() ).endTag( NAMESPACE, "deprecated" );
213         }
214         if ( mojo.getSince() != null )
215         {
216             serializer.startTag( NAMESPACE, "since" ).text( mojo.getSince() ).endTag( NAMESPACE, "since" );
217         }
218         if ( mojo.getCall() != null )
219         {
220             serializer.startTag( NAMESPACE, "call" ).text( mojo.getCall() ).endTag( NAMESPACE, "call" );
221         }
222         serializer.endTag( NAMESPACE, tagName );
223     } //-- void writeMojo( Mojo, String, XmlSerializer )
224 
225     /**
226      * Method writeParameter.
227      * 
228      * @param parameter
229      * @param serializer
230      * @param tagName
231      * @throws java.io.IOException
232      */
233     private void writeParameter( Parameter parameter, String tagName, XmlSerializer serializer )
234         throws java.io.IOException
235     {
236         serializer.startTag( NAMESPACE, tagName );
237         if ( parameter.getName() != null )
238         {
239             serializer.startTag( NAMESPACE, "name" ).text( parameter.getName() ).endTag( NAMESPACE, "name" );
240         }
241         if ( parameter.getAlias() != null )
242         {
243             serializer.startTag( NAMESPACE, "alias" ).text( parameter.getAlias() ).endTag( NAMESPACE, "alias" );
244         }
245         if ( parameter.getProperty() != null )
246         {
247             serializer.startTag( NAMESPACE, "property" ).text( parameter.getProperty() ).endTag( NAMESPACE, "property" );
248         }
249         if ( parameter.isRequired() != false )
250         {
251             serializer.startTag( NAMESPACE, "required" ).text( String.valueOf( parameter.isRequired() ) ).endTag( NAMESPACE, "required" );
252         }
253         if ( parameter.isReadonly() != false )
254         {
255             serializer.startTag( NAMESPACE, "readonly" ).text( String.valueOf( parameter.isReadonly() ) ).endTag( NAMESPACE, "readonly" );
256         }
257         if ( parameter.getExpression() != null )
258         {
259             serializer.startTag( NAMESPACE, "expression" ).text( parameter.getExpression() ).endTag( NAMESPACE, "expression" );
260         }
261         if ( parameter.getDefaultValue() != null )
262         {
263             serializer.startTag( NAMESPACE, "defaultValue" ).text( parameter.getDefaultValue() ).endTag( NAMESPACE, "defaultValue" );
264         }
265         if ( parameter.getType() != null )
266         {
267             serializer.startTag( NAMESPACE, "type" ).text( parameter.getType() ).endTag( NAMESPACE, "type" );
268         }
269         if ( parameter.getDescription() != null )
270         {
271             serializer.startTag( NAMESPACE, "description" ).text( parameter.getDescription() ).endTag( NAMESPACE, "description" );
272         }
273         if ( parameter.getDeprecation() != null )
274         {
275             serializer.startTag( NAMESPACE, "deprecated" ).text( parameter.getDeprecation() ).endTag( NAMESPACE, "deprecated" );
276         }
277         if ( parameter.getSince() != null )
278         {
279             serializer.startTag( NAMESPACE, "since" ).text( parameter.getSince() ).endTag( NAMESPACE, "since" );
280         }
281         serializer.endTag( NAMESPACE, tagName );
282     } //-- void writeParameter( Parameter, String, XmlSerializer )
283 
284     /**
285      * Method writePluginMetadata.
286      * 
287      * @param pluginMetadata
288      * @param serializer
289      * @param tagName
290      * @throws java.io.IOException
291      */
292     private void writePluginMetadata( PluginMetadata pluginMetadata, String tagName, XmlSerializer serializer )
293         throws java.io.IOException
294     {
295         serializer.startTag( NAMESPACE, tagName );
296         if ( ( pluginMetadata.getMojos() != null ) && ( pluginMetadata.getMojos().size() > 0 ) )
297         {
298             serializer.startTag( NAMESPACE, "mojos" );
299             for ( Iterator iter = pluginMetadata.getMojos().iterator(); iter.hasNext(); )
300             {
301                 Mojo o = (Mojo) iter.next();
302                 writeMojo( o, "mojo", serializer );
303             }
304             serializer.endTag( NAMESPACE, "mojos" );
305         }
306         serializer.endTag( NAMESPACE, tagName );
307     } //-- void writePluginMetadata( PluginMetadata, String, XmlSerializer )
308 
309 }