org.deduced.dynamic
Class DeductionRuleExecutionCompiler

java.lang.Object
  extended by org.deduced.dynamic.AbstractDynamicExecutionCompiler
      extended by org.deduced.dynamic.DeductionRuleExecutionCompiler
All Implemented Interfaces:
DynamicExecutionCompiler

public class DeductionRuleExecutionCompiler
extends AbstractDynamicExecutionCompiler

DeductionRuleExecutionCompiler

Author:
Steve McDuff

Nested Class Summary
 
Nested classes/interfaces inherited from class org.deduced.dynamic.AbstractDynamicExecutionCompiler
AbstractDynamicExecutionCompiler.DynamicFileNameGenerator, AbstractDynamicExecutionCompiler.FileNameGenerator, AbstractDynamicExecutionCompiler.LocalClassLoader
 
Field Summary
private static DeductionRuleExecutionCompiler INSTANCE
          unique instance of the deduction rule execution compiler
 
Fields inherited from class org.deduced.dynamic.AbstractDynamicExecutionCompiler
CLASS_FILE_EXTENSION, DEDUCED_DYNAMIC_CLASS_NAME, DYNAMIC_CODE_PACKAGE_NAME, FILE_NAME_GENERATOR, JAVA_FILE_EXTENSION
 
Constructor Summary
protected DeductionRuleExecutionCompiler()
          DeductionRuleExecutionCompiler constructor
 
Method Summary
 void buildClassContent(PropertyCollection compiledModel, java.lang.String className, java.lang.String packageName, java.lang.StringBuilder builder)
          (non-JSDoc)
static DynamicExecutionCompiler getInstance()
          get the deduction rule execution compiler Instance
static java.lang.String getRuleMethodName(PropertyCollection<?,?> rule)
          get Rule Method Name
static boolean isReferenceMultiple(java.util.List<?> instanceList)
          test if a reference can result in multiple values
static void printReferenceClassType(java.lang.StringBuilder builder, PropertyCollection<?,?> instanceReference)
          print Reference Class Type
static void printRuleClassHeader(java.lang.String className, java.lang.String packageName, java.lang.StringBuilder builder)
          print Rule Class Header
static void printRuleGenericMethod(PropertyCollection<?,?> rule, java.lang.StringBuilder builder)
          print Rule Generic Method
static void printRuleGenericMethodDeclaration(java.lang.StringBuilder builder)
          print Rule Generic Method Declaration
static void printRuleSpecificMethod(PropertyCollection<?,?> rule, java.lang.StringBuilder builder)
          print Rule Specific Method
 void validateCompilationModelForCompilation(PropertyCollection compiledModel, CompileResult result)
          (non-JSDoc)
private  void validateOutputListSize(PropertyCollection deductionRule, int outputListSize)
          validate Output List Size.
private  void validateOutputType(PropertyCollection deductionRule, PropertyCollection<?,?> output)
          validate Output Type.
 
Methods inherited from class org.deduced.dynamic.AbstractDynamicExecutionCompiler
attemptToLoadClassFromCache, compileClass, compileFile, createAnalyzerFromCompiledModel, deleteAllGeneratedClassFiles, deleteAllGeneratedFiles, deleteAllGeneratedJavaFiles, deleteClassCachedFiles, deleteFileAssertIfFailed, deleteInnerClasses, disableCompiledModel, doesClassExist, filterIllegalJavaCharacters, getAnalyzerFromCompiledModel, getClassFromCompiledModel, getClassNameForCompiledModel, getClassNameFromCompiledModel, getCompilerArguments, getDynamicClassLoader, getInnerClassList, getNextAvailableClassName, getNextAvailableDynamicFileName, getNextAvailableFileName, getNextDynamicFileName, getOutputFolderName, isAutomaticallyDeletingGeneratedClassFiles, isAutomaticallyDeletingGeneratedJavaFiles, isAutomaticallyDeletingGeneratedJavaFilesIfCompileFails, isClassName, isCompiledModelEnabled, isValidMethodNameCharacter, loadClassAndInnerClass, logAnalyzerCreationResult, resetAnalyzerFromCompiledModel, setAutomaticallyDeletingGeneratedClassFiles, setAutomaticallyDeletingGeneratedJavaFiles, setAutomaticallyDeletingGeneratedJavaFilesIfCompileFails, setCompilerArguments, setDynamicClassLoader, setOutputFolderName, validateCompilationModelIsEnabled, writeJavaClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

