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.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        //-----------/
40       //- Methods -/
41      //-----------/
42  
43      /**
44       * Method write.
45       * 
46       * @param writer
47       * @param expressionDocumentation
48       * @throws java.io.IOException
49       */
50      public void write( Writer writer, ExpressionDocumentation expressionDocumentation )
51          throws java.io.IOException
52      {
53          XmlSerializer serializer = new MXSerializer();
54          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
55          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
56          serializer.setOutput( writer );
57          serializer.startDocument( expressionDocumentation.getModelEncoding(), null );
58          writeExpressionDocumentation( expressionDocumentation, "paramdoc", serializer );
59          serializer.endDocument();
60      } //-- void write( Writer, ExpressionDocumentation )
61  
62      /**
63       * Method write.
64       * 
65       * @param stream
66       * @param expressionDocumentation
67       * @throws java.io.IOException
68       */
69      public void write( OutputStream stream, ExpressionDocumentation expressionDocumentation )
70          throws java.io.IOException
71      {
72          XmlSerializer serializer = new MXSerializer();
73          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
74          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
75          serializer.setOutput( stream, expressionDocumentation.getModelEncoding() );
76          serializer.startDocument( expressionDocumentation.getModelEncoding(), null );
77          writeExpressionDocumentation( expressionDocumentation, "paramdoc", serializer );
78          serializer.endDocument();
79      } //-- void write( OutputStream, ExpressionDocumentation )
80  
81      /**
82       * Method writeExpression.
83       * 
84       * @param expression
85       * @param serializer
86       * @param tagName
87       * @throws java.io.IOException
88       */
89      private void writeExpression( Expression expression, String tagName, XmlSerializer serializer )
90          throws java.io.IOException
91      {
92          serializer.startTag( NAMESPACE, tagName );
93          if ( expression.getSyntax() != null )
94          {
95              serializer.startTag( NAMESPACE, "syntax" ).text( expression.getSyntax() ).endTag( NAMESPACE, "syntax" );
96          }
97          if ( expression.getDescription() != null )
98          {
99              serializer.startTag( NAMESPACE, "description" ).text( expression.getDescription() ).endTag( NAMESPACE, "description" );
100         }
101         if ( expression.getConfiguration() != null )
102         {
103             serializer.startTag( NAMESPACE, "configuration" ).text( expression.getConfiguration() ).endTag( NAMESPACE, "configuration" );
104         }
105         if ( ( expression.getCliOptions() != null ) && ( expression.getCliOptions().size() > 0 ) )
106         {
107             serializer.startTag( NAMESPACE, "cliOptions" );
108             for ( Iterator iter = expression.getCliOptions().keySet().iterator(); iter.hasNext(); )
109             {
110                 String key = (String) iter.next();
111                 String value = (String) expression.getCliOptions().get( key );
112                 serializer.startTag( NAMESPACE, "cliOption" );
113                 serializer.startTag( NAMESPACE, "key" ).text( key ).endTag( NAMESPACE, "key" );
114                 serializer.startTag( NAMESPACE, "value" ).text( value ).endTag( NAMESPACE, "value" );
115                 serializer.endTag( NAMESPACE, "cliOption" );
116             }
117             serializer.endTag( NAMESPACE, "cliOptions" );
118         }
119         if ( ( expression.getApiMethods() != null ) && ( expression.getApiMethods().size() > 0 ) )
120         {
121             serializer.startTag( NAMESPACE, "apiMethods" );
122             for ( Iterator iter = expression.getApiMethods().keySet().iterator(); iter.hasNext(); )
123             {
124                 String key = (String) iter.next();
125                 String value = (String) expression.getApiMethods().get( key );
126                 serializer.startTag( NAMESPACE, "apiMethod" );
127                 serializer.startTag( NAMESPACE, "key" ).text( key ).endTag( NAMESPACE, "key" );
128                 serializer.startTag( NAMESPACE, "value" ).text( value ).endTag( NAMESPACE, "value" );
129                 serializer.endTag( NAMESPACE, "apiMethod" );
130             }
131             serializer.endTag( NAMESPACE, "apiMethods" );
132         }
133         if ( expression.getDeprecation() != null )
134         {
135             serializer.startTag( NAMESPACE, "deprecation" ).text( expression.getDeprecation() ).endTag( NAMESPACE, "deprecation" );
136         }
137         if ( expression.getBan() != null )
138         {
139             serializer.startTag( NAMESPACE, "ban" ).text( expression.getBan() ).endTag( NAMESPACE, "ban" );
140         }
141         if ( expression.isEditable() != true )
142         {
143             serializer.startTag( NAMESPACE, "editable" ).text( String.valueOf( expression.isEditable() ) ).endTag( NAMESPACE, "editable" );
144         }
145         serializer.endTag( NAMESPACE, tagName );
146     } //-- void writeExpression( Expression, String, XmlSerializer )
147 
148     /**
149      * Method writeExpressionDocumentation.
150      * 
151      * @param expressionDocumentation
152      * @param serializer
153      * @param tagName
154      * @throws java.io.IOException
155      */
156     private void writeExpressionDocumentation( ExpressionDocumentation expressionDocumentation, String tagName, XmlSerializer serializer )
157         throws java.io.IOException
158     {
159         serializer.setPrefix( "", "http://maven.apache.org/PARAMDOC/1.0.0" );
160         serializer.setPrefix( "xsi", "http://www.w3.org/2001/XMLSchema-instance" );
161         serializer.startTag( NAMESPACE, tagName );
162         serializer.attribute( "", "xsi:schemaLocation", "http://maven.apache.org/PARAMDOC/1.0.0 http://maven.apache.org/xsd/paramdoc-1.0.0.xsd" );
163         if ( ( expressionDocumentation.getExpressions() != null ) && ( expressionDocumentation.getExpressions().size() > 0 ) )
164         {
165             serializer.startTag( NAMESPACE, "expressions" );
166             for ( Iterator iter = expressionDocumentation.getExpressions().iterator(); iter.hasNext(); )
167             {
168                 Expression o = (Expression) iter.next();
169                 writeExpression( o, "expression", serializer );
170             }
171             serializer.endTag( NAMESPACE, "expressions" );
172         }
173         serializer.endTag( NAMESPACE, tagName );
174     } //-- void writeExpressionDocumentation( ExpressionDocumentation, String, XmlSerializer )
175 
176 }