Class JSObject

java.lang.Object
de.inetsoftware.jwebassembly.web.JSObject
Direct Known Subclasses:
EventTarget, NodeList, Window

public class JSObject extends Object
The base type for all wrapped JavaScript objects.
Author:
Volker Berlin
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Object
    Native object from JavaScript.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Create a Java instance as wrapper of the JavaScript object.
  • Method Summary

    Modifier and Type
    Method
    Description
    static DOMString
    Get the dom string from a java string https://developer.mozilla.org/de/docs/Web/API/DOMString
    protected <T> T
    get(String propName)
    Get the value of a property of this object.
    protected <T> T
    invoke(String methodName, Object param1)
    Invoke a JavaScript method with one non string parameter of this object.
    protected <T> T
    invoke(String methodName, String param1)
    Invoke a JavaScript method with one string parameter of this object.
    protected void
    set(String propName, String value)
    Set the value of a property of this object.
    protected static <T> T
    win_get(String propName)
    Get a JavaScript property value by name from global variable window.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • peer

      protected final Object peer
      Native object from JavaScript.
  • Constructor Details

    • JSObject

      protected JSObject(Object peer)
      Create a Java instance as wrapper of the JavaScript object.
      Parameters:
      peer - the native JavaScript object
  • Method Details

    • win_get

      protected static <T> T win_get(@Nonnull String propName)
      Get a JavaScript property value by name from global variable window.
      Type Parameters:
      T - the return type
      Parameters:
      propName - the name of the property as DOMString
      Returns:
      the value of the property
    • get

      protected <T> T get(@Nonnull String propName)
      Get the value of a property of this object.
      Type Parameters:
      T - the return type
      Parameters:
      propName - the name of the property
      Returns:
      the value of the property
    • set

      protected void set(@Nonnull String propName, String value)
      Set the value of a property of this object.
      Parameters:
      propName - the name of the property
      value - the value of the property
    • invoke

      protected <T> T invoke(@Nonnull String methodName, String param1)
      Invoke a JavaScript method with one string parameter of this object.
      Type Parameters:
      T - the return type
      Parameters:
      methodName - the method name
      param1 - the parameter
      Returns:
      the return value
    • invoke

      protected <T> T invoke(@Nonnull String methodName, Object param1)
      Invoke a JavaScript method with one non string parameter of this object.
      Type Parameters:
      T - the return type
      Parameters:
      methodName - the method name
      param1 - the parameter
      Returns:
      the return value
    • domString

      public static DOMString domString(@Nonnull String str)
      Get the dom string from a java string https://developer.mozilla.org/de/docs/Web/API/DOMString
      Parameters:
      str - the Java string
      Returns:
      dom string