View Javadoc
1   /*
2    Licensed to the Apache Software Foundation (ASF) under one
3    or more contributor license agreements.  See the NOTICE file
4    distributed with this work for additional information
5    regarding copyright ownership.  The ASF licenses this file
6    to you under the Apache License, Version 2.0 (the
7    "License"); you may not use this file except in compliance
8    with the License.  You may obtain a copy of the License at
9    
10       http://www.apache.org/licenses/LICENSE-2.0
11   
12   Unless required by applicable law or agreed to in writing,
13   software distributed under the License is distributed on an
14   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   KIND, either express or implied.  See the License for the
16   specific language governing permissions and limitations
17   under the License.
18   =================== DO NOT EDIT THIS FILE ====================
19   Generated by Modello 2.5.1,
20   any modifications will be overwritten.
21   ==============================================================
22   */
23  
24  package org.apache.maven.plugins.invoker.model.io.xpp3;
25  
26    //---------------------------------/
27   //- Imported classes and packages -/
28  //---------------------------------/
29  
30  import java.io.OutputStream;
31  import java.io.Writer;
32  import java.util.Iterator;
33  import org.apache.maven.plugins.invoker.model.BuildJob;
34  import org.codehaus.plexus.util.xml.pull.MXSerializer;
35  import org.codehaus.plexus.util.xml.pull.XmlSerializer;
36  
37  /**
38   * Class BuildJobXpp3Writer.
39   * 
40   * @version $Revision$ $Date$
41   */
42  @SuppressWarnings( "all" )
43  public class BuildJobXpp3Writer
44  {
45  
46        //--------------------------/
47       //- Class/Member Variables -/
48      //--------------------------/
49  
50      /**
51       * Field NAMESPACE.
52       */
53      private static final String NAMESPACE = null;
54  
55      /**
56       * Field fileComment.
57       */
58      private String fileComment = null;
59  
60  
61        //-----------/
62       //- Methods -/
63      //-----------/
64  
65      /**
66       * Method setFileComment.
67       * 
68       * @param fileComment a fileComment object.
69       */
70      public void setFileComment( String fileComment )
71      {
72          this.fileComment = fileComment;
73      } //-- void setFileComment( String )
74  
75      /**
76       * Method write.
77       * 
78       * @param writer a writer object.
79       * @param buildJob a buildJob object.
80       * @throws java.io.IOException java.io.IOException if any.
81       */
82      public void write( Writer writer, BuildJob buildJob )
83          throws java.io.IOException
84      {
85          XmlSerializer serializer = new MXSerializer();
86          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
87          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
88          serializer.setOutput( writer );
89          serializer.startDocument( buildJob.getModelEncoding(), null );
90          writeBuildJob( buildJob, "build-job", serializer );
91          serializer.endDocument();
92      } //-- void write( Writer, BuildJob )
93  
94      /**
95       * Method write.
96       * 
97       * @param stream a stream object.
98       * @param buildJob a buildJob object.
99       * @throws java.io.IOException java.io.IOException if any.
100      */
101     public void write( OutputStream stream, BuildJob buildJob )
102         throws java.io.IOException
103     {
104         XmlSerializer serializer = new MXSerializer();
105         serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
106         serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
107         serializer.setOutput( stream, buildJob.getModelEncoding() );
108         serializer.startDocument( buildJob.getModelEncoding(), null );
109         writeBuildJob( buildJob, "build-job", serializer );
110         serializer.endDocument();
111     } //-- void write( OutputStream, BuildJob )
112 
113     /**
114      * Method writeBuildJob.
115      * 
116      * @param buildJob a buildJob object.
117      * @param serializer a serializer object.
118      * @param tagName a tagName object.
119      * @throws java.io.IOException java.io.IOException if any.
120      */
121     private void writeBuildJob( BuildJob buildJob, String tagName, XmlSerializer serializer )
122         throws java.io.IOException
123     {
124         serializer.startTag( NAMESPACE, tagName );
125         if ( buildJob.getProject() != null )
126         {
127             serializer.attribute( NAMESPACE, "project", buildJob.getProject() );
128         }
129         if ( buildJob.getName() != null )
130         {
131             serializer.attribute( NAMESPACE, "name", buildJob.getName() );
132         }
133         if ( buildJob.getDescription() != null )
134         {
135             serializer.attribute( NAMESPACE, "description", buildJob.getDescription() );
136         }
137         if ( buildJob.getResult() != null )
138         {
139             serializer.attribute( NAMESPACE, "result", buildJob.getResult() );
140         }
141         if ( buildJob.getTime() != 0.0f )
142         {
143             serializer.attribute( NAMESPACE, "time", String.valueOf( buildJob.getTime() ) );
144         }
145         if ( ( buildJob.getType() != null ) && !buildJob.getType().equals( "normal" ) )
146         {
147             serializer.attribute( NAMESPACE, "type", buildJob.getType() );
148         }
149         if ( buildJob.getOrdinal() != 0 )
150         {
151             serializer.attribute( NAMESPACE, "ordinal", String.valueOf( buildJob.getOrdinal() ) );
152         }
153         if ( buildJob.getBuildlog() != null )
154         {
155             serializer.attribute( NAMESPACE, "buildlog", buildJob.getBuildlog() );
156         }
157         if ( buildJob.getFailureMessage() != null )
158         {
159             serializer.startTag( NAMESPACE, "failureMessage" ).text( buildJob.getFailureMessage() ).endTag( NAMESPACE, "failureMessage" );
160         }
161         serializer.endTag( NAMESPACE, tagName );
162     } //-- void writeBuildJob( BuildJob, String, XmlSerializer )
163 
164 }