View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   // Generated by Modello 2.3.0,
3   // any modifications will be overwritten.
4   // ==============================================================
5   
6   package org.apache.maven.usability.plugin.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.usability.plugin.Expression;
16  import org.apache.maven.usability.plugin.ExpressionDocumentation;
17  import org.codehaus.plexus.util.xml.pull.MXSerializer;
18  import org.codehaus.plexus.util.xml.pull.XmlSerializer;
19  
20  /**
21   * Class ParamdocXpp3Writer.
22   * 
23   * @version $Revision$ $Date$
24   */
25  @SuppressWarnings( "all" )
26  public class ParamdocXpp3Writer
27  {
28  
29        //--------------------------/
30       //- Class/Member Variables -/
31      //--------------------------/
32  
33      /**
34       * Field NAMESPACE.
35       */
36      private static final String NAMESPACE = null;
37  
38      /**
39       * Field fileComment.
40       */
41      private String fileComment = null;
42  
43  
44        //-----------/
45       //- Methods -/
46      //-----------/
47  
48      /**
49       * Method setFileComment.
50       * 
51       * @param fileComment a fileComment object.
52       */
53      public void setFileComment( String fileComment )
54      {
55          this.fileComment = fileComment;
56      } //-- void setFileComment( String )
57  
58      /**
59       * Method write.
60       * 
61       * @param writer a writer object.
62       * @param expressionDocumentation a expressionDocumentation
63       * object.
64       * @throws java.io.IOException java.io.IOException if any.
65       */
66      public void write( Writer writer, ExpressionDocumentation expressionDocumentation )
67          throws java.io.IOException
68      {
69          XmlSerializer serializer = new MXSerializer();
70          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
71          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
72          serializer.setOutput( writer );
73          serializer.startDocument( expressionDocumentation.getModelEncoding(), null );
74          writeExpressionDocumentation( expressionDocumentation, "paramdoc", serializer );
75          serializer.endDocument();
76      } //-- void write( Writer, ExpressionDocumentation )
77  
78      /**
79       * Method write.
80       * 
81       * @param stream a stream object.
82       * @param expressionDocumentation a expressionDocumentation
83       * object.
84       * @throws java.io.IOException java.io.IOException if any.
85       */
86      public void write( OutputStream stream, ExpressionDocumentation expressionDocumentation )
87          throws java.io.IOException
88      {
89          XmlSerializer serializer = new MXSerializer();
90          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
91          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
92          serializer.setOutput( stream, expressionDocumentation.getModelEncoding() );
93          serializer.startDocument( expressionDocumentation.getModelEncoding(), null );
94          writeExpressionDocumentation( expressionDocumentation, "paramdoc", serializer );
95          serializer.endDocument();
96      } //-- void write( OutputStream, ExpressionDocumentation )
97  
98      /**
99       * Method writeExpression.
100      * 
101      * @param expression a expression object.
102      * @param serializer a serializer object.
103      * @param tagName a tagName object.
104      * @throws java.io.IOException java.io.IOException if any.
105      */
106     private void writeExpression( Expression expression, String tagName, XmlSerializer serializer )
107         throws java.io.IOException
108     {
109         serializer.startTag( NAMESPACE, tagName );
110         if ( expression.getSyntax() != null )
111         {
112             serializer.startTag( NAMESPACE, "syntax" ).text( expression.getSyntax() ).endTag( NAMESPACE, "syntax" );
113         }
114         if ( expression.getDescription() != null )
115         {
116             serializer.startTag( NAMESPACE, "description" ).text( expression.getDescription() ).endTag( NAMESPACE, "description" );
117         }
118         if ( expression.getConfiguration() != null )
119         {
120             serializer.startTag( NAMESPACE, "configuration" ).text( expression.getConfiguration() ).endTag( NAMESPACE, "configuration" );
121         }
122         if ( ( expression.getCliOptions() != null ) && ( expression.getCliOptions().size() > 0 ) )
123         {
124             serializer.startTag( NAMESPACE, "cliOptions" );
125             for ( Iterator iter = expression.getCliOptions().keySet().iterator(); iter.hasNext(); )
126             {
127                 String key = (String) iter.next();
128                 String value = (String) expression.getCliOptions().get( key );
129                 serializer.startTag( NAMESPACE, "cliOption" );
130                 serializer.startTag( NAMESPACE, "key" ).text( key ).endTag( NAMESPACE, "key" );
131                 serializer.startTag( NAMESPACE, "value" ).text( value ).endTag( NAMESPACE, "value" );
132                 serializer.endTag( NAMESPACE, "cliOption" );
133             }
134             serializer.endTag( NAMESPACE, "cliOptions" );
135         }
136         if ( ( expression.getApiMethods() != null ) && ( expression.getApiMethods().size() > 0 ) )
137         {
138             serializer.startTag( NAMESPACE, "apiMethods" );
139             for ( Iterator iter = expression.getApiMethods().keySet().iterator(); iter.hasNext(); )
140             {
141                 String key = (String) iter.next();
142                 String value = (String) expression.getApiMethods().get( key );
143                 serializer.startTag( NAMESPACE, "apiMethod" );
144                 serializer.startTag( NAMESPACE, "key" ).text( key ).endTag( NAMESPACE, "key" );
145                 serializer.startTag( NAMESPACE, "value" ).text( value ).endTag( NAMESPACE, "value" );
146                 serializer.endTag( NAMESPACE, "apiMethod" );
147             }
148             serializer.endTag( NAMESPACE, "apiMethods" );
149         }
150         if ( expression.getDeprecation() != null )
151         {
152             serializer.startTag( NAMESPACE, "deprecation" ).text( expression.getDeprecation() ).endTag( NAMESPACE, "deprecation" );
153         }
154         if ( expression.getBan() != null )
155         {
156             serializer.startTag( NAMESPACE, "ban" ).text( expression.getBan() ).endTag( NAMESPACE, "ban" );
157         }
158         if ( expression.isEditable() != true )
159         {
160             serializer.startTag( NAMESPACE, "editable" ).text( String.valueOf( expression.isEditable() ) ).endTag( NAMESPACE, "editable" );
161         }
162         serializer.endTag( NAMESPACE, tagName );
163     } //-- void writeExpression( Expression, String, XmlSerializer )
164 
165     /**
166      * Method writeExpressionDocumentation.
167      * 
168      * @param expressionDocumentation a expressionDocumentation
169      * object.
170      * @param serializer a serializer object.
171      * @param tagName a tagName object.
172      * @throws java.io.IOException java.io.IOException if any.
173      */
174     private void writeExpressionDocumentation( ExpressionDocumentation expressionDocumentation, String tagName, XmlSerializer serializer )
175         throws java.io.IOException
176     {
177         if ( this.fileComment != null )
178         {
179         serializer.comment(this.fileComment);
180         }
181         serializer.setPrefix( "", "http://maven.apache.org/PARAMDOC/1.0.0" );
182         serializer.setPrefix( "xsi", "http://www.w3.org/2001/XMLSchema-instance" );
183         serializer.startTag( NAMESPACE, tagName );
184         serializer.attribute( "", "xsi:schemaLocation", "http://maven.apache.org/PARAMDOC/1.0.0 http://maven.apache.org/xsd/paramdoc-1.0.0.xsd" );
185         if ( ( expressionDocumentation.getExpressions() != null ) && ( expressionDocumentation.getExpressions().size() > 0 ) )
186         {
187             serializer.startTag( NAMESPACE, "expressions" );
188             for ( Iterator iter = expressionDocumentation.getExpressions().iterator(); iter.hasNext(); )
189             {
190                 Expression o = (Expression) iter.next();
191                 writeExpression( o, "expression", serializer );
192             }
193             serializer.endTag( NAMESPACE, "expressions" );
194         }
195         serializer.endTag( NAMESPACE, tagName );
196     } //-- void writeExpressionDocumentation( ExpressionDocumentation, String, XmlSerializer )
197 
198 }