ma.glasnost.orika.impl.generator
Class EclipseJdtCompilerStrategy

java.lang.Object
  extended by ma.glasnost.orika.impl.generator.CompilerStrategy
      extended by ma.glasnost.orika.impl.generator.EclipseJdtCompilerStrategy

public class EclipseJdtCompilerStrategy
extends CompilerStrategy

Uses Eclipse JDT to format and compile the source for the specified GeneratedSourceCode objects.

By default, this compiler strategy writes formatted source files relative to the current class path root.

Author:
matt.deboer@gmail.com

Nested Class Summary
 
Nested classes/interfaces inherited from class ma.glasnost.orika.impl.generator.CompilerStrategy
CompilerStrategy.SourceCodeGenerationException
 
Field Summary
 
Fields inherited from class ma.glasnost.orika.impl.generator.CompilerStrategy
pathToWriteClassFiles, pathToWriteSourceFiles, WRITE_RELATIVE_TO_CLASSPATH, writeClassFiles, writeSourceFiles
 
Constructor Summary
EclipseJdtCompilerStrategy()
           
 
Method Summary
 void assureTypeIsAccessible(Class<?> type)
          Verify that the Class provided is accessible to the compiler/generator.
 Class<?> compileClass(SourceCodeContext sourceCode)
          Compile and return the (generated) class; this will also cause the generated class to be detached from the class-pool, and any (optional) source and/or class files to be written.
protected  void writeClassFile(String packageName, String simpleClassName, byte[] data)
           
protected  void writeSourceFile(String sourceText, String packageName, String className)
          Produces the requested source and/or class files for debugging purposes.
 
Methods inherited from class ma.glasnost.orika.impl.generator.CompilerStrategy
preparePackageOutputPath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EclipseJdtCompilerStrategy

public EclipseJdtCompilerStrategy()
Method Detail

writeSourceFile

protected void writeSourceFile(String sourceText,
                               String packageName,
                               String className)
                        throws IOException
Produces the requested source and/or class files for debugging purposes.

Throws:
IOException

writeClassFile

protected void writeClassFile(String packageName,
                              String simpleClassName,
                              byte[] data)
                       throws IOException
Throws:
IOException

assureTypeIsAccessible

public void assureTypeIsAccessible(Class<?> type)
                            throws CompilerStrategy.SourceCodeGenerationException
Description copied from class: CompilerStrategy
Verify that the Class provided is accessible to the compiler/generator.

Specified by:
assureTypeIsAccessible in class CompilerStrategy
Throws:
CompilerStrategy.SourceCodeGenerationException - if the type is not accessible

compileClass

public Class<?> compileClass(SourceCodeContext sourceCode)
                      throws CompilerStrategy.SourceCodeGenerationException
Compile and return the (generated) class; this will also cause the generated class to be detached from the class-pool, and any (optional) source and/or class files to be written.

Specified by:
compileClass in class CompilerStrategy
Returns:
the (generated) compiled class
Throws:
IOException
CompilerStrategy.SourceCodeGenerationException


Copyright © 2013 Glasnost. All Rights Reserved.