Class FieldScriptableObject
java.lang.Object
org.web3d.vrml.scripting.ecmascript.builtin.FieldScriptableObject
- All Implemented Interfaces:
org.mozilla.javascript.Scriptable
- Direct Known Subclasses:
Matrix3
,Matrix4
,MFBool
,MFColor
,MFColorRGBA
,MFDouble
,MFFloat
,MFImage
,MFInt32
,MFRotation
,MFString
,MFTime
,MFVec2d
,MFVec2f
,MFVec3d
,MFVec3f
,MFVec4d
,MFVec4f
,NodeFieldObject
,SFColor
,SFColorRGBA
,SFImage
,SFRotation
,SFVec2d
,SFVec2f
,SFVec3d
,SFVec3f
,SFVec4d
,SFVec4f
,VrmlMatrix
public abstract class FieldScriptableObject
extends Object
implements org.mozilla.javascript.Scriptable
Base representation of all field objects in ecmascript scripting.
All fields must extend this class. All implementations should make sure to set the dataChanged field whenever their internal data state has been modified.
- Version:
- $Revision: 1.6 $
- 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 boolean
Flag to say this field is read only (directOutput == true)protected static final String
Error message for when the field is marked readOnlyprotected boolean
Flag to say this is a script variable and that the readOnly rules are modified somewhat to deal with it.Fields inherited from interface org.mozilla.javascript.Scriptable
NOT_FOUND
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
FieldScriptableObject
(String name) 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 value of the named function.The class name as defined to the Javascript function.getDefaultValue
(Class hint) Object[]
getIds()
org.mozilla.javascript.Scriptable
org.mozilla.javascript.Scriptable
boolean
has
(int index, org.mozilla.javascript.Scriptable start) boolean
boolean
Query this field object to see if it has changed since the last time this method was called.boolean
hasInstance
(org.mozilla.javascript.Scriptable value) protected org.mozilla.javascript.FunctionObject
locateFunction
(String methodName) Convenience method to locate a function name for this object and create an appropriate Function instance to represent it.void
Sets a property based on the index.void
Sets the named property with a new value.protected void
registerFunction
(String name, Object value) Register a function object with this field typevoid
setParentScope
(org.mozilla.javascript.Scriptable parent) void
setPrototype
(org.mozilla.javascript.Scriptable proto) Ignored.void
Set this field to be read only.void
Set this field to be a script field.
-
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:
-
dataChanged
protected boolean dataChangedFlag to be set if the data has changed -
readOnly
protected boolean readOnlyFlag to say this field is read only (directOutput == true) -
scriptField
protected boolean scriptFieldFlag to say this is a script variable and that the readOnly rules are modified somewhat to deal with it. It allows direct writing to this field, but does not allow writing to any children field.
-
-
Constructor Details
-
FieldScriptableObject
Default public constructor required by Rhino for when created by an Ecmascript call.- Parameters:
name
- the name of this Scriptable object
-
-
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) - Specified by:
has
in interfaceorg.mozilla.javascript.Scriptable
-
has
- Specified by:
has
in interfaceorg.mozilla.javascript.Scriptable
-
get
- Specified by:
get
in interfaceorg.mozilla.javascript.Scriptable
-
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
- Specified by:
getIds
in interfaceorg.mozilla.javascript.Scriptable
-
hasInstance
public boolean hasInstance(org.mozilla.javascript.Scriptable value) - Specified by:
hasInstance
in interfaceorg.mozilla.javascript.Scriptable
-
getParentScope
public org.mozilla.javascript.Scriptable getParentScope()- Specified by:
getParentScope
in interfaceorg.mozilla.javascript.Scriptable
-
setParentScope
public void setParentScope(org.mozilla.javascript.Scriptable parent) - Specified by:
setParentScope
in interfaceorg.mozilla.javascript.Scriptable
-
getPrototype
public org.mozilla.javascript.Scriptable getPrototype()- Specified by:
getPrototype
in interfaceorg.mozilla.javascript.Scriptable
-
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
-
setScriptField
public void setScriptField()Set this field to be a script field. Once set, cannot be turned off. -
setReadOnly
public void setReadOnly()Set this field to be read only. Once set, cannot be turned off. -
registerFunction
-
locateFunction
Convenience method to locate a function name for this object and create an appropriate Function instance to represent it. It assumes that the name you give it is the normal name and will add a "jsFunction_" prefix to locate that from the method details. There is also the implicit assumption that you have made a check for this name being a valid function for this object before you call this method. If a function object is found for this method, it will automatically be registered and you can also have a copy of it returned to use.- Parameters:
methodName
- The real method name to look for- Returns:
- The function object corresponding to the munged method name
-
hasChanged
public boolean hasChanged()Query this field object to see if it has changed since the last time this method was called. In a single-threaded environment, calling this method twice should return true and then false (assuming that data had changed since the previous calls).- Returns:
- true if the data has changed.
-