All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.codehaus.cargo.maven3.io.xpp3.UberWarXpp3Writer Maven / Gradle / Ivy
// =================== DO NOT EDIT THIS FILE ====================
// Generated by Modello 2.0.0,
// any modifications will be overwritten.
// ==============================================================
package org.codehaus.cargo.maven3.io.xpp3;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
import java.io.OutputStream;
import java.io.Writer;
import java.util.Iterator;
import org.codehaus.cargo.maven3.Merge;
import org.codehaus.cargo.maven3.MergeRoot;
import org.codehaus.cargo.maven3.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;
/**
* Field fileComment.
*/
private String fileComment = null;
//-----------/
//- Methods -/
//-----------/
/**
* Method setFileComment.
*
* @param fileComment a fileComment object.
*/
public void setFileComment( String fileComment )
{
this.fileComment = fileComment;
} //-- void setFileComment( String )
/**
* Method write.
*
* @param writer a writer object.
* @param mergeRoot a mergeRoot object.
* @throws java.io.IOException java.io.IOException if any.
*/
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 a stream object.
* @param mergeRoot a mergeRoot object.
* @throws java.io.IOException java.io.IOException if any.
*/
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 a merge object.
* @param serializer a serializer object.
* @param tagName a tagName object.
* @throws java.io.IOException java.io.IOException if any.
*/
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 a mergeRoot object.
* @param serializer a serializer object.
* @param tagName a tagName object.
* @throws java.io.IOException java.io.IOException if any.
*/
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 a webXml object.
* @param serializer a serializer object.
* @param tagName a tagName object.
* @throws java.io.IOException java.io.IOException if any.
*/
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 )
}