Class AbstractJSObject

  • All Implemented Interfaces:
    JSObject
    Direct Known Subclasses:
    ScriptObjectMirror


    public abstract class AbstractJSObject
    extends Object
    implements JSObject
    This is the base class for nashorn ScriptObjectMirror class. This class can also be subclassed by an arbitrary Java class. Nashorn will treat objects of such classes just like nashorn script objects. Usual nashorn operations like obj[i], obj.foo, obj.func(), delete obj.foo will be delegated to appropriate method call of this class.
    Since:
    1.8u40
    • Constructor Detail

      • AbstractJSObject

        public AbstractJSObject​()
        The default constructor.
    • Method Detail

      • call

        public Object call​(Object thiz,
                           Object... args)
        Description copied from interface: JSObject
        Call this object as a JavaScript function. This is equivalent to 'func.apply(thiz, args)' in JavaScript.
        Specified by:
        call in interface JSObject
        Implementation Requirements:
        This implementation always throws UnsupportedOperationException
        Parameters:
        thiz - 'this' object to be passed to the function. This may be null.
        args - arguments to method
        Returns:
        result of call
      • newObject

        public Object newObject​(Object... args)
        Description copied from interface: JSObject
        Call this 'constructor' JavaScript function to create a new object. This is equivalent to 'new func(arg1, arg2...)' in JavaScript.
        Specified by:
        newObject in interface JSObject
        Implementation Requirements:
        This implementation always throws UnsupportedOperationException
        Parameters:
        args - arguments to method
        Returns:
        result of constructor call
      • eval

        public Object eval​(String s)
        Description copied from interface: JSObject
        Evaluate a JavaScript expression.
        Specified by:
        eval in interface JSObject
        Implementation Requirements:
        This imlementation always throws UnsupportedOperationException
        Parameters:
        s - JavaScript expression to evaluate
        Returns:
        evaluation result
      • getMember

        public Object getMember​(String name)
        Description copied from interface: JSObject
        Retrieves a named member of this JavaScript object.
        Specified by:
        getMember in interface JSObject
        Implementation Requirements:
        This implementation always returns null
        Parameters:
        name - of member
        Returns:
        member
      • getSlot

        public Object getSlot​(int index)
        Description copied from interface: JSObject
        Retrieves an indexed member of this JavaScript object.
        Specified by:
        getSlot in interface JSObject
        Implementation Requirements:
        This implementation always returns null
        Parameters:
        index - index slot to retrieve
        Returns:
        member
      • hasMember

        public boolean hasMember​(String name)
        Description copied from interface: JSObject
        Does this object have a named member?
        Specified by:
        hasMember in interface JSObject
        Implementation Requirements:
        This implementation always returns false
        Parameters:
        name - name of member
        Returns:
        true if this object has a member of the given name
      • hasSlot

        public boolean hasSlot​(int slot)
        Description copied from interface: JSObject
        Does this object have a indexed property?
        Specified by:
        hasSlot in interface JSObject
        Implementation Requirements:
        This implementation always returns false
        Parameters:
        slot - index to check
        Returns:
        true if this object has a slot
      • removeMember

        public void removeMember​(String name)
        Description copied from interface: JSObject
        Remove a named member from this JavaScript object
        Specified by:
        removeMember in interface JSObject
        Implementation Requirements:
        This implementation is a no-op
        Parameters:
        name - name of the member
      • setMember

        public void setMember​(String name,
                              Object value)
        Description copied from interface: JSObject
        Set a named member in this JavaScript object
        Specified by:
        setMember in interface JSObject
        Implementation Requirements:
        This implementation is a no-op
        Parameters:
        name - name of the member
        value - value of the member
      • setSlot

        public void setSlot​(int index,
                            Object value)
        Description copied from interface: JSObject
        Set an indexed member in this JavaScript object
        Specified by:
        setSlot in interface JSObject
        Implementation Requirements:
        This implementation is a no-op
        Parameters:
        index - index of the member slot
        value - value of the member
      • keySet

        public Set<String> keySet​()
        Description copied from interface: JSObject
        Returns the set of all property names of this object.
        Specified by:
        keySet in interface JSObject
        Implementation Requirements:
        This implementation returns empty set
        Returns:
        set of property names
      • values

        public Collection<Object> values​()
        Description copied from interface: JSObject
        Returns the set of all property values of this object.
        Specified by:
        values in interface JSObject
        Implementation Requirements:
        This implementation returns empty set
        Returns:
        set of property values.
      • isInstance

        public boolean isInstance​(Object instance)
        Description copied from interface: JSObject
        Checking whether the given object is an instance of 'this' object.
        Specified by:
        isInstance in interface JSObject
        Implementation Requirements:
        This implementation always returns false
        Parameters:
        instance - instance to check
        Returns:
        true if the given 'instance' is an instance of this 'function' object
      • isInstanceOf

        public boolean isInstanceOf​(Object clazz)
        Description copied from interface: JSObject
        Checking whether this object is an instance of the given 'clazz' object.
        Specified by:
        isInstanceOf in interface JSObject
        Parameters:
        clazz - clazz to check
        Returns:
        true if this object is an instance of the given 'clazz'
      • getClassName

        public String getClassName​()
        Description copied from interface: JSObject
        ECMA [[Class]] property
        Specified by:
        getClassName in interface JSObject
        Returns:
        ECMA [[Class]] property value of this object
      • isFunction

        public boolean isFunction​()
        Description copied from interface: JSObject
        Is this a function object?
        Specified by:
        isFunction in interface JSObject
        Implementation Requirements:
        This implementation always returns false
        Returns:
        if this mirror wraps a ECMAScript function instance
      • isStrictFunction

        public boolean isStrictFunction​()
        Description copied from interface: JSObject
        Is this a 'use strict' function object?
        Specified by:
        isStrictFunction in interface JSObject
        Implementation Requirements:
        This implementation always returns false
        Returns:
        true if this mirror represents a ECMAScript 'use strict' function
      • isArray

        public boolean isArray​()
        Description copied from interface: JSObject
        Is this an array object?
        Specified by:
        isArray in interface JSObject
        Implementation Requirements:
        This implementation always returns false
        Returns:
        if this mirror wraps a ECMAScript array object