private static final DeductionRuleExecutionCompiler INSTANCE
unique instance of the deduction rule execution compiler

Constructor Detail

DeductionRuleExecutionCompiler

protected DeductionRuleExecutionCompiler()
DeductionRuleExecutionCompiler constructor

Method Detail

getInstance

public static DynamicExecutionCompiler getInstance()
get the deduction rule execution compiler Instance

Returns:
the deduction rule execution compiler

buildClassContent

public void buildClassContent(PropertyCollection compiledModel,
                              java.lang.String className,
                              java.lang.String packageName,
                              java.lang.StringBuilder builder)
(non-JSDoc)

Specified by:
buildClassContent in class AbstractDynamicExecutionCompiler
Parameters:
compiledModel - the compiled model
className - the class name to use
packageName - the package name to use
builder - the string builder containing the class content
See Also:
AbstractDynamicExecutionCompiler.buildClassContent(org.deduced.PropertyCollection, java.lang.String, java.lang.String, java.lang.StringBuilder)

printRuleGenericMethod

public static void printRuleGenericMethod(PropertyCollection<?,?> rule,
                                          java.lang.StringBuilder builder)
print Rule Generic Method

Parameters:
rule - the rule to print
builder - the string builder in which to print the content

printRuleGenericMethodDeclaration

public static void printRuleGenericMethodDeclaration(java.lang.StringBuilder builder)
print Rule Generic Method Declaration

Parameters:
builder - the rule string builder

printRuleClassHeader

public static void printRuleClassHeader(java.lang.String className,
                                        java.lang.String packageName,
                                        java.lang.StringBuilder builder)
print Rule Class Header

Parameters:
className - the class name
packageName - the package name
builder - the string builder in which to print the content

printRuleSpecificMethod

public static void printRuleSpecificMethod(PropertyCollection<?,?> rule,
                                           java.lang.StringBuilder builder)
print Rule Specific Method

Parameters:
rule - the rule to print
builder - the string builder in which to write the class content

printReferenceClassType

public static void printReferenceClassType(java.lang.StringBuilder builder,
                                           PropertyCollection<?,?> instanceReference)
print Reference Class Type

Parameters:
builder - string builder in which to print the content
instanceReference - the instance reference to print

isReferenceMultiple

public static boolean isReferenceMultiple(java.util.List<?> instanceList)
test if a reference can result in multiple values

Parameters:
instanceList - the instance list
Returns:
true if the reference has multiple values

getRuleMethodName

public static java.lang.String getRuleMethodName(PropertyCollection<?,?> rule)
get Rule Method Name

Parameters:
rule - the rule from which to extract the method name
Returns:
the rule method name

validateCompilationModelForCompilation

public void validateCompilationModelForCompilation(PropertyCollection compiledModel,
                                                   CompileResult result)
(non-JSDoc)

Overrides:
validateCompilationModelForCompilation in class AbstractDynamicExecutionCompiler
Parameters:
compiledModel - the compiled model
result - the compilation result to fill
See Also:
AbstractDynamicExecutionCompiler.validateCompilationModelForCompilation(org.deduced.PropertyCollection, org.deduced.controller.implementation.CompileResult)

validateOutputListSize

private void validateOutputListSize(PropertyCollection deductionRule,
                                    int outputListSize)
validate Output List Size. the output list must not be empty.

Parameters:
deductionRule - the rule we are creating
outputListSize - the output list size

validateOutputType

private void validateOutputType(PropertyCollection deductionRule,
                                PropertyCollection<?,?> output)
validate Output Type. Output type isn't allowed to be static

Parameters:
deductionRule - the rule we are creating
output - the current output