Class AbstractScriptableObject
java.lang.Object
org.web3d.vrml.scripting.ecmascript.builtin.AbstractScriptableObject
- All Implemented Interfaces:
org.mozilla.javascript.Scriptable
- Direct Known Subclasses:
Browser
,ComponentInfo
,ComponentInfoArray
,ExternProtoDeclaration
,ExternProtoDeclarationArray
,FieldDefinitionArray
,ProfileInfo
,ProfileInfoArray
,ProtoDeclaration
,ProtoDeclarationArray
,Route
,RouteArray
,X3DConstants
,X3DExecutionContext
,X3DFieldDefinition
public abstract class AbstractScriptableObject
extends Object
implements org.mozilla.javascript.Scriptable
Base representation of all miscellaneous objects in ecmascript scripting.
- Version:
- $Revision: 1.1 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final String
Error message when given a string that you parse for a number and it is not a valid format.protected boolean
Flag to be set if the data has changedprotected static final String
Error message when a property is being set and it is not a compatible javascript type with what is required.protected static final String
The prefix of the name for any function call we dynamically look upprotected boolean
Flag to say this field is read onlyprotected static final String
Error message for when the field is marked readOnlyFields inherited from interface org.mozilla.javascript.Scriptable
NOT_FOUND
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Default public constructor required by Rhino for when created by an Ecmascript call. -
Method Summary
Modifier and TypeMethodDescriptionvoid
delete
(int index) Delete a property.void
Delete a property.get
(int index, org.mozilla.javascript.Scriptable start) Get the variable at the given index.Get the value of the named function.The class name as defined to the Javascript function.getDefaultValue
(Class hint) Return a default value for this.Object[]
getIds()
Get properties.org.mozilla.javascript.Scriptable
Fetch the parent scope of this context.org.mozilla.javascript.Scriptable
Get the prototype used by this context.boolean
has
(int index, org.mozilla.javascript.Scriptable start) Check for the indexed property presence.boolean
Check for the named property presence.boolean
hasInstance
(org.mozilla.javascript.Scriptable value) void
Sets a property based on the index.void
Sets the named property with a new value.void
setParentScope
(org.mozilla.javascript.Scriptable parent) Set the parent scope of this object.void
setPrototype
(org.mozilla.javascript.Scriptable proto) Ignored.void
Set this field to be read only.
-
Field Details
-
BAD_FORMAT_MSG
Error message when given a string that you parse for a number and it is not a valid format. The message assumes that you will tack on the passed in string as part of the message.- See Also:
-
INVALID_TYPE_MSG
Error message when a property is being set and it is not a compatible javascript type with what is required.- See Also:
-
READONLY_MSG
Error message for when the field is marked readOnly- See Also:
-
JS_FUNCTION_PREFIX
The prefix of the name for any function call we dynamically look up- See Also:
-
dataChanged
protected boolean dataChangedFlag to be set if the data has changed -
readOnly
protected boolean readOnlyFlag to say this field is read only
-
-
Constructor Details
-
AbstractScriptableObject
Default public constructor required by Rhino for when created by an Ecmascript call.- Parameters:
name
- the class name of the script
-
-
Method Details
-
getClassName
The class name as defined to the Javascript function.- Specified by:
getClassName
in interfaceorg.mozilla.javascript.Scriptable
- Returns:
- the name of this class
-
getDefaultValue
-
has
public boolean has(int index, org.mozilla.javascript.Scriptable start) Check for the indexed property presence. Always returns NOT_FOUND as ECMAScript doesn't support indexed objects.- Specified by:
has
in interfaceorg.mozilla.javascript.Scriptable
- Returns:
- false (NOT_FOUND)
-
has
Check for the named property presence.- Specified by:
has
in interfaceorg.mozilla.javascript.Scriptable
- Parameters:
name
- name of the scriptstart
- the script corresponding to the given name- Returns:
- true if it is a defined eventOut or field
-
get
Get the variable at the given index. Since we don't support integer index values for fields of the script, this always returns NOT_FOUND.- Specified by:
get
in interfaceorg.mozilla.javascript.Scriptable
- Returns:
- NOT_FOUND
-
get
Get the value of the named function. If no function object is registered for this name, the method will return null.- Specified by:
get
in interfaceorg.mozilla.javascript.Scriptable
- Parameters:
name
- The variable namestart
- The object where the lookup began- Returns:
- the corresponding function object or null
-
put
Sets a property based on the index. Since we don't support indexes, this is ignored.- Specified by:
put
in interfaceorg.mozilla.javascript.Scriptable
- Parameters:
index
- The index of the property to setstart
- The object who's property is being setvalue
- The value being requested
-
put
Sets the named property with a new value. A put usually means changing the entire property. So, if the property has changed using an operation likee = new SFVec3f(0, 1, 0);
then a whole new object is passed to us.- Specified by:
put
in interfaceorg.mozilla.javascript.Scriptable
- Parameters:
name
- The name of the property to definestart
- The object who's property is being setvalue
- The value being requested
-
delete
public void delete(int index) Delete a property. There are no dynamic fields, so this does nothing.- Specified by:
delete
in interfaceorg.mozilla.javascript.Scriptable
- Parameters:
index
- The index of the property to delete
-
delete
Delete a property. There are no dynamic fields, so this does nothing.- Specified by:
delete
in interfaceorg.mozilla.javascript.Scriptable
- Parameters:
name
- The name of the property to delete
-
getIds
Get properties. We return an empty array since we define all properties to be DONTENUM.- Specified by:
getIds
in interfaceorg.mozilla.javascript.Scriptable
- Returns:
- EMPTY_IDS
-
hasInstance
public boolean hasInstance(org.mozilla.javascript.Scriptable value) - Specified by:
hasInstance
in interfaceorg.mozilla.javascript.Scriptable
-
getParentScope
public org.mozilla.javascript.Scriptable getParentScope()Fetch the parent scope of this context.- Specified by:
getParentScope
in interfaceorg.mozilla.javascript.Scriptable
- Returns:
- parentScope
-
setParentScope
public void setParentScope(org.mozilla.javascript.Scriptable parent) Set the parent scope of this object. Should be the global shared instance.- Specified by:
setParentScope
in interfaceorg.mozilla.javascript.Scriptable
- Parameters:
parent
- new value for parentScope
-
getPrototype
public org.mozilla.javascript.Scriptable getPrototype()Get the prototype used by this context.- Specified by:
getPrototype
in interfaceorg.mozilla.javascript.Scriptable
- Returns:
- prototype
-
setPrototype
public void setPrototype(org.mozilla.javascript.Scriptable proto) Ignored. Set the prototype for this context. The context does not have a prototype that we want the user to play with.- Specified by:
setPrototype
in interfaceorg.mozilla.javascript.Scriptable
- Parameters:
proto
- The prototype definition to use
-
setReadOnly
public void setReadOnly()Set this field to be read only. Once set, cannot be turned off.
-