org.eclipse.ease

## Interface ICodeFactory

All Known Implementing Classes:
  AbstractCodeFactory, JavaScriptCodeFactory, PythonCodeFactory

    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 boolean` `TRACE_MODULE_WRAPPER` Trace enablement for module wrappers.

### Method Summary

All Methods Instance Methods Abstract Methods
`String` `classInstantiation(Class<?> clazz, String[] parameters)` Create code to instantiate a java class.
`String` `createCommentedString(String comment)` Create code for the provided comment.
`String` `createCommentedString(String comment, boolean addBlockComment)` Create code for the provided comment.
`String` `createFinalFieldWrapper(IEnvironment environment, String moduleVariable, Field field)` Create code to bind a final java field to a script variable.
`String` `createFunctionCall(Method method, Object... parameters)` Create code to call a wrapped function.
`String` `createFunctionWrapper(IEnvironment environment, String moduleVariable, Method method)` Create code to wrap a java method call on a given script variable to the target language.
`String` `createKeywordHeader(Map<String,String> keywords, String existingHeader)` Create a comment header for given keywords.
`String` `getDefaultValue(ICodeFactory.Parameter parameter)` Get the default value for a given parameter
`String` `getSaveVariableName(String variableName)` Converts a given string to a save variable name for the target language.

### Field Detail

#### TRACE_MODULE_WRAPPER

    static final boolean TRACE_MODULE_WRAPPER

Trace enablement for module wrappers.

### Method Detail

#### getSaveVariableName

    String getSaveVariableName(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

#### createFunctionWrapper

    String createFunctionWrapper(IEnvironment environment,
                                 String moduleVariable,
                                 Method method)

Create code to wrap a java method call on a given script variable to the target language. Creates script code that invokes the given method on the given moduleVariable.

Parameters:
  `environment` - script environment
  `moduleVariable` - name of variable holding the module instance
  `method` - method to be wrapped
Returns:
  wrapped script code

#### classInstantiation

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

Create code to instantiate a java class.

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

#### createFinalFieldWrapper

    String createFinalFieldWrapper(IEnvironment environment,
                                   String moduleVariable,
                                   Field field)

Create code to bind a final java field to a script variable.

Parameters:
  `environment` - script environment
  `moduleVariable` - name of variable holding the module instance
  `field` - field to be accessed
Returns:
  wrapped script code

#### createFunctionCall

    String createFunctionCall(Method method,
                              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

    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

    String createCommentedString(String comment)

Create code for the provided comment. Typically line or block comment tokens will be added around the comment.

Parameters:
  `comment` - the comment
Returns:
  the comment with comment tokens.

#### createCommentedString

    String createCommentedString(String comment,
                                 boolean addBlockComment)

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
  `addBlockComment` - `true` for adding block comment or `false` for adding single line comment
Returns:
  the comment with comment tokens.

#### createKeywordHeader

    String createKeywordHeader(Map<String,String> keywords,
                               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