org.eclipse.ease

## Interface ICodeFactory

All Known Implementing Classes:
  AbstractCodeFactory, GroovyCodeFactory, JavaScriptCodeFactory, PythonCodeFactory, RubyCodeFactory

    public interface ICodeFactory

An ICodeFactory is capable of generating code fragments for a dedicated target language.

### Nested Class Summary

Nested Classes
`static class` `ICodeFactory.Parameter` Parameter definition class.

### Field Summary

Fields
`static java.lang.String` `RESULT_NAME` intermediate name of original method call return value.
`static boolean` `TRACE_MODULE_WRAPPER` Trace enablement for module wrappers.

### Method Summary

All Methods Instance Methods Abstract Methods
`java.lang.String` `classInstantiation(java.lang.Class<?> clazz, java.lang.String[] parameters)` Create code to instantiate a java class.
`java.lang.String` `createCommentedString(java.lang.String comment, boolean blockComment)` Create code for the provided comment.
`java.lang.String` `createFunctionCall(java.lang.reflect.Method method, java.lang.Object... parameters)` Create code to call a wrapped function.
`java.lang.String` `createKeywordHeader(java.util.Map<java.lang.String,java.lang.String> keywords, java.lang.String existingHeader)` Create a comment header for given keywords.
`java.lang.String` `createWrapper(IEnvironment environment, java.lang.Object instance, java.lang.String identifier, boolean customNamespace, IScriptEngine engine)` Create script wrapper code for a given java instance.
`java.lang.String` `getDefaultValue(ICodeFactory.Parameter parameter)` Get the default value for a given parameter
`java.lang.String` `getSaveVariableName(java.lang.String variableName)` Converts a given string to a save variable name for the target language.

### Field Detail

#### RESULT_NAME

    static final java.lang.String RESULT_NAME

intermediate name of original method call return value.

See Also:
  Constant Field Values

#### TRACE_MODULE_WRAPPER

    static final boolean TRACE_MODULE_WRAPPER

Trace enablement for module wrappers.

### Method Detail

#### getSaveVariableName

    java.lang.String getSaveVariableName(java.lang.String variableName)

Converts a given string to a save variable name for the target language. Typically filters invalid characters and verifies that the returned string does not match any reserved keyword. Does not verify if the returned name is already in use.

Parameters:
  `variableName` - variable name candidate
Returns:
  converted variable name

#### classInstantiation

    java.lang.String classInstantiation(java.lang.Class<?> clazz,
                                        java.lang.String[] parameters)

Create code to instantiate a java class.

Parameters:
  `clazz` - class to instantiate
  `parameters` - parameters used for class instantiation
Returns:
  wrapped script code

#### createFunctionCall

    java.lang.String createFunctionCall(java.lang.reflect.Method method,
                                        java.lang.Object... parameters)

Create code to call a wrapped function. Create code to call a script function that was wrapped using `#createFunctionWrapper(IEnvironment, String, Method)` before.

Parameters:
  `method` - method to be called
  `parameters` - call parameters
Returns:
  script code to call function

#### getDefaultValue

    java.lang.String getDefaultValue(ICodeFactory.Parameter parameter)

Get the default value for a given parameter

Parameters:
  `parameter` - parameter to get default value for
Returns:
  String representation of default value

#### createCommentedString

    java.lang.String createCommentedString(java.lang.String comment,
                                           boolean blockComment)

Create code for the provided comment. Typically line or block comment tokens will be added around the comment. Start block comment token will be added immediately before comment and end block comment token will be added immediately after comment. Format comment properly to get proper result.

Parameters:
  `comment` - the comment
  `blockComment` - `true` for adding block comment or `false` for adding (multiple) line comments
Returns:
  the comment string with comment tokens.

#### createKeywordHeader

    java.lang.String createKeywordHeader(java.util.Map<java.lang.String,java.lang.String> keywords,
                                         java.lang.String existingHeader)

Create a comment header for given keywords. Arbitrary content will be delimited by an empty line

Parameters:
  `keywords` - key:value pairs to be stored
  `existingHeader` - current header to copy plain text from
Returns:
  String representation of header

#### createWrapper

    java.lang.String createWrapper(IEnvironment environment,
                                   java.lang.Object instance,
                                   java.lang.String identifier,
                                   boolean customNamespace,
                                   IScriptEngine engine)

Create script wrapper code for a given java instance.

Parameters:
  `environment` - environment module instance
  `instance` - object instance to wrap
  `identifier` - script variable name for wrapped Java object
  `customNamespace` - whether to store methods to the global namespace or to create a custom object
  `engine` - script engine