public abstract class AbstractIdObject<T extends AbstractIdObject>
extends org.mozilla.javascript.IdScriptableObject
This class makes it easier to use Rhino's "IdFunctionObject" by maintaining a map between prototype method names and property names, so all the implementor has to do is implement them. IdFunctionObject is more efficient than using the @JSFunction and @JSGetter annotations because it does not use reflection. This class uses a set of static HashMaps, per Java class, to mape between function and property IDs and names. This is slightly less-efficient than the hand-rolled switches used in Rhino source code but it is very close.
To use a class, a subclass must:
| Modifier and Type | Field and Description |
|---|---|
protected static int |
Id_constructor |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractIdObject(IdPropertyMap map) |
| Modifier and Type | Method and Description |
|---|---|
protected Object |
anonymousCall(int id,
org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
Object thisObj,
Object[] args)
Subclasses may override this method to implement a function that does not necessarily depend
on the value of "this" in the current scope.
|
protected abstract T |
defaultConstructor()
Subclasses must override this function.
|
protected T |
defaultConstructor(org.mozilla.javascript.Context cx,
Object[] args)
Subclasses who need arguments to their constructor may override this function.
|
Object |
execIdCall(org.mozilla.javascript.IdFunctionObject f,
org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
org.mozilla.javascript.Scriptable thisObj,
Object[] args) |
org.mozilla.javascript.Function |
exportAsClass(org.mozilla.javascript.Scriptable scope) |
protected int |
findInstanceIdInfo(String name) |
protected int |
findPrototypeId(String name) |
String |
getClassName() |
protected String |
getInstanceIdName(int id) |
protected int |
getMaxInstanceId() |
protected void |
initPrototypeId(int id) |
protected Object |
prototypeCall(int id,
org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
Object[] args)
Subclasses may override this method to implement a prototype function.
|
activatePrototypeMap, addIdFunctionProperty, defaultGet, defaultHas, defaultPut, defineOwnProperty, delete, exportAsJSClass, fillConstructorProperties, get, getAttributes, getInstanceIdValue, getOwnPropertyDescriptor, has, hasPrototypeMap, incompatibleCallError, initPrototypeConstructor, initPrototypeMethod, initPrototypeValue, instanceIdInfo, put, setAttributes, setInstanceIdAttributes, setInstanceIdValueapplyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, equivalentValues, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, hasInstance, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, sizeprotected static final int Id_constructor
protected AbstractIdObject(IdPropertyMap map)
protected Object prototypeCall(int id, org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable scope, Object[] args)
protected Object anonymousCall(int id, org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable scope, Object thisObj, Object[] args)
protected T defaultConstructor(org.mozilla.javascript.Context cx, Object[] args)
protected abstract T defaultConstructor()
public String getClassName()
getClassName in interface org.mozilla.javascript.ScriptablegetClassName in class org.mozilla.javascript.ScriptableObjectpublic org.mozilla.javascript.Function exportAsClass(org.mozilla.javascript.Scriptable scope)
protected String getInstanceIdName(int id)
getInstanceIdName in class org.mozilla.javascript.IdScriptableObjectprotected int findInstanceIdInfo(String name)
findInstanceIdInfo in class org.mozilla.javascript.IdScriptableObjectprotected int getMaxInstanceId()
getMaxInstanceId in class org.mozilla.javascript.IdScriptableObjectprotected void initPrototypeId(int id)
initPrototypeId in class org.mozilla.javascript.IdScriptableObjectprotected int findPrototypeId(String name)
findPrototypeId in class org.mozilla.javascript.IdScriptableObjectpublic Object execIdCall(org.mozilla.javascript.IdFunctionObject f, org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable scope, org.mozilla.javascript.Scriptable thisObj, Object[] args)
execIdCall in interface org.mozilla.javascript.IdFunctionCallexecIdCall in class org.mozilla.javascript.IdScriptableObjectCopyright © 2016 Apigee Corporation. All Rights Reserved.