src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/AbstractJSObject.java

Print this page




  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.nashorn.api.scripting;
  27 
  28 import java.util.Collection;
  29 import java.util.Collections;
  30 import java.util.Set;
  31 
  32 /**
  33  * This is the base class for nashorn ScriptObjectMirror class.
  34  *
  35  * This class can also be subclassed by an arbitrary Java class. Nashorn will
  36  * treat objects of such classes just like nashorn script objects. Usual nashorn
  37  * operations like obj[i], obj.foo, obj.func(), delete obj.foo will be glued
  38  * to appropriate method call of this class.


  39  */

  40 public abstract class AbstractJSObject implements JSObject {
  41     /**
  42      * Call this object as a JavaScript function. This is equivalent to
  43      * 'func.apply(thiz, args)' in JavaScript.
  44      *
  45      * @param thiz 'this' object to be passed to the function
  46      * @param args arguments to method
  47      * @return result of call
  48      */
  49     @Override
  50     public Object call(final Object thiz, final Object... args) {
  51         throw new UnsupportedOperationException("call");
  52     }
  53 
  54     /**
  55      * Call this 'constructor' JavaScript function to create a new object.
  56      * This is equivalent to 'new func(arg1, arg2...)' in JavaScript.
  57      *
  58      * @param args arguments to method
  59      * @return result of constructor call




  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.nashorn.api.scripting;
  27 
  28 import java.util.Collection;
  29 import java.util.Collections;
  30 import java.util.Set;
  31 
  32 /**
  33  * This is the base class for nashorn ScriptObjectMirror class.
  34  *
  35  * This class can also be subclassed by an arbitrary Java class. Nashorn will
  36  * treat objects of such classes just like nashorn script objects. Usual nashorn
  37  * operations like obj[i], obj.foo, obj.func(), delete obj.foo will be glued
  38  * to appropriate method call of this class.
  39  *
  40  * @since 1.8u40
  41  */
  42 @jdk.Exported
  43 public abstract class AbstractJSObject implements JSObject {
  44     /**
  45      * Call this object as a JavaScript function. This is equivalent to
  46      * 'func.apply(thiz, args)' in JavaScript.
  47      *
  48      * @param thiz 'this' object to be passed to the function
  49      * @param args arguments to method
  50      * @return result of call
  51      */
  52     @Override
  53     public Object call(final Object thiz, final Object... args) {
  54         throw new UnsupportedOperationException("call");
  55     }
  56 
  57     /**
  58      * Call this 'constructor' JavaScript function to create a new object.
  59      * This is equivalent to 'new func(arg1, arg2...)' in JavaScript.
  60      *
  61      * @param args arguments to method
  62      * @return result of constructor call