001// =================== DO NOT EDIT THIS FILE ==================== 002// Generated by Modello 1.8.1, 003// any modifications will be overwritten. 004// ============================================================== 005 006package org.apache.maven.plugin.tools.model.io.xpp3; 007 008 //---------------------------------/ 009 //- Imported classes and packages -/ 010//---------------------------------/ 011 012import java.io.OutputStream; 013import java.io.Writer; 014import java.util.Iterator; 015import org.apache.maven.plugin.tools.model.Component; 016import org.apache.maven.plugin.tools.model.LifecycleExecution; 017import org.apache.maven.plugin.tools.model.Mojo; 018import org.apache.maven.plugin.tools.model.Parameter; 019import org.apache.maven.plugin.tools.model.PluginMetadata; 020import org.codehaus.plexus.util.xml.pull.MXSerializer; 021import org.codehaus.plexus.util.xml.pull.XmlSerializer; 022 023/** 024 * Class PluginMetadataXpp3Writer. 025 * 026 * @version $Revision: 907040 $ $Date: 2014-04-27 09:50:12 +0000 (Sun, 27 Apr 2014) $ 027 */ 028@SuppressWarnings( "all" ) 029public class PluginMetadataXpp3Writer 030{ 031 032 //--------------------------/ 033 //- Class/Member Variables -/ 034 //--------------------------/ 035 036 /** 037 * Field NAMESPACE. 038 */ 039 private static final String NAMESPACE = null; 040 041 042 //-----------/ 043 //- Methods -/ 044 //-----------/ 045 046 /** 047 * Method write. 048 * 049 * @param writer 050 * @param pluginMetadata 051 * @throws java.io.IOException 052 */ 053 public void write( Writer writer, PluginMetadata pluginMetadata ) 054 throws java.io.IOException 055 { 056 XmlSerializer serializer = new MXSerializer(); 057 serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", " " ); 058 serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" ); 059 serializer.setOutput( writer ); 060 serializer.startDocument( pluginMetadata.getModelEncoding(), null ); 061 writePluginMetadata( pluginMetadata, "pluginMetadata", serializer ); 062 serializer.endDocument(); 063 } //-- void write( Writer, PluginMetadata ) 064 065 /** 066 * Method write. 067 * 068 * @param stream 069 * @param pluginMetadata 070 * @throws java.io.IOException 071 */ 072 public void write( OutputStream stream, PluginMetadata pluginMetadata ) 073 throws java.io.IOException 074 { 075 XmlSerializer serializer = new MXSerializer(); 076 serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", " " ); 077 serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" ); 078 serializer.setOutput( stream, pluginMetadata.getModelEncoding() ); 079 serializer.startDocument( pluginMetadata.getModelEncoding(), null ); 080 writePluginMetadata( pluginMetadata, "pluginMetadata", serializer ); 081 serializer.endDocument(); 082 } //-- void write( OutputStream, PluginMetadata ) 083 084 /** 085 * Method writeComponent. 086 * 087 * @param component 088 * @param serializer 089 * @param tagName 090 * @throws java.io.IOException 091 */ 092 private void writeComponent( Component component, String tagName, XmlSerializer serializer ) 093 throws java.io.IOException 094 { 095 serializer.startTag( NAMESPACE, tagName ); 096 if ( component.getRole() != null ) 097 { 098 serializer.startTag( NAMESPACE, "role" ).text( component.getRole() ).endTag( NAMESPACE, "role" ); 099 } 100 if ( component.getHint() != null ) 101 { 102 serializer.startTag( NAMESPACE, "hint" ).text( component.getHint() ).endTag( NAMESPACE, "hint" ); 103 } 104 serializer.endTag( NAMESPACE, tagName ); 105 } //-- void writeComponent( Component, String, XmlSerializer ) 106 107 /** 108 * Method writeLifecycleExecution. 109 * 110 * @param lifecycleExecution 111 * @param serializer 112 * @param tagName 113 * @throws java.io.IOException 114 */ 115 private void writeLifecycleExecution( LifecycleExecution lifecycleExecution, String tagName, XmlSerializer serializer ) 116 throws java.io.IOException 117 { 118 serializer.startTag( NAMESPACE, tagName ); 119 if ( lifecycleExecution.getLifecycle() != null ) 120 { 121 serializer.startTag( NAMESPACE, "lifecycle" ).text( lifecycleExecution.getLifecycle() ).endTag( NAMESPACE, "lifecycle" ); 122 } 123 if ( lifecycleExecution.getPhase() != null ) 124 { 125 serializer.startTag( NAMESPACE, "phase" ).text( lifecycleExecution.getPhase() ).endTag( NAMESPACE, "phase" ); 126 } 127 if ( lifecycleExecution.getGoal() != null ) 128 { 129 serializer.startTag( NAMESPACE, "goal" ).text( lifecycleExecution.getGoal() ).endTag( NAMESPACE, "goal" ); 130 } 131 serializer.endTag( NAMESPACE, tagName ); 132 } //-- void writeLifecycleExecution( LifecycleExecution, String, XmlSerializer ) 133 134 /** 135 * Method writeMojo. 136 * 137 * @param mojo 138 * @param serializer 139 * @param tagName 140 * @throws java.io.IOException 141 */ 142 private void writeMojo( Mojo mojo, String tagName, XmlSerializer serializer ) 143 throws java.io.IOException 144 { 145 serializer.startTag( NAMESPACE, tagName ); 146 if ( mojo.getGoal() != null ) 147 { 148 serializer.startTag( NAMESPACE, "goal" ).text( mojo.getGoal() ).endTag( NAMESPACE, "goal" ); 149 } 150 if ( mojo.getPhase() != null ) 151 { 152 serializer.startTag( NAMESPACE, "phase" ).text( mojo.getPhase() ).endTag( NAMESPACE, "phase" ); 153 } 154 if ( mojo.isAggregator() != false ) 155 { 156 serializer.startTag( NAMESPACE, "aggregator" ).text( String.valueOf( mojo.isAggregator() ) ).endTag( NAMESPACE, "aggregator" ); 157 } 158 if ( mojo.getRequiresDependencyResolution() != null ) 159 { 160 serializer.startTag( NAMESPACE, "requiresDependencyResolution" ).text( mojo.getRequiresDependencyResolution() ).endTag( NAMESPACE, "requiresDependencyResolution" ); 161 } 162 if ( mojo.isRequiresProject() != false ) 163 { 164 serializer.startTag( NAMESPACE, "requiresProject" ).text( String.valueOf( mojo.isRequiresProject() ) ).endTag( NAMESPACE, "requiresProject" ); 165 } 166 if ( mojo.isRequiresReports() != false ) 167 { 168 serializer.startTag( NAMESPACE, "requiresReports" ).text( String.valueOf( mojo.isRequiresReports() ) ).endTag( NAMESPACE, "requiresReports" ); 169 } 170 if ( mojo.isRequiresOnline() != false ) 171 { 172 serializer.startTag( NAMESPACE, "requiresOnline" ).text( String.valueOf( mojo.isRequiresOnline() ) ).endTag( NAMESPACE, "requiresOnline" ); 173 } 174 if ( mojo.isInheritByDefault() != false ) 175 { 176 serializer.startTag( NAMESPACE, "inheritByDefault" ).text( String.valueOf( mojo.isInheritByDefault() ) ).endTag( NAMESPACE, "inheritByDefault" ); 177 } 178 if ( mojo.isRequiresDirectInvocation() != false ) 179 { 180 serializer.startTag( NAMESPACE, "requiresDirectInvocation" ).text( String.valueOf( mojo.isRequiresDirectInvocation() ) ).endTag( NAMESPACE, "requiresDirectInvocation" ); 181 } 182 if ( mojo.getExecution() != null ) 183 { 184 writeLifecycleExecution( (LifecycleExecution) mojo.getExecution(), "execution", serializer ); 185 } 186 if ( ( mojo.getComponents() != null ) && ( mojo.getComponents().size() > 0 ) ) 187 { 188 serializer.startTag( NAMESPACE, "components" ); 189 for ( Iterator iter = mojo.getComponents().iterator(); iter.hasNext(); ) 190 { 191 Component o = (Component) iter.next(); 192 writeComponent( o, "component", serializer ); 193 } 194 serializer.endTag( NAMESPACE, "components" ); 195 } 196 if ( ( mojo.getParameters() != null ) && ( mojo.getParameters().size() > 0 ) ) 197 { 198 serializer.startTag( NAMESPACE, "parameters" ); 199 for ( Iterator iter = mojo.getParameters().iterator(); iter.hasNext(); ) 200 { 201 Parameter o = (Parameter) iter.next(); 202 writeParameter( o, "parameter", serializer ); 203 } 204 serializer.endTag( NAMESPACE, "parameters" ); 205 } 206 if ( mojo.getDescription() != null ) 207 { 208 serializer.startTag( NAMESPACE, "description" ).text( mojo.getDescription() ).endTag( NAMESPACE, "description" ); 209 } 210 if ( mojo.getDeprecation() != null ) 211 { 212 serializer.startTag( NAMESPACE, "deprecated" ).text( mojo.getDeprecation() ).endTag( NAMESPACE, "deprecated" ); 213 } 214 if ( mojo.getSince() != null ) 215 { 216 serializer.startTag( NAMESPACE, "since" ).text( mojo.getSince() ).endTag( NAMESPACE, "since" ); 217 } 218 if ( mojo.getCall() != null ) 219 { 220 serializer.startTag( NAMESPACE, "call" ).text( mojo.getCall() ).endTag( NAMESPACE, "call" ); 221 } 222 serializer.endTag( NAMESPACE, tagName ); 223 } //-- void writeMojo( Mojo, String, XmlSerializer ) 224 225 /** 226 * Method writeParameter. 227 * 228 * @param parameter 229 * @param serializer 230 * @param tagName 231 * @throws java.io.IOException 232 */ 233 private void writeParameter( Parameter parameter, String tagName, XmlSerializer serializer ) 234 throws java.io.IOException 235 { 236 serializer.startTag( NAMESPACE, tagName ); 237 if ( parameter.getName() != null ) 238 { 239 serializer.startTag( NAMESPACE, "name" ).text( parameter.getName() ).endTag( NAMESPACE, "name" ); 240 } 241 if ( parameter.getAlias() != null ) 242 { 243 serializer.startTag( NAMESPACE, "alias" ).text( parameter.getAlias() ).endTag( NAMESPACE, "alias" ); 244 } 245 if ( parameter.getProperty() != null ) 246 { 247 serializer.startTag( NAMESPACE, "property" ).text( parameter.getProperty() ).endTag( NAMESPACE, "property" ); 248 } 249 if ( parameter.isRequired() != false ) 250 { 251 serializer.startTag( NAMESPACE, "required" ).text( String.valueOf( parameter.isRequired() ) ).endTag( NAMESPACE, "required" ); 252 } 253 if ( parameter.isReadonly() != false ) 254 { 255 serializer.startTag( NAMESPACE, "readonly" ).text( String.valueOf( parameter.isReadonly() ) ).endTag( NAMESPACE, "readonly" ); 256 } 257 if ( parameter.getExpression() != null ) 258 { 259 serializer.startTag( NAMESPACE, "expression" ).text( parameter.getExpression() ).endTag( NAMESPACE, "expression" ); 260 } 261 if ( parameter.getDefaultValue() != null ) 262 { 263 serializer.startTag( NAMESPACE, "defaultValue" ).text( parameter.getDefaultValue() ).endTag( NAMESPACE, "defaultValue" ); 264 } 265 if ( parameter.getType() != null ) 266 { 267 serializer.startTag( NAMESPACE, "type" ).text( parameter.getType() ).endTag( NAMESPACE, "type" ); 268 } 269 if ( parameter.getDescription() != null ) 270 { 271 serializer.startTag( NAMESPACE, "description" ).text( parameter.getDescription() ).endTag( NAMESPACE, "description" ); 272 } 273 if ( parameter.getDeprecation() != null ) 274 { 275 serializer.startTag( NAMESPACE, "deprecated" ).text( parameter.getDeprecation() ).endTag( NAMESPACE, "deprecated" ); 276 } 277 if ( parameter.getSince() != null ) 278 { 279 serializer.startTag( NAMESPACE, "since" ).text( parameter.getSince() ).endTag( NAMESPACE, "since" ); 280 } 281 serializer.endTag( NAMESPACE, tagName ); 282 } //-- void writeParameter( Parameter, String, XmlSerializer ) 283 284 /** 285 * Method writePluginMetadata. 286 * 287 * @param pluginMetadata 288 * @param serializer 289 * @param tagName 290 * @throws java.io.IOException 291 */ 292 private void writePluginMetadata( PluginMetadata pluginMetadata, String tagName, XmlSerializer serializer ) 293 throws java.io.IOException 294 { 295 serializer.startTag( NAMESPACE, tagName ); 296 if ( ( pluginMetadata.getMojos() != null ) && ( pluginMetadata.getMojos().size() > 0 ) ) 297 { 298 serializer.startTag( NAMESPACE, "mojos" ); 299 for ( Iterator iter = pluginMetadata.getMojos().iterator(); iter.hasNext(); ) 300 { 301 Mojo o = (Mojo) iter.next(); 302 writeMojo( o, "mojo", serializer ); 303 } 304 serializer.endTag( NAMESPACE, "mojos" ); 305 } 306 serializer.endTag( NAMESPACE, tagName ); 307 } //-- void writePluginMetadata( PluginMetadata, String, XmlSerializer ) 308 309}