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