Class JavaScriptCodeFactory

java.lang.Object
org.eclipse.ease.AbstractCodeFactory
org.eclipse.ease.lang.javascript.JavaScriptCodeFactory
All Implemented Interfaces:
ICodeFactory

public class JavaScriptCodeFactory extends AbstractCodeFactory
  • Constructor Details

    • JavaScriptCodeFactory

      public JavaScriptCodeFactory()
  • Method Details

    • isSaveName

      public static boolean isSaveName(String identifier)
    • classInstantiation

      public String classInstantiation(Class<?> clazz, String[] parameters)
      Description copied from interface: ICodeFactory
      Create code to instantiate a java class.
      Parameters:
      clazz - class to instantiate
      parameters - parameters used for class instantiation
      Returns:
      wrapped script code
    • getSaveVariableName

      public String getSaveVariableName(String variableName)
      Description copied from interface: ICodeFactory
      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
    • createCommentedString

      public String createCommentedString(String comment, boolean addBlockComment)
      Description copied from interface: ICodeFactory
      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.
      Specified by:
      createCommentedString in interface ICodeFactory
      Overrides:
      createCommentedString in class AbstractCodeFactory
      Parameters:
      comment - the comment
      addBlockComment - true for adding block comment or false for adding (multiple) line comments
      Returns:
      the comment string with comment tokens.
    • createWrapper

      public String createWrapper(IEnvironment environment, Object instance, String identifier, boolean customNamespace, IScriptEngine engine)
      Description copied from interface: ICodeFactory
      Create script wrapper code for a given java instance.
      Specified by:
      createWrapper in interface ICodeFactory
      Overrides:
      createWrapper in class AbstractCodeFactory
      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
      Returns:
      create wrapped script code