View Javadoc

1   /*
2    =================== DO NOT EDIT THIS FILE ====================
3    Generated by Modello 1.4.1 on 2013-09-01 13:05:08,
4    any modifications will be overwritten.
5    ==============================================================
6    */
7   
8   package org.apache.maven.plugin.resources.remote.io.xpp3;
9   
10    //---------------------------------/
11   //- Imported classes and packages -/
12  //---------------------------------/
13  
14  import java.io.OutputStream;
15  import java.io.Writer;
16  import java.text.DateFormat;
17  import java.util.Iterator;
18  import java.util.Locale;
19  import org.apache.maven.plugin.resources.remote.Supplement;
20  import org.apache.maven.plugin.resources.remote.SupplementalDataModel;
21  import org.codehaus.plexus.util.xml.Xpp3Dom;
22  import org.codehaus.plexus.util.xml.pull.MXSerializer;
23  import org.codehaus.plexus.util.xml.pull.XmlSerializer;
24  
25  /**
26   * Class SupplementalDataModelXpp3Writer.
27   * 
28   * @version $Revision$ $Date$
29   */
30  @SuppressWarnings( "all" )
31  public class SupplementalDataModelXpp3Writer
32  {
33  
34        //--------------------------/
35       //- Class/Member Variables -/
36      //--------------------------/
37  
38      /**
39       * Field NAMESPACE.
40       */
41      private static final String NAMESPACE = null;
42  
43  
44        //-----------/
45       //- Methods -/
46      //-----------/
47  
48      /**
49       * Method write.
50       * 
51       * @param writer
52       * @param supplementalDataModel
53       * @throws java.io.IOException
54       */
55      public void write( Writer writer, SupplementalDataModel supplementalDataModel )
56          throws java.io.IOException
57      {
58          XmlSerializer serializer = new MXSerializer();
59          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
60          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
61          serializer.setOutput( writer );
62          serializer.startDocument( supplementalDataModel.getModelEncoding(), null );
63          writeSupplementalDataModel( supplementalDataModel, "supplementalDataModels", serializer );
64          serializer.endDocument();
65      } //-- void write( Writer, SupplementalDataModel )
66  
67      /**
68       * Method write.
69       * 
70       * @param stream
71       * @param supplementalDataModel
72       * @throws java.io.IOException
73       */
74      public void write( OutputStream stream, SupplementalDataModel supplementalDataModel )
75          throws java.io.IOException
76      {
77          XmlSerializer serializer = new MXSerializer();
78          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
79          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
80          serializer.setOutput( stream, supplementalDataModel.getModelEncoding() );
81          serializer.startDocument( supplementalDataModel.getModelEncoding(), null );
82          writeSupplementalDataModel( supplementalDataModel, "supplementalDataModels", serializer );
83          serializer.endDocument();
84      } //-- void write( OutputStream, SupplementalDataModel )
85  
86      /**
87       * Method writeSupplement.
88       * 
89       * @param supplement
90       * @param serializer
91       * @param tagName
92       * @throws java.io.IOException
93       */
94      private void writeSupplement( Supplement supplement, String tagName, XmlSerializer serializer )
95          throws java.io.IOException
96      {
97          serializer.startTag( NAMESPACE, tagName );
98          if ( supplement.getProject() != null )
99          {
100             ((Xpp3Dom) supplement.getProject()).writeToSerializer( NAMESPACE, serializer );
101         }
102         serializer.endTag( NAMESPACE, tagName );
103     } //-- void writeSupplement( Supplement, String, XmlSerializer )
104 
105     /**
106      * Method writeSupplementalDataModel.
107      * 
108      * @param supplementalDataModel
109      * @param serializer
110      * @param tagName
111      * @throws java.io.IOException
112      */
113     private void writeSupplementalDataModel( SupplementalDataModel supplementalDataModel, String tagName, XmlSerializer serializer )
114         throws java.io.IOException
115     {
116         serializer.setPrefix( "", "http://maven.apache.org/supplemental-model/1.0.0" );
117         serializer.setPrefix( "xsi", "http://www.w3.org/2001/XMLSchema-instance" );
118         serializer.startTag( NAMESPACE, tagName );
119         serializer.attribute( "", "xsi:schemaLocation", "http://maven.apache.org/supplemental-model/1.0.0 http://maven.apache.org/xsd/supplemental-model-1.0.0.xsd" );
120         if ( ( supplementalDataModel.getSupplement() != null ) && ( supplementalDataModel.getSupplement().size() > 0 ) )
121         {
122             for ( Iterator iter = supplementalDataModel.getSupplement().iterator(); iter.hasNext(); )
123             {
124                 Supplement o = (Supplement) iter.next();
125                 writeSupplement( o, "supplement", serializer );
126             }
127         }
128         serializer.endTag( NAMESPACE, tagName );
129     } //-- void writeSupplementalDataModel( SupplementalDataModel, String, XmlSerializer )
130 
131 }