ma.glasnost.orika.impl.generator
Class EclipseJdtCompiler

java.lang.Object
  extended by ma.glasnost.orika.impl.generator.EclipseJdtCompiler

public class EclipseJdtCompiler
extends Object

EclipseJdtCompiler leverages the eclipse jdt core to compile source code provided in String format.
It can also make use of the source formatter tool to format source.

Author:
matt.deboer@gmail.com

Constructor Summary
EclipseJdtCompiler()
           
 
Method Summary
 void assertTypeAccessible(Class<?> type)
           
 byte[] compile(String source, String packageName, String classSimpleName)
          Compile and return the raw bytes of the class file.
 Class<?> compileAndLoad(String source, String packageName, String classSimpleName)
          Compile and return the (generated) class.
 String formatSource(String code)
          Format the source code using the Eclipse text formatter
 byte[] getBytes(String className)
          Gets the raw bytes of the classFile that was defined for the given className by this compiler.
 Class<?> load(String className, byte[] data)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EclipseJdtCompiler

public EclipseJdtCompiler()
Method Detail

formatSource

public String formatSource(String code)
Format the source code using the Eclipse text formatter


assertTypeAccessible

public void assertTypeAccessible(Class<?> type)
                          throws IllegalStateException
Throws:
IllegalStateException

compileAndLoad

public Class<?> compileAndLoad(String source,
                               String packageName,
                               String classSimpleName)
                        throws ClassNotFoundException
Compile and return the (generated) class.

Parameters:
source -
packageName -
classSimpleName -
Returns:
the (generated) compiled class
Throws:
ClassNotFoundException

compile

public byte[] compile(String source,
                      String packageName,
                      String classSimpleName)
Compile and return the raw bytes of the class file.

Parameters:
source -
packageName -
classSimpleName -
Returns:
the raw bytes of the class file

load

public Class<?> load(String className,
                     byte[] data)
              throws ClassNotFoundException
Throws:
ClassNotFoundException

getBytes

public byte[] getBytes(String className)
Gets the raw bytes of the classFile that was defined for the given className by this compiler.

Parameters:
className -
Returns:


Copyright © 2012 Glasnost. All Rights Reserved.