public class JSObject extends JSValue
Modifier and Type | Field and Description |
---|---|
static int |
JSPropertyAttributeDontDelete
Specifies that the delete operation should fail on a property.
|
static int |
JSPropertyAttributeDontEnum
Specifies that a property should not be enumerated by
JSPropertyEnumerators and JavaScript for...in loops.
|
static int |
JSPropertyAttributeNone
Specifies that a property has no special attributes.
|
static int |
JSPropertyAttributeReadOnly
Specifies that a property is read-only.
|
Constructor and Description |
---|
JSObject()
Called only by convenience subclasses.
|
JSObject(JSContext ctx)
Creates a new, empty JavaScript object.
|
JSObject(JSContext ctx,
java.lang.Class<?> iface)
Creates a new object with function properties set for each method
in the defined interface.
|
JSObject(JSContext ctx,
java.lang.Class<?> iface,
java.lang.Class<? extends JSObject> subclass)
Deprecated.
Function constructors have been removed from JSObject since 3.0. Use JSFunction instead.
|
JSObject(JSContext ctx,
JSObject invoke,
java.lang.reflect.Method method)
Deprecated.
Function constructors have been removed from JSObject since 3.0. Use JSFunction instead.
|
JSObject(JSContext ctx,
java.util.Map map)
Creates a new function object with the entries in 'map' set as properties.
|
Modifier and Type | Method and Description |
---|---|
JSValue |
__nullFunc() |
JSValue |
callAsFunction()
Deprecated.
Function calls have been removed from JSObject since 3.0. Use JSFunction.call or
JSFunction.apply instead
|
JSValue |
callAsFunction(JSObject thiz)
Deprecated.
Function calls have been removed from JSObject since 3.0. Use JSFunction.call or
JSFunction.apply instead
|
JSValue |
callAsFunction(JSObject thiz,
JSValue[] args)
Deprecated.
Function calls have been removed from JSObject since 3.0. Use JSFunction.call or
JSFunction.apply instead
|
JSValue |
callAsFunction(JSValue[] args)
Deprecated.
Function calls have been removed from JSObject since 3.0. Use JSFunction.call or
JSFunction.apply instead
|
boolean |
deleteProperty(java.lang.String prop)
Deletes a property from the object
|
JSObject |
getThis() |
int |
hashCode() |
boolean |
hasProperty(java.lang.String prop)
Determines if the object contains a given property
|
boolean |
isConstructor()
Determines if the object is a constructor
|
boolean |
isFunction()
Determines if the object is a function
|
JSValue |
property(java.lang.String prop)
Gets the property named 'prop'
|
void |
property(java.lang.String prop,
java.lang.Object value)
Sets the value of property 'prop'.
|
void |
property(java.lang.String prop,
java.lang.Object value,
int attributes)
Sets the value of property 'prop'
|
JSValue |
propertyAtIndex(int index)
Returns the property at index 'index'.
|
void |
propertyAtIndex(int index,
java.lang.Object value)
Sets the property at index 'index'.
|
java.lang.String[] |
propertyNames()
Gets the list of set property names on the object
|
JSValue |
prototype()
Deprecated.
Constructor functions have been removed from JSObject since 3.0. Use
JSFunction.prototype() instead
|
void |
prototype(JSValue proto)
Deprecated.
Constructor functions have been removed from JSObject since 3.0. Use
JSFunction.prototype() instead
|
equals, getContext, isArray, isBoolean, isDate, isEqual, isInstanceOfConstructor, isNull, isNumber, isObject, isStrictEqual, isString, isUndefined, toBoolean, toFunction, toJSArray, toJSON, toJSON, toNumber, toObject, toString, valueRef
public static int JSPropertyAttributeNone
public static int JSPropertyAttributeReadOnly
public static int JSPropertyAttributeDontEnum
public static int JSPropertyAttributeDontDelete
public JSObject(JSContext ctx)
var obj = {}; // OR
var obj = new Object();
ctx
- The JSContext to create the object inpublic JSObject()
public JSObject(JSContext ctx, java.lang.Class<?> iface) throws JSException
var obj = {
func1: function(a) { alert(a); },
func2: function(b,c) { alert(b+c); }
};
Where func1, func2, etc. are defined in interface 'iface'. This JSObject
must implement 'iface'.ctx
- The JSContext to create the object iniface
- The Java Interface defining the methods to expose to JavaScriptJSException
public JSObject(JSContext ctx, java.util.Map map)
ctx
- The JSContext to create object inmap
- The map containing the properties@Deprecated public JSObject(JSContext ctx, java.lang.Class<?> iface, java.lang.Class<? extends JSObject> subclass) throws JSException
ctx
- deprecatediface
- deprecatedsubclass
- deprecatedJSException
@Deprecated public JSObject(JSContext ctx, JSObject invoke, java.lang.reflect.Method method) throws JSException
ctx
- deprecatedinvoke
- deprecatedmethod
- deprecatedJSException
public boolean hasProperty(java.lang.String prop)
prop
- The property to test the existence ofpublic JSValue property(java.lang.String prop) throws JSException
prop
- The name of the property to fetchJSException
public void property(java.lang.String prop, java.lang.Object value, int attributes) throws JSException
prop
- The name of the property to setvalue
- The Java object to set. The Java object will be converted to a JavaScript object
automatically.attributes
- And OR'd list of JSProperty constantsJSException
public void property(java.lang.String prop, java.lang.Object value) throws JSException
prop
- The name of the property to setvalue
- The Java object to set. The Java object will be converted to a JavaScript object
automatically.JSException
public boolean deleteProperty(java.lang.String prop) throws JSException
prop
- The name of the property to deleteJSException
public JSValue propertyAtIndex(int index) throws JSException
index
- The index of the propertyJSException
public void propertyAtIndex(int index, java.lang.Object value) throws JSException
index
- The index of the property to setvalue
- The Java object to set, will be automatically converted to a JavaScript valueJSException
public java.lang.String[] propertyNames()
public boolean isFunction()
public boolean isConstructor()
public JSObject getThis()
public JSValue __nullFunc()
@Deprecated public JSValue callAsFunction(JSObject thiz, JSValue[] args) throws JSException
thiz
- deprecatedargs
- deprecatedJSException
@Deprecated public JSValue callAsFunction(JSObject thiz) throws JSException
thiz
- deprecatedJSException
@Deprecated public JSValue callAsFunction(JSValue[] args) throws JSException
args
- deprecatedJSException
@Deprecated public JSValue callAsFunction() throws JSException
JSException
@Deprecated public JSValue prototype()
@Deprecated public void prototype(JSValue proto)
proto
- deprecated