All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.codehaus.cargo.maven2.io.xpp3.UberWarXpp3Writer Maven / Gradle / Ivy

There is a newer version: 1.9.0
Show newest version
// =================== DO NOT EDIT THIS FILE ====================
// Generated by Modello 1.7,
// any modifications will be overwritten.
// ==============================================================

package org.codehaus.cargo.maven2.io.xpp3;

  //---------------------------------/
 //- Imported classes and packages -/
//---------------------------------/

import java.io.OutputStream;
import java.io.Writer;
import java.util.Iterator;
import org.codehaus.cargo.maven2.Merge;
import org.codehaus.cargo.maven2.MergeRoot;
import org.codehaus.cargo.maven2.WebXml;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.pull.MXSerializer;
import org.codehaus.plexus.util.xml.pull.XmlSerializer;

/**
 * Class UberWarXpp3Writer.
 * 
 * @version $Revision$ $Date$
 */
public class UberWarXpp3Writer
{

      //--------------------------/
     //- Class/Member Variables -/
    //--------------------------/

    /**
     * Field NAMESPACE.
     */
    private static final String NAMESPACE = null;


      //-----------/
     //- Methods -/
    //-----------/

    /**
     * Method write.
     * 
     * @param writer
     * @param mergeRoot
     * @throws java.io.IOException
     */
    public void write( Writer writer, MergeRoot mergeRoot )
        throws java.io.IOException
    {
        XmlSerializer serializer = new MXSerializer();
        serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
        serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
        serializer.setOutput( writer );
        serializer.startDocument( mergeRoot.getModelEncoding(), null );
        writeMergeRoot( mergeRoot, "uberwar", serializer );
        serializer.endDocument();
    } //-- void write( Writer, MergeRoot )

    /**
     * Method write.
     * 
     * @param stream
     * @param mergeRoot
     * @throws java.io.IOException
     */
    public void write( OutputStream stream, MergeRoot mergeRoot )
        throws java.io.IOException
    {
        XmlSerializer serializer = new MXSerializer();
        serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
        serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
        serializer.setOutput( stream, mergeRoot.getModelEncoding() );
        serializer.startDocument( mergeRoot.getModelEncoding(), null );
        writeMergeRoot( mergeRoot, "uberwar", serializer );
        serializer.endDocument();
    } //-- void write( OutputStream, MergeRoot )

    /**
     * Method writeMerge.
     * 
     * @param merge
     * @param serializer
     * @param tagName
     * @throws java.io.IOException
     */
    private void writeMerge( Merge merge, String tagName, XmlSerializer serializer )
        throws java.io.IOException
    {
        serializer.startTag( NAMESPACE, tagName );
        if ( merge.getDocument() != null )
        {
            serializer.startTag( NAMESPACE, "document" ).text( merge.getDocument() ).endTag( NAMESPACE, "document" );
        }
        if ( merge.getFile() != null )
        {
            serializer.startTag( NAMESPACE, "file" ).text( merge.getFile() ).endTag( NAMESPACE, "file" );
        }
        if ( merge.getType() != null )
        {
            serializer.startTag( NAMESPACE, "type" ).text( merge.getType() ).endTag( NAMESPACE, "type" );
        }
        if ( merge.getClassname() != null )
        {
            serializer.startTag( NAMESPACE, "classname" ).text( merge.getClassname() ).endTag( NAMESPACE, "classname" );
        }
        if ( merge.getParameters() != null )
        {
            ((Xpp3Dom) merge.getParameters()).writeToSerializer( NAMESPACE, serializer );
        }
        serializer.endTag( NAMESPACE, tagName );
    } //-- void writeMerge( Merge, String, XmlSerializer )

    /**
     * Method writeMergeRoot.
     * 
     * @param mergeRoot
     * @param serializer
     * @param tagName
     * @throws java.io.IOException
     */
    private void writeMergeRoot( MergeRoot mergeRoot, String tagName, XmlSerializer serializer )
        throws java.io.IOException
    {
        serializer.startTag( NAMESPACE, tagName );
        if ( ( mergeRoot.getWars() != null ) && ( mergeRoot.getWars().size() > 0 ) )
        {
            serializer.startTag( NAMESPACE, "wars" );
            for ( Iterator iter = mergeRoot.getWars().iterator(); iter.hasNext(); )
            {
                String war = (String) iter.next();
                serializer.startTag( NAMESPACE, "war" ).text( war ).endTag( NAMESPACE, "war" );
            }
            serializer.endTag( NAMESPACE, "wars" );
        }
        if ( ( mergeRoot.getMerges() != null ) && ( mergeRoot.getMerges().size() > 0 ) )
        {
            serializer.startTag( NAMESPACE, "merges" );
            for ( Iterator iter = mergeRoot.getMerges().iterator(); iter.hasNext(); )
            {
                Merge o = (Merge) iter.next();
                writeMerge( o, "merge", serializer );
            }
            serializer.endTag( NAMESPACE, "merges" );
        }
        if ( mergeRoot.getWebXml() != null )
        {
            writeWebXml( (WebXml) mergeRoot.getWebXml(), "webXml", serializer );
        }
        serializer.endTag( NAMESPACE, tagName );
    } //-- void writeMergeRoot( MergeRoot, String, XmlSerializer )

    /**
     * Method writeWebXml.
     * 
     * @param webXml
     * @param serializer
     * @param tagName
     * @throws java.io.IOException
     */
    private void writeWebXml( WebXml webXml, String tagName, XmlSerializer serializer )
        throws java.io.IOException
    {
        serializer.startTag( NAMESPACE, tagName );
        if ( webXml.getContextParams() != null )
        {
            ((Xpp3Dom) webXml.getContextParams()).writeToSerializer( NAMESPACE, serializer );
        }
        serializer.endTag( NAMESPACE, tagName );
    } //-- void writeWebXml( WebXml, String, XmlSerializer )

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy