Class OfficeFloorJavaCompilerImpl
- java.lang.Object
-
- net.officefloor.compile.classes.OfficeFloorJavaCompiler
-
- net.officefloor.compile.impl.classes.OfficeFloorJavaCompilerImpl
-
public class OfficeFloorJavaCompilerImpl extends OfficeFloorJavaCompiler
OfficeFloorJavaCompilerimplementation.- Author:
- Daniel Sagenschneider
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.officefloor.compile.classes.OfficeFloorJavaCompiler
OfficeFloorJavaCompiler.ClassField, OfficeFloorJavaCompiler.ClassName, OfficeFloorJavaCompiler.ConstructorWriter, OfficeFloorJavaCompiler.ConstructorWriterContext, OfficeFloorJavaCompiler.ImplementationRunnable<T extends java.lang.Throwable>, OfficeFloorJavaCompiler.JavaSource, OfficeFloorJavaCompiler.JavaSourceContext, OfficeFloorJavaCompiler.JavaSourceWriter, OfficeFloorJavaCompiler.MethodWriter, OfficeFloorJavaCompiler.MethodWriterContext, OfficeFloorJavaCompiler.NonCompilerOperation<T extends java.lang.Throwable>
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringJAVAC_PROCESSING_ENVIRONMENT_CLASS_NAMEClassname for the JavacProcessingEnvironment to confirm on class path to ensure can compile.-
Fields inherited from class net.officefloor.compile.classes.OfficeFloorJavaCompiler
DEFAULT_OFFICE_FLOOR_JAVA_COMPILER_IMPLEMENTATION, SYSTEM_PROPERTY_JAVA_COMPILING
-
-
Constructor Summary
Constructors Constructor Description OfficeFloorJavaCompilerImpl(SourceContext sourceContext)Instantiate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OfficeFloorJavaCompiler.JavaSourceaddSource(java.lang.String className, java.lang.String source)OfficeFloorJavaCompiler.JavaSourceaddWrapper(java.lang.Class<?>[] wrappingTypes, java.lang.Class<?> delegateType, java.lang.String delegateExtraction, OfficeFloorJavaCompiler.ConstructorWriter constructorWriter, OfficeFloorJavaCompiler.MethodWriter methodWriter, OfficeFloorJavaCompiler.JavaSourceWriter... additionalSourceWriter)Adds a wrapperOfficeFloorJavaCompiler.JavaSource.java.util.Map<OfficeFloorJavaCompiler.JavaSource,java.lang.Class<?>>compile()Compiles all the addedOfficeFloorJavaCompiler.JavaSourceinstances.OfficeFloorJavaCompiler.ClassNamecreateClassName(java.lang.String name)Generates a uniqueOfficeFloorJavaCompiler.ClassName.OfficeFloorJavaCompiler.ClassFieldcreateField(java.lang.Class<?> fieldType, java.lang.String fieldName)Creates theOfficeFloorJavaCompiler.ClassField.java.lang.StringgetSourceName(java.lang.Class<?> type)Obtains the source name for theClass.voidwriteConstructor(java.lang.Appendable appendable, java.lang.String className, OfficeFloorJavaCompiler.ClassField... fields)Writes theConstructor.voidwriteDelegateMethodCall(java.lang.Appendable source, java.lang.String delegate, java.lang.reflect.Method method)Writes the delegateMethodcall.voidwriteMethodImplementation(java.lang.Appendable source, java.lang.String delegate, java.lang.reflect.Method method)Writes theMethodimplementation by invoking the delegate.booleanwriteMethodSignature(java.lang.Appendable source, java.lang.reflect.Method method)Writes theMethodsignature to theAppendable.-
Methods inherited from class net.officefloor.compile.classes.OfficeFloorJavaCompiler
addSource, addWrapper, newInstance, runWithImplementation, runWithoutCompiler
-
-
-
-
Field Detail
-
JAVAC_PROCESSING_ENVIRONMENT_CLASS_NAME
public static final java.lang.String JAVAC_PROCESSING_ENVIRONMENT_CLASS_NAME
Classname for the JavacProcessingEnvironment to confirm on class path to ensure can compile.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OfficeFloorJavaCompilerImpl
public OfficeFloorJavaCompilerImpl(SourceContext sourceContext) throws java.lang.ClassNotFoundException
Instantiate.- Parameters:
sourceContext-SourceContext.- Throws:
java.lang.ClassNotFoundException- If missingClassinstances for compiling.
-
-
Method Detail
-
createClassName
public OfficeFloorJavaCompiler.ClassName createClassName(java.lang.String name)
Description copied from class:OfficeFloorJavaCompilerGenerates a uniqueOfficeFloorJavaCompiler.ClassName.- Specified by:
createClassNamein classOfficeFloorJavaCompiler- Parameters:
name- Seed name.- Returns:
OfficeFloorJavaCompiler.ClassName.
-
getSourceName
public java.lang.String getSourceName(java.lang.Class<?> type)
Description copied from class:OfficeFloorJavaCompilerObtains the source name for theClass.- Specified by:
getSourceNamein classOfficeFloorJavaCompiler- Parameters:
type-Class.- Returns:
- Name used in source to reference the type.
-
createField
public OfficeFloorJavaCompiler.ClassField createField(java.lang.Class<?> fieldType, java.lang.String fieldName)
Description copied from class:OfficeFloorJavaCompilerCreates theOfficeFloorJavaCompiler.ClassField.- Specified by:
createFieldin classOfficeFloorJavaCompiler- Parameters:
fieldType-Fieldtype.fieldName-Fieldname.- Returns:
OfficeFloorJavaCompiler.ClassField.
-
writeConstructor
public void writeConstructor(java.lang.Appendable appendable, java.lang.String className, OfficeFloorJavaCompiler.ClassField... fields) throws java.io.IOExceptionDescription copied from class:OfficeFloorJavaCompilerWrites theConstructor.- Specified by:
writeConstructorin classOfficeFloorJavaCompiler- Parameters:
appendable-Appendable.className- Simple name of theClass.fields-OfficeFloorJavaCompiler.ClassFieldinstances.- Throws:
java.io.IOException- If fails to write theConstructor.
-
writeMethodSignature
public boolean writeMethodSignature(java.lang.Appendable source, java.lang.reflect.Method method) throws java.io.IOExceptionDescription copied from class:OfficeFloorJavaCompilerWrites theMethodsignature to theAppendable.- Specified by:
writeMethodSignaturein classOfficeFloorJavaCompiler- Parameters:
source-Appendable.method-Method.- Returns:
trueif returns a value (falseforvoidMethodreturn).- Throws:
java.io.IOException- If fails to write theMethodsignature.
-
writeMethodImplementation
public void writeMethodImplementation(java.lang.Appendable source, java.lang.String delegate, java.lang.reflect.Method method) throws java.io.IOExceptionDescription copied from class:OfficeFloorJavaCompilerWrites theMethodimplementation by invoking the delegate.- Specified by:
writeMethodImplementationin classOfficeFloorJavaCompiler- Parameters:
source-Appendable.delegate- Means to access delegate.method-Method.- Throws:
java.io.IOException- If fails write delegateMethodimplementation.
-
writeDelegateMethodCall
public void writeDelegateMethodCall(java.lang.Appendable source, java.lang.String delegate, java.lang.reflect.Method method) throws java.io.IOExceptionDescription copied from class:OfficeFloorJavaCompilerWrites the delegateMethodcall.- Specified by:
writeDelegateMethodCallin classOfficeFloorJavaCompiler- Parameters:
source-Appendable.delegate- Means to access delegate.method-Method.- Throws:
java.io.IOException- If fails write delegateMethodcall.
-
addSource
public OfficeFloorJavaCompiler.JavaSource addSource(java.lang.String className, java.lang.String source)
Description copied from class:OfficeFloorJavaCompiler- Specified by:
addSourcein classOfficeFloorJavaCompiler- Parameters:
className-Classname.source- Source for theClass.- Returns:
OfficeFloorJavaCompiler.JavaSource.
-
addWrapper
public OfficeFloorJavaCompiler.JavaSource addWrapper(java.lang.Class<?>[] wrappingTypes, java.lang.Class<?> delegateType, java.lang.String delegateExtraction, OfficeFloorJavaCompiler.ConstructorWriter constructorWriter, OfficeFloorJavaCompiler.MethodWriter methodWriter, OfficeFloorJavaCompiler.JavaSourceWriter... additionalSourceWriter) throws java.io.IOException
Description copied from class:OfficeFloorJavaCompilerAdds a wrapperOfficeFloorJavaCompiler.JavaSource.- Specified by:
addWrapperin classOfficeFloorJavaCompiler- Parameters:
wrappingTypes- Wrapping types.delegateType- Delegate type.delegateExtraction- Means to extract the wrapped implementation from the delegate. May benullto use default.constructorWriter-OfficeFloorJavaCompiler.ConstructorWriter. May benullto use defaultConstructor.methodWriter-OfficeFloorJavaCompiler.MethodWriter. May benullto use default implementation.additionalSourceWriter-OfficeFloorJavaCompiler.JavaSourceWriterinstances.- Returns:
OfficeFloorJavaCompiler.JavaSourcefor the wrapper.- Throws:
java.io.IOException- If fails to write the wrapper.
-
compile
public java.util.Map<OfficeFloorJavaCompiler.JavaSource,java.lang.Class<?>> compile()
Description copied from class:OfficeFloorJavaCompilerCompiles all the addedOfficeFloorJavaCompiler.JavaSourceinstances.- Specified by:
compilein classOfficeFloorJavaCompiler- Returns:
MapofOfficeFloorJavaCompiler.JavaSourceto itsClass.
-
-