java.lang.Object
org.jboss.arquillian.graphene.spi.javascript.JavaScript

public class JavaScript extends Object

Encapsulates JavaScript definitions.

Able to load JavaScript code from file or from classpath resource.

Author:
Lukas Fryc, Jan Papousek
  • Constructor Details

    • JavaScript

      public JavaScript(String source)
      Instantiates a new JavaScript.
      Parameters:
      source - the JavaScript source code
  • Method Details

    • fromFile

      public static JavaScript fromFile(File sourceFile)
      Loads the JavaScript from file.
      Parameters:
      sourceFile - the source file
      Returns:
      the JavaScript object loaded from file
      Throws:
      RuntimeException - when failed to load a script
    • fromResource

      public static JavaScript fromResource(String resourceName)
      Loads the JavaScript from classpath resource.
      Parameters:
      resourceName - the resource name, e.g. "org/jboss/test/..."
      Returns:
      the JavaScript object loaded from classpath resource
      Throws:
      RuntimeException - when failed to load a script
    • fromString

      public static JavaScript fromString(String source)
      The factory method for JavaScript object
      Parameters:
      source - the JavaScript source code
      Returns:
      the new JavaScript object with predefined JavaScript code
    • join

      public JavaScript join(JavaScript javaScriptToJoin)
      Joins this JavaScript object with another JavaScript object to single JavaScript.
      Parameters:
      javaScriptToJoin - the JavaScript object we want to join with
      Returns:
      the joined JavaScript object
    • append

      public JavaScript append(String sourceCodeToAppend)
      Append the JavaScript part to end of the this JavaScript
      Parameters:
      sourceCodeToAppend - JavaScript source code to append on the end of this JavaScript
      Returns:
      this JavaScript with javaScriptPartToAppend appended
    • getSourceCode

      public String getSourceCode()
      Returns the source of hold by this JavaScript object instance.
    • toString

      public String toString()
      Overrides:
      toString in class Object