View Javadoc
1   /*
2    Licensed to the Apache Software Foundation (ASF) under one
3    or more contributor license agreements.  See the NOTICE file
4    distributed with this work for additional information
5    regarding copyright ownership.  The ASF licenses this file
6    to you under the Apache License, Version 2.0 (the
7    "License"); you may not use this file except in compliance
8    with the License.  You may obtain a copy of the License at
9    
10       http://www.apache.org/licenses/LICENSE-2.0
11   
12   Unless required by applicable law or agreed to in writing,
13   software distributed under the License is distributed on an
14   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   KIND, either express or implied.  See the License for the
16   specific language governing permissions and limitations
17   under the License.
18   =================== DO NOT EDIT THIS FILE ====================
19   Generated by Modello 2.4.0,
20   any modifications will be overwritten.
21   ==============================================================
22   */
23  
24  package org.apache.maven.usability.plugin.io.xpp3;
25  
26    //---------------------------------/
27   //- Imported classes and packages -/
28  //---------------------------------/
29  
30  import java.io.OutputStream;
31  import java.io.Writer;
32  import java.util.Iterator;
33  import org.apache.maven.usability.plugin.Expression;
34  import org.apache.maven.usability.plugin.ExpressionDocumentation;
35  import org.codehaus.plexus.util.xml.pull.MXSerializer;
36  import org.codehaus.plexus.util.xml.pull.XmlSerializer;
37  
38  /**
39   * Class ParamdocXpp3Writer.
40   * 
41   * @version $Revision$ $Date$
42   */
43  @SuppressWarnings( "all" )
44  public class ParamdocXpp3Writer
45  {
46  
47        //--------------------------/
48       //- Class/Member Variables -/
49      //--------------------------/
50  
51      /**
52       * Field NAMESPACE.
53       */
54      private static final String NAMESPACE = null;
55  
56      /**
57       * Field fileComment.
58       */
59      private String fileComment = null;
60  
61  
62        //-----------/
63       //- Methods -/
64      //-----------/
65  
66      /**
67       * Method setFileComment.
68       * 
69       * @param fileComment a fileComment object.
70       */
71      public void setFileComment( String fileComment )
72      {
73          this.fileComment = fileComment;
74      } //-- void setFileComment( String )
75  
76      /**
77       * Method write.
78       * 
79       * @param writer a writer object.
80       * @param expressionDocumentation a expressionDocumentation
81       * object.
82       * @throws java.io.IOException java.io.IOException if any.
83       */
84      public void write( Writer writer, ExpressionDocumentation expressionDocumentation )
85          throws java.io.IOException
86      {
87          XmlSerializer serializer = new MXSerializer();
88          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
89          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
90          serializer.setOutput( writer );
91          serializer.startDocument( expressionDocumentation.getModelEncoding(), null );
92          writeExpressionDocumentation( expressionDocumentation, "paramdoc", serializer );
93          serializer.endDocument();
94      } //-- void write( Writer, ExpressionDocumentation )
95  
96      /**
97       * Method write.
98       * 
99       * @param stream a stream object.
100      * @param expressionDocumentation a expressionDocumentation
101      * object.
102      * @throws java.io.IOException java.io.IOException if any.
103      */
104     public void write( OutputStream stream, ExpressionDocumentation expressionDocumentation )
105         throws java.io.IOException
106     {
107         XmlSerializer serializer = new MXSerializer();
108         serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
109         serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
110         serializer.setOutput( stream, expressionDocumentation.getModelEncoding() );
111         serializer.startDocument( expressionDocumentation.getModelEncoding(), null );
112         writeExpressionDocumentation( expressionDocumentation, "paramdoc", serializer );
113         serializer.endDocument();
114     } //-- void write( OutputStream, ExpressionDocumentation )
115 
116     /**
117      * Method writeExpression.
118      * 
119      * @param expression a expression object.
120      * @param serializer a serializer object.
121      * @param tagName a tagName object.
122      * @throws java.io.IOException java.io.IOException if any.
123      */
124     private void writeExpression( Expression expression, String tagName, XmlSerializer serializer )
125         throws java.io.IOException
126     {
127         serializer.startTag( NAMESPACE, tagName );
128         if ( expression.getSyntax() != null )
129         {
130             serializer.startTag( NAMESPACE, "syntax" ).text( expression.getSyntax() ).endTag( NAMESPACE, "syntax" );
131         }
132         if ( expression.getDescription() != null )
133         {
134             serializer.startTag( NAMESPACE, "description" ).text( expression.getDescription() ).endTag( NAMESPACE, "description" );
135         }
136         if ( expression.getConfiguration() != null )
137         {
138             serializer.startTag( NAMESPACE, "configuration" ).text( expression.getConfiguration() ).endTag( NAMESPACE, "configuration" );
139         }
140         if ( ( expression.getCliOptions() != null ) && ( expression.getCliOptions().size() > 0 ) )
141         {
142             serializer.startTag( NAMESPACE, "cliOptions" );
143             for ( Iterator iter = expression.getCliOptions().keySet().iterator(); iter.hasNext(); )
144             {
145                 String key = (String) iter.next();
146                 String value = (String) expression.getCliOptions().get( key );
147                 serializer.startTag( NAMESPACE, "cliOption" );
148                 serializer.startTag( NAMESPACE, "key" ).text( key ).endTag( NAMESPACE, "key" );
149                 serializer.startTag( NAMESPACE, "value" ).text( value ).endTag( NAMESPACE, "value" );
150                 serializer.endTag( NAMESPACE, "cliOption" );
151             }
152             serializer.endTag( NAMESPACE, "cliOptions" );
153         }
154         if ( ( expression.getApiMethods() != null ) && ( expression.getApiMethods().size() > 0 ) )
155         {
156             serializer.startTag( NAMESPACE, "apiMethods" );
157             for ( Iterator iter = expression.getApiMethods().keySet().iterator(); iter.hasNext(); )
158             {
159                 String key = (String) iter.next();
160                 String value = (String) expression.getApiMethods().get( key );
161                 serializer.startTag( NAMESPACE, "apiMethod" );
162                 serializer.startTag( NAMESPACE, "key" ).text( key ).endTag( NAMESPACE, "key" );
163                 serializer.startTag( NAMESPACE, "value" ).text( value ).endTag( NAMESPACE, "value" );
164                 serializer.endTag( NAMESPACE, "apiMethod" );
165             }
166             serializer.endTag( NAMESPACE, "apiMethods" );
167         }
168         if ( expression.getDeprecation() != null )
169         {
170             serializer.startTag( NAMESPACE, "deprecation" ).text( expression.getDeprecation() ).endTag( NAMESPACE, "deprecation" );
171         }
172         if ( expression.getBan() != null )
173         {
174             serializer.startTag( NAMESPACE, "ban" ).text( expression.getBan() ).endTag( NAMESPACE, "ban" );
175         }
176         if ( expression.isEditable() != true )
177         {
178             serializer.startTag( NAMESPACE, "editable" ).text( String.valueOf( expression.isEditable() ) ).endTag( NAMESPACE, "editable" );
179         }
180         serializer.endTag( NAMESPACE, tagName );
181     } //-- void writeExpression( Expression, String, XmlSerializer )
182 
183     /**
184      * Method writeExpressionDocumentation.
185      * 
186      * @param expressionDocumentation a expressionDocumentation
187      * object.
188      * @param serializer a serializer object.
189      * @param tagName a tagName object.
190      * @throws java.io.IOException java.io.IOException if any.
191      */
192     private void writeExpressionDocumentation( ExpressionDocumentation expressionDocumentation, String tagName, XmlSerializer serializer )
193         throws java.io.IOException
194     {
195         if ( this.fileComment != null )
196         {
197         serializer.comment(this.fileComment);
198         }
199         serializer.setPrefix( "", "http://maven.apache.org/PARAMDOC/1.0.0" );
200         serializer.setPrefix( "xsi", "http://www.w3.org/2001/XMLSchema-instance" );
201         serializer.startTag( NAMESPACE, tagName );
202         serializer.attribute( "", "xsi:schemaLocation", "http://maven.apache.org/PARAMDOC/1.0.0 http://maven.apache.org/xsd/paramdoc-1.0.0.xsd" );
203         if ( ( expressionDocumentation.getExpressions() != null ) && ( expressionDocumentation.getExpressions().size() > 0 ) )
204         {
205             serializer.startTag( NAMESPACE, "expressions" );
206             for ( Iterator iter = expressionDocumentation.getExpressions().iterator(); iter.hasNext(); )
207             {
208                 Expression o = (Expression) iter.next();
209                 writeExpression( o, "expression", serializer );
210             }
211             serializer.endTag( NAMESPACE, "expressions" );
212         }
213         serializer.endTag( NAMESPACE, tagName );
214     } //-- void writeExpressionDocumentation( ExpressionDocumentation, String, XmlSerializer )
215 
216 }