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 StringError message when given a string that you parse for a number and it is not a valid format.protected booleanFlag to be set if the data has changedprotected static final StringError message when a property is being set and it is not a compatible javascript type with what is required.protected booleanFlag to say this field is read only (directOutput == true)protected static final StringError message for when the field is marked readOnlyprotected booleanFlag 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
ConstructorsModifierConstructorDescriptionprotectedFieldScriptableObject(String name) Default public constructor required by Rhino for when created by an Ecmascript call. -
Method Summary
Modifier and TypeMethodDescriptionvoiddelete(int index) Delete a property.voidDelete 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.Scriptableorg.mozilla.javascript.Scriptablebooleanhas(int index, org.mozilla.javascript.Scriptable start) booleanbooleanQuery this field object to see if it has changed since the last time this method was called.booleanhasInstance(org.mozilla.javascript.Scriptable value) protected org.mozilla.javascript.FunctionObjectlocateFunction(String methodName) Convenience method to locate a function name for this object and create an appropriate Function instance to represent it.voidSets a property based on the index.voidSets the named property with a new value.protected voidregisterFunction(String name, Object value) Register a function object with this field typevoidsetParentScope(org.mozilla.javascript.Scriptable parent) voidsetPrototype(org.mozilla.javascript.Scriptable proto) Ignored.voidSet this field to be read only.voidSet 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:
getClassNamein interfaceorg.mozilla.javascript.Scriptable- Returns:
- the name of this class
-
getDefaultValue
-
has
public boolean has(int index, org.mozilla.javascript.Scriptable start) - Specified by:
hasin interfaceorg.mozilla.javascript.Scriptable
-
has
- Specified by:
hasin interfaceorg.mozilla.javascript.Scriptable
-
get
- Specified by:
getin 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:
getin 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:
putin 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:
putin 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:
deletein 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:
deletein interfaceorg.mozilla.javascript.Scriptable- Parameters:
name- The name of the property to delete
-
getIds
- Specified by:
getIdsin interfaceorg.mozilla.javascript.Scriptable
-
hasInstance
public boolean hasInstance(org.mozilla.javascript.Scriptable value) - Specified by:
hasInstancein interfaceorg.mozilla.javascript.Scriptable
-
getParentScope
public org.mozilla.javascript.Scriptable getParentScope()- Specified by:
getParentScopein interfaceorg.mozilla.javascript.Scriptable
-
setParentScope
public void setParentScope(org.mozilla.javascript.Scriptable parent) - Specified by:
setParentScopein interfaceorg.mozilla.javascript.Scriptable
-
getPrototype
public org.mozilla.javascript.Scriptable getPrototype()- Specified by:
getPrototypein 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:
setPrototypein 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.
-