org.apache.maven.toolchain.model.io.xpp3.MavenToolchainsXpp3Writer Maven / Gradle / Ivy
The newest version!
// =================== DO NOT EDIT THIS FILE ====================
// Generated by Modello 1.7,
// any modifications will be overwritten.
// ==============================================================
package org.apache.maven.toolchain.model.io.xpp3;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
import java.io.OutputStream;
import java.io.Writer;
import java.util.Iterator;
import org.apache.maven.toolchain.model.PersistedToolchains;
import org.apache.maven.toolchain.model.ToolchainModel;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.pull.MXSerializer;
import org.codehaus.plexus.util.xml.pull.XmlSerializer;
/**
* Class MavenToolchainsXpp3Writer.
*
* @version $Revision$ $Date$
*/
@SuppressWarnings( "all" )
public class MavenToolchainsXpp3Writer
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field NAMESPACE.
*/
private static final String NAMESPACE = null;
//-----------/
//- Methods -/
//-----------/
/**
* Method write.
*
* @param writer
* @param persistedToolchains
* @throws java.io.IOException
*/
public void write( Writer writer, PersistedToolchains persistedToolchains )
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( persistedToolchains.getModelEncoding(), null );
writePersistedToolchains( persistedToolchains, "toolchains", serializer );
serializer.endDocument();
} //-- void write( Writer, PersistedToolchains )
/**
* Method write.
*
* @param stream
* @param persistedToolchains
* @throws java.io.IOException
*/
public void write( OutputStream stream, PersistedToolchains persistedToolchains )
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, persistedToolchains.getModelEncoding() );
serializer.startDocument( persistedToolchains.getModelEncoding(), null );
writePersistedToolchains( persistedToolchains, "toolchains", serializer );
serializer.endDocument();
} //-- void write( OutputStream, PersistedToolchains )
/**
* Method writePersistedToolchains.
*
* @param persistedToolchains
* @param serializer
* @param tagName
* @throws java.io.IOException
*/
private void writePersistedToolchains( PersistedToolchains persistedToolchains, String tagName, XmlSerializer serializer )
throws java.io.IOException
{
serializer.setPrefix( "", "http://maven.apache.org/TOOLCHAINS/1.0.0" );
serializer.setPrefix( "xsi", "http://www.w3.org/2001/XMLSchema-instance" );
serializer.startTag( NAMESPACE, tagName );
serializer.attribute( "", "xsi:schemaLocation", "http://maven.apache.org/TOOLCHAINS/1.0.0 http://maven.apache.org/xsd/toolchains-1.0.0.xsd" );
if ( ( persistedToolchains.getToolchains() != null ) && ( persistedToolchains.getToolchains().size() > 0 ) )
{
for ( Iterator iter = persistedToolchains.getToolchains().iterator(); iter.hasNext(); )
{
ToolchainModel o = (ToolchainModel) iter.next();
writeToolchainModel( o, "toolchain", serializer );
}
}
serializer.endTag( NAMESPACE, tagName );
} //-- void writePersistedToolchains( PersistedToolchains, String, XmlSerializer )
/**
* Method writeToolchainModel.
*
* @param toolchainModel
* @param serializer
* @param tagName
* @throws java.io.IOException
*/
private void writeToolchainModel( ToolchainModel toolchainModel, String tagName, XmlSerializer serializer )
throws java.io.IOException
{
serializer.startTag( NAMESPACE, tagName );
if ( toolchainModel.getType() != null )
{
serializer.startTag( NAMESPACE, "type" ).text( toolchainModel.getType() ).endTag( NAMESPACE, "type" );
}
if ( toolchainModel.getProvides() != null )
{
((Xpp3Dom) toolchainModel.getProvides()).writeToSerializer( NAMESPACE, serializer );
}
if ( toolchainModel.getConfiguration() != null )
{
((Xpp3Dom) toolchainModel.getConfiguration()).writeToSerializer( NAMESPACE, serializer );
}
serializer.endTag( NAMESPACE, tagName );
} //-- void writeToolchainModel( ToolchainModel, String, XmlSerializer )
}