View Javadoc

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