001    // =================== DO NOT EDIT THIS FILE ====================
002    // Generated by Modello 1.7,
003    // any modifications will be overwritten.
004    // ==============================================================
005    
006    package org.apache.maven.usability.plugin.io.xpp3;
007    
008      //---------------------------------/
009     //- Imported classes and packages -/
010    //---------------------------------/
011    
012    import java.io.OutputStream;
013    import java.io.Writer;
014    import java.util.Iterator;
015    import org.apache.maven.usability.plugin.Expression;
016    import org.apache.maven.usability.plugin.ExpressionDocumentation;
017    import org.codehaus.plexus.util.xml.pull.MXSerializer;
018    import org.codehaus.plexus.util.xml.pull.XmlSerializer;
019    
020    /**
021     * Class ParamdocXpp3Writer.
022     * 
023     * @version $Revision$ $Date$
024     */
025    @SuppressWarnings( "all" )
026    public class ParamdocXpp3Writer
027    {
028    
029          //--------------------------/
030         //- Class/Member Variables -/
031        //--------------------------/
032    
033        /**
034         * Field NAMESPACE.
035         */
036        private static final String NAMESPACE = null;
037    
038    
039          //-----------/
040         //- Methods -/
041        //-----------/
042    
043        /**
044         * Method write.
045         * 
046         * @param writer
047         * @param expressionDocumentation
048         * @throws java.io.IOException
049         */
050        public void write( Writer writer, ExpressionDocumentation expressionDocumentation )
051            throws java.io.IOException
052        {
053            XmlSerializer serializer = new MXSerializer();
054            serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
055            serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
056            serializer.setOutput( writer );
057            serializer.startDocument( expressionDocumentation.getModelEncoding(), null );
058            writeExpressionDocumentation( expressionDocumentation, "paramdoc", serializer );
059            serializer.endDocument();
060        } //-- void write( Writer, ExpressionDocumentation )
061    
062        /**
063         * Method write.
064         * 
065         * @param stream
066         * @param expressionDocumentation
067         * @throws java.io.IOException
068         */
069        public void write( OutputStream stream, ExpressionDocumentation expressionDocumentation )
070            throws java.io.IOException
071        {
072            XmlSerializer serializer = new MXSerializer();
073            serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
074            serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
075            serializer.setOutput( stream, expressionDocumentation.getModelEncoding() );
076            serializer.startDocument( expressionDocumentation.getModelEncoding(), null );
077            writeExpressionDocumentation( expressionDocumentation, "paramdoc", serializer );
078            serializer.endDocument();
079        } //-- void write( OutputStream, ExpressionDocumentation )
080    
081        /**
082         * Method writeExpression.
083         * 
084         * @param expression
085         * @param serializer
086         * @param tagName
087         * @throws java.io.IOException
088         */
089        private void writeExpression( Expression expression, String tagName, XmlSerializer serializer )
090            throws java.io.IOException
091        {
092            serializer.startTag( NAMESPACE, tagName );
093            if ( expression.getSyntax() != null )
094            {
095                serializer.startTag( NAMESPACE, "syntax" ).text( expression.getSyntax() ).endTag( NAMESPACE, "syntax" );
096            }
097            if ( expression.getDescription() != null )
098            {
099                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    }