View Javadoc

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