View Javadoc

1   /*
2    * Copyright 2005 The Codehaus.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.codehaus.mojo.castor;
17  
18  import java.io.File;
19  import java.io.FileNotFoundException;
20  import java.io.IOException;
21  import java.lang.reflect.InvocationTargetException;
22  import java.lang.reflect.Method;
23  import java.util.HashSet;
24  import java.util.Iterator;
25  import java.util.Set;
26  
27  import org.apache.maven.model.Resource;
28  import org.apache.maven.plugin.AbstractMojo;
29  import org.apache.maven.plugin.MojoExecutionException;
30  import org.apache.maven.plugins.annotations.LifecyclePhase;
31  import org.apache.maven.plugins.annotations.Mojo;
32  import org.apache.maven.plugins.annotations.Parameter;
33  import org.apache.maven.project.MavenProject;
34  import org.codehaus.plexus.compiler.util.scan.InclusionScanException;
35  import org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner;
36  import org.codehaus.plexus.compiler.util.scan.StaleSourceScanner;
37  import org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping;
38  import org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping;
39  import org.codehaus.plexus.util.FileUtils;
40  import org.exolab.castor.builder.conflictresolution.WarningViaDialogClassNameCRStrategy;
41  import org.exolab.castor.util.Version;
42  
43  /**
44   * A mojo that uses Castor to generate a collection of javabeans from an XSD. Detailed explanations of many of these can
45   * be found in the details for the Castor <a href="http://castor.codehaus.org/sourcegen.html">SourceGenerator</a>.
46   * 
47   * @author brozow <brozow@opennms.org>
48   * @author jesse <jesse.mcconnell@gmail.com>
49   */
50  @Mojo(name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
51  public class GenerateMojo extends AbstractMojo
52  {
53  
54      /**
55       * Output message to indicate that class descriptor generation is disabled.
56       */
57      private static final String DISABLE_DESCRIPTORS_MSG = "Disabling generation of Class descriptors";
58  
59      /**
60       * Output message to indicate that generation of marshaling framework methods is disabled.
61       */
62      private static final String DISABLE_MARSHALL_MSG =
63          "Disabling generation of Marshalling framework methods (marshall, unmarshall, validate).";
64  
65      /**
66       * Default location of castorbuilder.properties file.
67       */
68      private static final String DEFAULT_PROPERTY_FILE_LOCATION = "src/main/castor/castorbuilder.properties";
69  
70      /**
71       * The binding file to use for mapping xml to java.
72       */
73      @Parameter(property = "bindingFile", defaultValue = "${basedir}/src/main/castor/bindings.xml")
74      private File bindingfile;
75  
76      /**
77       * A schema file to process. If this is not set then all .xsd files in schemaDirectory will be processed.
78       */
79      @Parameter(property = "schema")
80      private File schema;
81  
82      /**
83       * The source directory containing *.xsd files
84       */
85      @Parameter(property = "schemaDirectory", defaultValue = "${basedir}/src/main/castor")
86      private File schemaDirectory;
87  
88      /**
89       * The directory to output the generated sources to
90       * 
91       * @todo This would be better as outputDirectory but for backward compatibility I left it as dest
92       */
93      @Parameter(property = "dest", defaultValue = "${project.build.directory}/generated-sources/castor")
94      private File dest;
95  
96      /**
97       * The directory to store the processed xsds. The timestamps of these xsds are used to determine if the source for
98       * that xsd need to be regenerated
99       * 
100      * @todo timestampDirectory would be a better name for this. Used this name for backward compatibility
101      */
102     @Parameter(property = "tstamp", defaultValue = "${project.build.directory}/xsds")
103     private File tstamp;
104 
105     /**
106      * The granularity in milliseconds of the last modification date for testing whether a source needs recompilation
107      */
108     @Parameter(property = "staleMillis", defaultValue = "0")
109     private int staleMillis = 0;
110 
111     /**
112      * Castor collection types. Allowable values are 'vector', 'arraylist', 'j2' or 'odmg' 'j2' and 'arraylist' are the
113      * same.
114      * 
115      * @parameter default-value="arraylist";
116      */
117     @Parameter(property = "types", defaultValue = "arraylist")
118     private String types = "arraylist";
119 
120     /**
121      * If true, generate descriptors
122      */
123     @Parameter(property = "descriptors", defaultValue = "true")
124     private boolean descriptors = true;
125 
126     /**
127      * Verbose output during generation
128      */
129     @Parameter(property = "verbose", defaultValue = "false")
130     private boolean verbose = false;
131 
132     /**
133      * Enable warning messages
134      */
135     @Parameter(property = "warnings", defaultValue = "false")
136     private boolean warnings = false;
137 
138     /**
139      * if false, don't generate the marshaller
140      */
141     @Parameter(property = "marshal", defaultValue = "true")
142     private boolean marshal = true;
143 
144     /**
145      * The line separator to use in generated source. Can be either win, unix, or mac
146      * 
147      * @parameter
148      */
149     @Parameter(property = "lineSeparator")
150     private String lineSeparator;
151 
152     /**
153      * The castorbuilder.properties file to use
154      */
155     @Parameter(property = "properties", defaultValue = "${basedir}/src/main/castor/castorbuilder.properties")
156     private File properties;
157 
158     /**
159      * The package for the generated source
160      */
161     @Parameter(property = "packaging")
162     private String packaging;
163 
164     /**
165      * The name of the strategy to use for handling name conflicts.
166      * Can be either warnViaConsoleDialog or informViaLog
167      */
168     @Parameter(property = "nameConflictStrategy", defaultValue = WarningViaDialogClassNameCRStrategy.NAME)
169     private String nameConflictStrategy = WarningViaDialogClassNameCRStrategy.NAME;
170 
171     /**
172      * Whether to generate Java classes from imported XML schemas or not.
173      */
174     @Parameter(property = "generateImportedSchemas", defaultValue = "false")
175     private boolean generateImportedSchemas = false;
176 
177     /**
178      * Set to <tt>true</tt> to generate Castor XML class mappings for the Java classes generated by the XML code
179      * generator from imported XML schemas.
180      */
181     @Parameter(property = "generateMappings", defaultValue = "false")
182     private boolean generateMappings = false;
183 
184     /**
185      * The method to use for Java class generation; possible values are 'standard' (default) and 'velocity'.
186      * 
187      * @parameter default-value="standard"
188      */
189     @Parameter(property = "classGenerationMode", defaultValue = "standard")
190     private String classGenerationMode = "standard";
191 
192     /**
193      * The (optional) directory to output generated <b>resources</b> files to.
194      */
195     @Parameter(property = "resourceDestination", defaultValue = "${project.build.directory}/generated-sources/castor")
196     private File resourceDestination;
197 
198     /**
199      * Whether to generate JDO-specific descriptor classes or not.
200      */
201     @Parameter(property = "createJdoDescriptors", defaultValue = "false")
202     private boolean createJdoDescriptors = false;
203 
204     /**
205      * The Maven project to act upon.
206      * 
207      * @required
208      */
209     @Parameter(property = "project", defaultValue = "${project}", required = true)
210     private MavenProject project;
211 
212     /**
213      * {@link SourceGenerator} instance used for code generation.
214      * 
215      * @see SourceGenerator#generateSource(org.xml.sax.InputSource, String)
216      */
217     private CastorSourceGenerator sgen;
218 
219     /**
220      * {@inheritDoc}
221      * 
222      * @see org.apache.maven.plugin.AbstractMojo#execute()
223      */
224     public void execute()
225         throws MojoExecutionException
226     {
227 
228         if ( !dest.exists() )
229         {
230             FileUtils.mkdir( dest.getAbsolutePath() );
231         }
232 
233         if ( !resourceDestination.exists() )
234         {
235             FileUtils.mkdir( resourceDestination.getAbsolutePath() );
236         }
237 
238         Set<File> staleXSDs = computeStaleXSDs();
239 
240         if ( staleXSDs.isEmpty() )
241         {
242             getLog().info( "Nothing to process - all xsds are up to date" );
243 
244             // adding generated sources to Maven project
245             project.addCompileSourceRoot( dest.getAbsolutePath() );
246 
247             // adding resources directory to Maven project
248             getLog().info( "Adding resource " + getResourceDestination().getAbsolutePath() + " ... " );
249             Resource resource = new Resource();
250             resource.setDirectory( getResourceDestination().getAbsolutePath() );
251             resource.addInclude( "**/*.cdr" );
252             resource.addExclude( "**/*.java" );
253             project.addResource( resource );
254 
255             return;
256         }
257 
258         config();
259 
260         for ( Iterator<File> i = staleXSDs.iterator(); i.hasNext(); )
261         {
262             File xsd = (File) i.next();
263 
264             try
265             {
266 
267                 processFile( xsd.getCanonicalPath() );
268 
269                 // copy stale xsd to timestamp directory within the same relative path
270                 File timeStampDir = getTimeStampDirectory();
271                 // make sure this is after the actual processing,
272                 // otherwise it if fails the computeStaleXSDs will think it completed.
273                 FileUtils.copyFileToDirectory( xsd, timeStampDir );
274             }
275             catch ( Exception e )
276             {
277                 throw new MojoExecutionException( "Castor execution failed", e );
278             }
279             catch ( Throwable t )
280             {
281                 throw new MojoExecutionException( "Castor execution failed", t );
282             }
283         }
284 
285         if ( project != null )
286         {
287             project.addCompileSourceRoot( dest.getAbsolutePath() );
288 
289             // adding resources directory to Maven project
290             getLog().info( "Adding resource " + getResourceDestination().getAbsolutePath() + " ... " );
291             Resource resource = new Resource();
292             resource.setDirectory( getResourceDestination().getAbsolutePath() );
293             resource.addInclude( "**/*.cdr" );
294             resource.addExclude( "**/*.java" );
295             project.addResource( resource );
296         }
297 
298     }
299 
300     /**
301      * Computes the collection of <i>stale</i> XML schemas for which sources need to be re-generated.
302      * 
303      * @return A set of XML schemas for which sources need to be re-generated.
304      * @throws MojoExecutionException If there's a problem with scanning all potential XML schemas.
305      */
306     private Set<File> computeStaleXSDs()
307         throws MojoExecutionException
308     {
309         Set<File> staleSources = new HashSet<File>();
310 
311         if ( schema != null && schema.exists() )
312         {
313             File sourceFile = schema;
314             File targetFile = new File( getTimeStampDirectory(), sourceFile.getName() );
315             if ( !targetFile.exists() || ( targetFile.lastModified() + staleMillis < sourceFile.lastModified() ) )
316             {
317                 getLog().debug( "Finding XSDs - adding schema " + targetFile );
318                 staleSources.add( sourceFile );
319             }
320             else
321             {
322                 getLog().debug( "Finding XSDs - adding schema " + targetFile );
323             }
324         }
325         else
326         {
327             SourceMapping mapping = new SuffixMapping( ".xsd", ".xsd" );
328 
329             File tstampDir = getTimeStampDirectory();
330 
331             File schemaDir = schemaDirectory;
332 
333             SourceInclusionScanner scanner = getSourceInclusionScanner();
334 
335             scanner.addSourceMapping( mapping );
336 
337             try
338             {
339                 getLog().debug(
340                                 "Finding XSDs - adding scanned XSDs from schemaDir " + schemaDir + " tstampDir "
341                                     + tstampDir );
342                 staleSources.addAll( scanner.getIncludedSources( schemaDir, tstampDir ) );
343             }
344             catch ( InclusionScanException e )
345             {
346                 throw new MojoExecutionException( "Error scanning source root: \'" + schemaDir
347                     + "\' for stale xsds to reprocess.", e );
348             }
349         }
350 
351         return staleSources;
352     }
353 
354     /**
355      * Returns a {@link SourceInclusionScanner} instance.
356      * 
357      * @return A {@link SourceInclusionScanner} instance.
358      */
359     private SourceInclusionScanner getSourceInclusionScanner()
360     {
361         return new StaleSourceScanner( staleMillis );
362     }
363 
364     /**
365      * Returns the location where timestamp information is recorded.
366      * 
367      * @return the location where timestamp information is recorded.
368      */
369     private File getTimeStampDirectory()
370     {
371         return tstamp;
372     }
373 
374     /**
375      * Entry point for configuring the underlying Castor XML code generator based upon the plugin configuration.
376      * 
377      * @throws MojoExecutionException If there's a problem accessing resources as specified in the plugin configuration.
378      */
379     private void config()
380         throws MojoExecutionException
381     {
382         sgen = CastorSourceGenerator.createSourceGenerator( types );
383 
384         if ( getLog().isInfoEnabled() )
385         {
386             getLog().info(
387                            "Successfully created an instance of the Castor XML source generator, release "
388                                + Version.VERSION );
389         }
390 
391         sgen.setLog( getLog() );
392 
393         sgen.setLineSeparatorStyle( lineSeparator );
394 
395         sgen.setDestDir( dest.getAbsolutePath() );
396 
397         callSetterMethodUsingReflection( "setResourceDestination", String.class,
398                                          getResourceDestination().getAbsolutePath() );
399 
400         if ( bindingfile != null && bindingfile.exists() )
401         {
402             sgen.setBindingFile( bindingfile );
403         }
404 
405         sgen.setVerbose( verbose );
406 
407         sgen.setSuppressNonFatalWarnings( !warnings );
408 
409         sgen.setDescriptorCreation( descriptors );
410         if ( !descriptors )
411         {
412             log( DISABLE_DESCRIPTORS_MSG );
413         }
414 
415         sgen.setCreateMarshalMethods( marshal );
416         if ( !marshal )
417         {
418             log( DISABLE_MARSHALL_MSG );
419         }
420 
421         if ( properties != null && properties.exists() )
422         {
423             sgen.setBuilderProperties( properties );
424         }
425         else
426         {
427             File defaultPropertyFile = new File( getProject().getBasedir(), DEFAULT_PROPERTY_FILE_LOCATION );
428             if ( properties != null && !properties.equals( defaultPropertyFile ) )
429             {
430                 getLog().warn( "Cannot find custom builder property file " + properties.getAbsolutePath() );
431                 throw new MojoExecutionException( "Cannot find custom builder property file "
432                     + properties.getAbsolutePath() );
433             }
434             else if ( properties != null )
435             {
436                 getLog().info(
437                                "There is no custom builder property file at " + "the default location at "
438                                    + properties.getAbsolutePath() + ". Continuing code generation without." );
439             }
440         }
441 
442         if ( createJdoDescriptors == true )
443         {
444             callSetterMethodUsingReflection( "setJdoDescriptorCreation", boolean.class,
445                                              new Boolean( createJdoDescriptors ) );
446         }
447 
448         if ( isGenerateImportedSchemas() == true )
449         {
450             sgen.setGenerateImportedSchemas( true );
451         }
452 
453         if ( generateMapping() == true )
454         {
455             sgen.setGenerateMappingFile( this.generateMappings );
456             sgen.setDescriptorCreation( false );
457         }
458 
459         if ( !getClassGenerationMode().equals( "standard" ) )
460         {
461             callSetterMethodUsingReflection( "setJClassPrinterType", String.class, getClassGenerationMode() );
462         }
463         
464         sgen.setNameConflictStrategy( this.nameConflictStrategy );
465 
466     }
467 
468     /**
469      * Helper method to invoke a setter method on SourceGenerator that might not be available due to a version issue.
470      * 
471      * @param methodName Name of the method
472      * @param parameterType Type of the method parameter.
473      * @param parameterValue Actual parameter value to be used during method invocation.
474      * @throws MojoExecutionException If the method cannot be invoked.
475      */
476     private void callSetterMethodUsingReflection( final String methodName, final Class<?> parameterType,
477                                                   final Object parameterValue )
478         throws MojoExecutionException
479     {
480         getLog().info(
481                        "About to invoke method >" + methodName
482                            + "< on Castor's SourceGenerator class using reflection." );
483         try
484         {
485             Method method = sgen.getClass().getMethod( methodName, new Class[] { parameterType } );
486             method.invoke( sgen, new Object[] { parameterValue } );
487         }
488         catch ( NoSuchMethodException e )
489         {
490             getLog().info( "Specified method " + methodName + " not available on class SourceGenerator." );
491             // unable to find method to configure JDO descriptor creation.
492         }
493         catch ( IllegalArgumentException e )
494         {
495             throw new MojoExecutionException( "Problem calling SourceGenerator." + methodName + ": ", e );
496         }
497         catch ( IllegalAccessException e )
498         {
499             throw new MojoExecutionException( "Problem calling SourceGenerator." + methodName + ": ", e );
500         }
501         catch ( InvocationTargetException e )
502         {
503             throw new MojoExecutionException( "Problem calling SourceGenerator." + methodName + ": ", e );
504         }
505     }
506 
507     /**
508      * Run source generation on the {@link File} soecified.
509      * 
510      * @param filePath The XML schema file (path) to be processed.
511      * @throws MojoExecutionException If there's a problem related to executing this mojo.
512      */
513     private void processFile( String filePath )
514         throws MojoExecutionException
515     {
516         log( "Processing " + filePath );
517         try
518         {
519             sgen.generateSource( filePath, packaging );
520         }
521         catch ( FileNotFoundException e )
522         {
523             String message = "XML Schema file \"" + filePath + "\" not found.";
524             log( message );
525             throw new MojoExecutionException( message );
526         }
527         catch ( IOException iox )
528         {
529             throw new MojoExecutionException( "An IOException occurred processing " + filePath, iox );
530         }
531         catch ( Exception e )
532         {
533             throw new MojoExecutionException( "An Exception occurred processing " + filePath, e );
534         }
535     }
536 
537     /**
538      * Logs a message to the logger.
539      * 
540      * @param msg The message ot be logged.
541      */
542     private void log( final String msg )
543     {
544         getLog().info( msg );
545     }
546 
547     /**
548      * Returns the destination directory to used during code generation.
549      * 
550      * @return the destination directory to used during code generation.
551      */
552     public File getDest()
553     {
554         return dest;
555     }
556 
557     /**
558      * Returns the destination directory for resource files generated during code generation.
559      * 
560      * @return the destination directory for resource files.
561      */
562     public File getResourceDestination()
563     {
564         return this.resourceDestination;
565     }
566 
567     /**
568      * Sets the destination directory to used during code generation.
569      * 
570      * @param dest the destination directory to used during code generation.
571      */
572     public void setDest( final File dest )
573     {
574         this.dest = dest;
575     }
576 
577     /**
578      * Sets the destination directory for resource files generated during code generation.
579      * 
580      * @param resourceDestination the destination directory for generated resource files.
581      */
582     public void setResourceDestination( final File resourceDestination )
583     {
584         this.resourceDestination = resourceDestination;
585     }
586 
587     /**
588      * Returns the directory to store time stamp information.
589      * 
590      * @return the directory to store time stamp information.
591      */
592     public File getTstamp()
593     {
594         return tstamp;
595     }
596 
597     /**
598      * Sets the directory to store time stamp information.
599      * 
600      * @param tstamp the directory to store time stamp information.
601      */
602     public void setTstamp( final File tstamp )
603     {
604         this.tstamp = tstamp;
605     }
606 
607     /**
608      * Returns the default package to be used during code generation.
609      * 
610      * @return the default package to be used during code generation.
611      */
612     public String getPackaging()
613     {
614         return packaging;
615     }
616 
617     /**
618      * Sets the default package to be used during code generation.
619      * 
620      * @param packaging the default package to be used during code generation.
621      */
622     public void setPackaging( final String packaging )
623     {
624         this.packaging = packaging;
625     }
626 
627     /**
628      * Returns the name conflict strategy to be used during code generation.
629      * 
630      * @return the name conflict strategy to be used during code generation.
631      */
632     public String getNameConflictStrategy()
633     {
634 		return nameConflictStrategy;
635 	}
636 
637     /**
638      * Sets the name conflict strategy to be used during code generation.
639      * 
640      * @param nameConflictStrategy the name conflict strategy to be used during code generation.
641      */
642 	public void setNameConflictStrategy( final String nameConflictStrategy )
643 	{
644 		this.nameConflictStrategy = nameConflictStrategy;
645 	}
646 
647 	/**
648      * Returns the (single) XML schema file to be processed.
649      * 
650      * @return the (single) XML schema file to be processed.
651      */
652     public File getSchema()
653     {
654         return schema;
655     }
656 
657     /**
658      * Sets the (single) XML schema file to be processed.
659      * 
660      * @param schema the (single) XML schema file to be processed.
661      */
662     public void setSchema( final File schema )
663     {
664         this.schema = schema;
665     }
666 
667     /**
668      * Returns the collection types Castor XML is capable of working with.
669      * 
670      * @return the collection types Castor XML is capable of working with.
671      */
672     public String getTypes()
673     {
674         return types;
675     }
676 
677     /**
678      * Sets the collection types Castor XML is capable of working with.
679      * 
680      * @param types the collection types Castor XML is capable of working with.
681      */
682     public void setTypes( final String types )
683     {
684         this.types = types;
685     }
686 
687     /**
688      * Sets the Castor XML code generator binding file to be used during code generation.
689      * 
690      * @param bindingfile the Castor XML code generator binding file to be used during code generation.
691      */
692     public void setBindingfile( final File bindingfile )
693     {
694         this.bindingfile = bindingfile;
695     }
696 
697     /**
698      * Sets the (user-specific) <tt>castorbuilder.properties</tt> file to be used during code generation.
699      * 
700      * @param properties the (user-specific) <tt>castorbuilder.properties</tt> file to be used during code generation.
701      */
702     public void setProperties( final File properties )
703     {
704         this.properties = properties;
705     }
706 
707     /**
708      * Indicates whether #marshal() methods will be generated during the code generation.
709      * 
710      * @return True if #marshal() methods will be generated during the code generation.
711      */
712     public boolean getMarshal()
713     {
714         return marshal;
715     }
716 
717     /**
718      * Sets whether #marshal() methods will be generated during the code generation.
719      * 
720      * @param marshal True if #marshal() methods will be generated during the code generation.
721      */
722     public void setMarshal( final boolean marshal )
723     {
724         this.marshal = marshal;
725     }
726 
727     /**
728      * Indicates whether code should be generated for imported XML schemas as well.
729      * 
730      * @return True if code should be generated for imported XML schemas as well.
731      */
732     public boolean isGenerateImportedSchemas()
733     {
734         return generateImportedSchemas;
735     }
736 
737     /**
738      * Sets whether code should be generated for imported XML schemas as well.
739      * 
740      * @param generateImportedSchemas True if code should be generated for imported XML schemas as well.
741      */
742     public void setGenerateImportedSchemas( final boolean generateImportedSchemas )
743     {
744         this.generateImportedSchemas = generateImportedSchemas;
745     }
746 
747     /**
748      * Returns the {@link MavenProject} instance for which code generation should be executed.
749      * 
750      * @return the {@link MavenProject} instance for which code generation should be executed.
751      */
752     public MavenProject getProject()
753     {
754         return project;
755     }
756 
757     /**
758      * Sets the {@link MavenProject} instance for which code generation should be executed.
759      * 
760      * @param project the {@link MavenProject} instance for which code generation should be executed.
761      */
762     public void setProject( MavenProject project )
763     {
764         this.project = project;
765     }
766 
767     /**
768      * Indicates whether JDO descriptors should be generated during code generation.
769      * 
770      * @return True if JDO descriptors should be generated during code generation.
771      */
772     public final boolean getCreateJdoDescriptors()
773     {
774         return createJdoDescriptors;
775     }
776 
777     /**
778      * Sets whether JDO descriptors should be generated during code generation.
779      * 
780      * @param newCreateJdoDescriptors True if JDO descriptors should be generated during code generation.
781      */
782     public final void setCreateJdoDescriptors( final boolean newCreateJdoDescriptors )
783     {
784         this.createJdoDescriptors = newCreateJdoDescriptors;
785     }
786 
787     /**
788      * Indicates whether mapping files should be created during code generation.
789      * 
790      * @return True if mapping files should be created during code generation
791      */
792     private boolean generateMapping()
793     {
794         return this.generateMappings;
795     }
796 
797     /**
798      * Sets whether mapping files should be created during code generation.
799      * 
800      * @param generateMappings True if mapping files should be created during code generation.
801      */
802     public final void setGenerateMappings( final boolean generateMappings )
803     {
804         this.generateMappings = generateMappings;
805     }
806 
807     /**
808      * Returns the method to use for Java class generation.
809      * 
810      * @return The method to use for Java class generation.
811      */
812     public String getClassGenerationMode()
813     {
814         return this.classGenerationMode;
815     }
816 
817     /**
818      * Sets the method to use for Java class generation; possible values are 'standard' (default) and 'velocity'.
819      * 
820      * @param classPrinterMethod The class generation mode to use.
821      */
822     public void setClassGenerationMode( final String classPrinterMethod )
823     {
824         this.classGenerationMode = classPrinterMethod;
825     }
826 
827 }