| java.lang.Object org.mozilla.javascript.ScriptableObject org.mozilla.javascript.IdScriptableObject
All known Subclasses: org.mozilla.javascript.xmlimpl.Namespace, org.mozilla.javascript.ImporterTopLevel, org.mozilla.javascript.NativeMath, org.mozilla.javascript.Arguments, org.mozilla.javascript.NativeIterator, org.mozilla.javascript.NativeCall, org.mozilla.javascript.NativeObject, org.mozilla.javascript.xml.impl.xmlbeans.Namespace, org.mozilla.javascript.NativeDate, org.mozilla.javascript.continuations.Continuation, org.mozilla.javascript.NativeError, org.mozilla.javascript.xml.XMLObject, org.mozilla.javascript.regexp.NativeRegExp, org.mozilla.javascript.xml.impl.xmlbeans.QName, org.mozilla.javascript.BaseFunction, org.mozilla.javascript.NativeArray, org.mozilla.javascript.xmlimpl.QName, org.mozilla.javascript.NativeString, org.mozilla.javascript.NativeNumber, org.mozilla.javascript.NativeGenerator, org.mozilla.javascript.NativeBoolean,
IdScriptableObject | abstract public class IdScriptableObject extends ScriptableObject implements IdFunctionCall(Code) | | Base class for native object implementation that uses IdFunctionObject to export its methods to script via .prototype object.
Any descendant should implement at least the following methods:
findInstanceIdInfo
getInstanceIdName
execIdCall
methodArity
To define non-function properties, the descendant should override
getInstanceIdValue
setInstanceIdValue
to get/set property value and provide its default attributes.
To customize initializition of constructor and protype objects, descendant
may override scopeInit or fillConstructorProperties methods.
|
Method Summary | |
final public void | activatePrototypeMap(int maxPrototypeId) | protected void | addIdFunctionProperty(Scriptable obj, Object tag, int id, String name, int arity) | final protected Object | defaultGet(String name) | final protected void | defaultPut(String name, Object value) | public void | delete(String name) | public Object | execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) 'thisObj' will be null if invoked as constructor, in which case
instance of Scriptable should be returned. | final public IdFunctionObject | exportAsJSClass(int maxPrototypeId, Scriptable scope, boolean sealed) | protected void | fillConstructorProperties(IdFunctionObject ctor) | protected int | findInstanceIdInfo(String name) Map name to id of instance property. | protected int | findPrototypeId(String name) | public Object | get(String name, Scriptable start) | public int | getAttributes(String name) | Object[] | getIds(boolean getAll) | protected String | getInstanceIdName(int id) Map id back to property name it defines. | protected Object | getInstanceIdValue(int id) Get id value. | protected int | getMaxInstanceId() Get maximum id findInstanceIdInfo can generate. | public boolean | has(String name, Scriptable start) | final public boolean | hasPrototypeMap() | protected static EcmaError | incompatibleCallError(IdFunctionObject f) Utility method to construct type error to indicate incompatible call
when converting script thisObj to a particular type is not possible.
Possible usage would be to have a private function like realThis:
private static NativeSomething realThis(Scriptable thisObj,
IdFunctionObject f)
{
if (!(thisObj instanceof NativeSomething))
throw incompatibleCallError(f);
return (NativeSomething)thisObj;
}
Note that although such function can be implemented universally via
java.lang.Class.isInstance(), it would be much more slower.
Parameters: f - function that is attempting to convert 'this'object. | final public void | initPrototypeConstructor(IdFunctionObject f) | protected void | initPrototypeId(int id) | final public void | initPrototypeMethod(Object tag, int id, String name, int arity) | final public void | initPrototypeValue(int id, String name, Object value, int attributes) | protected static int | instanceIdInfo(int attributes, int id) | public void | put(String name, Scriptable start, Object value) | public void | setAttributes(String name, int attributes) | protected void | setInstanceIdValue(int id, Object value) Set or delete id value. |
IdScriptableObject | public IdScriptableObject()(Code) | | |
activatePrototypeMap | final public void activatePrototypeMap(int maxPrototypeId)(Code) | | |
findPrototypeId | protected int findPrototypeId(String name)(Code) | | |
getInstanceIdName | protected String getInstanceIdName(int id)(Code) | | Map id back to property name it defines.
|
getInstanceIdValue | protected Object getInstanceIdValue(int id)(Code) | | Get id value.
If id value is constant, descendant can call cacheIdValue to store
value in the permanent cache.
Default implementation creates IdFunctionObject instance for given id
and cache its value
|
getMaxInstanceId | protected int getMaxInstanceId()(Code) | | Get maximum id findInstanceIdInfo can generate.
|
hasPrototypeMap | final public boolean hasPrototypeMap()(Code) | | |
incompatibleCallError | protected static EcmaError incompatibleCallError(IdFunctionObject f)(Code) | | Utility method to construct type error to indicate incompatible call
when converting script thisObj to a particular type is not possible.
Possible usage would be to have a private function like realThis:
private static NativeSomething realThis(Scriptable thisObj,
IdFunctionObject f)
{
if (!(thisObj instanceof NativeSomething))
throw incompatibleCallError(f);
return (NativeSomething)thisObj;
}
Note that although such function can be implemented universally via
java.lang.Class.isInstance(), it would be much more slower.
Parameters: f - function that is attempting to convert 'this'object. Scriptable object suitable for a check by the instanceofoperator. throws: RuntimeException - if no more instanceof target can be found |
initPrototypeId | protected void initPrototypeId(int id)(Code) | | |
initPrototypeMethod | final public void initPrototypeMethod(Object tag, int id, String name, int arity)(Code) | | |
initPrototypeValue | final public void initPrototypeValue(int id, String name, Object value, int attributes)(Code) | | |
instanceIdInfo | protected static int instanceIdInfo(int attributes, int id)(Code) | | |
setAttributes | public void setAttributes(String name, int attributes)(Code) | | |
setInstanceIdValue | protected void setInstanceIdValue(int id, Object value)(Code) | | Set or delete id value. If value == NOT_FOUND , the implementation
should make sure that the following getInstanceIdValue return NOT_FOUND.
|
Methods inherited from org.mozilla.javascript.ScriptableObject | void addLazilyInitializedValue(String name, int index, LazilyLoadedCtor init, int attributes)(Code)(Java Doc) final public Object associateValue(Object key, Object value)(Code)(Java Doc) public boolean avoidObjectDetection()(Code)(Java Doc) static BaseFunction buildClassCtor(Scriptable scope, Class clazz, boolean sealed, boolean mapInheritance) throws IllegalAccessException, InstantiationException, InvocationTargetException(Code)(Java Doc) public static Object callMethod(Scriptable obj, String methodName, Object[] args)(Code)(Java Doc) public static Object callMethod(Context cx, Scriptable obj, String methodName, Object[] args)(Code)(Java Doc) static void checkValidAttributes(int attributes)(Code)(Java Doc) public static void defineClass(Scriptable scope, Class clazz) throws IllegalAccessException, InstantiationException, InvocationTargetException(Code)(Java Doc) public static void defineClass(Scriptable scope, Class clazz, boolean sealed) throws IllegalAccessException, InstantiationException, InvocationTargetException(Code)(Java Doc) public static String defineClass(Scriptable scope, Class clazz, boolean sealed, boolean mapInheritance) throws IllegalAccessException, InstantiationException, InvocationTargetException(Code)(Java Doc) public void defineConst(String name, Scriptable start)(Code)(Java Doc) public static void defineConstProperty(Scriptable destination, String propertyName)(Code)(Java Doc) public void defineFunctionProperties(String[] names, Class clazz, int attributes)(Code)(Java Doc) public void defineProperty(String propertyName, Object value, int attributes)(Code)(Java Doc) public static void defineProperty(Scriptable destination, String propertyName, Object value, int attributes)(Code)(Java Doc) public void defineProperty(String propertyName, Class clazz, int attributes)(Code)(Java Doc) public void defineProperty(String propertyName, Object delegateTo, Method getter, Method setter, int attributes)(Code)(Java Doc) public void delete(String name)(Code)(Java Doc) public void delete(int index)(Code)(Java Doc) public static boolean deleteProperty(Scriptable obj, String name)(Code)(Java Doc) public static boolean deleteProperty(Scriptable obj, int index)(Code)(Java Doc) protected Object equivalentValues(Object value)(Code)(Java Doc) public Object get(String name, Scriptable start)(Code)(Java Doc) public Object get(int index, Scriptable start)(Code)(Java Doc) public Object[] getAllIds()(Code)(Java Doc) final public Object getAssociatedValue(Object key)(Code)(Java Doc) final public int getAttributes(String name, Scriptable start)(Code)(Java Doc) final public int getAttributes(int index, Scriptable start)(Code)(Java Doc) public int getAttributes(String name)(Code)(Java Doc) public int getAttributes(int index)(Code)(Java Doc) abstract public String getClassName()(Code)(Java Doc) public static Scriptable getClassPrototype(Scriptable scope, String className)(Code)(Java Doc) public Object getDefaultValue(Class typeHint)(Code)(Java Doc) public static Object getDefaultValue(Scriptable object, Class typeHint)(Code)(Java Doc) public static Scriptable getFunctionPrototype(Scriptable scope)(Code)(Java Doc) public Object getGetterOrSetter(String name, int index, boolean isSetter)(Code)(Java Doc) public Object[] getIds()(Code)(Java Doc) Object[] getIds(boolean getAll)(Code)(Java Doc) public static Scriptable getObjectPrototype(Scriptable scope)(Code)(Java Doc) public Scriptable getParentScope()(Code)(Java Doc) public static Object getProperty(Scriptable obj, String name)(Code)(Java Doc) public static Object getProperty(Scriptable obj, int index)(Code)(Java Doc) public static Object[] getPropertyIds(Scriptable obj)(Code)(Java Doc) public Scriptable getPrototype()(Code)(Java Doc) public static Scriptable getTopLevelScope(Scriptable obj)(Code)(Java Doc) public static Object getTopScopeValue(Scriptable scope, Object key)(Code)(Java Doc) public boolean has(String name, Scriptable start)(Code)(Java Doc) public boolean has(int index, Scriptable start)(Code)(Java Doc) public boolean hasInstance(Scriptable instance)(Code)(Java Doc) public static boolean hasProperty(Scriptable obj, String name)(Code)(Java Doc) public static boolean hasProperty(Scriptable obj, int index)(Code)(Java Doc) public boolean isConst(String name)(Code)(Java Doc) protected boolean isGetterOrSetter(String name, int index, boolean setter)(Code)(Java Doc) final public boolean isSealed()(Code)(Java Doc) public void put(String name, Scriptable start, Object value)(Code)(Java Doc) public void put(int index, Scriptable start, Object value)(Code)(Java Doc) public void putConst(String name, Scriptable start, Object value)(Code)(Java Doc) public static void putConstProperty(Scriptable obj, String name, Object value)(Code)(Java Doc) public static void putProperty(Scriptable obj, String name, Object value)(Code)(Java Doc) public static void putProperty(Scriptable obj, int index, Object value)(Code)(Java Doc) public static void redefineProperty(Scriptable obj, String name, boolean isConst)(Code)(Java Doc) public synchronized void sealObject()(Code)(Java Doc) final public void setAttributes(String name, Scriptable start, int attributes)(Code)(Java Doc) public void setAttributes(int index, Scriptable start, int attributes)(Code)(Java Doc) public void setAttributes(String name, int attributes)(Code)(Java Doc) public void setAttributes(int index, int attributes)(Code)(Java Doc) public void setGetterOrSetter(String name, int index, Callable getterOrSeter, boolean isSetter)(Code)(Java Doc) public void setParentScope(Scriptable m)(Code)(Java Doc) public void setPrototype(Scriptable m)(Code)(Java Doc)
|
|
|