xdc.services.getset
Class Setters

java.lang.Object
  extended by org.mozilla.javascript.ScriptableObject
      extended by org.mozilla.javascript.IdScriptableObject
          extended by org.mozilla.javascript.BaseFunction
              extended by xdc.services.getset.Setters
All Implemented Interfaces:
java.io.Serializable, org.mozilla.javascript.Callable, org.mozilla.javascript.ConstProperties, org.mozilla.javascript.debug.DebuggableObject, org.mozilla.javascript.Function, org.mozilla.javascript.IdFunctionCall, org.mozilla.javascript.Scriptable

public class Setters
extends org.mozilla.javascript.BaseFunction

A setter function to be added to a field of an XDCscript Var.Obj object. The Setters service manages a set of user-defined setter functions that notifies client code of a change to the value of the field. The setter only fires on writes to the field that actually change its value. Writing the current value again doesn't fire the setter.

There is also a set of global user-defined setter functions that are notified on any change. This avoids having to manually add such setters to every field. Note, though, that the global setters only apply to fields that have had the Setters service added to them.

The JavaScript setter functions have the signature:

 this.function(name, newValue, oldValue)
     this is set to the object whose field changed value
     name is the name of the field that changed value
     newValue is the new value of the field
     oldValue was the value of the field before the assignment
 
Following normal JavaScript conventions, unneeded arguments can be omitted from the declaration. So all of the following are valid declarations for a setter function:
 function(name, newValue, oldValue) {}
 function(name, newValue) {}
 function(name) {}
 function() {}
 

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.mozilla.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
 
Fields inherited from interface org.mozilla.javascript.Scriptable
NOT_FOUND
 
Constructor Summary
Setters(java.lang.Object member)
           
 
Method Summary
static void addGlobal(org.mozilla.javascript.Callable setter)
          Add a setter that is called when any field changes value.
 java.lang.Object call(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable scope, org.mozilla.javascript.Scriptable thisObj, java.lang.Object[] args)
          The master setter function called by XDCscript.
static int getMaxStackDepth()
          Get the maximum allowed depth of recursively nested setters.
static java.util.Set<org.mozilla.javascript.Callable> init(xdc.services.intern.xsr.Value.Observable obj, int index)
           
static java.util.Set<org.mozilla.javascript.Callable> init(xdc.services.intern.xsr.Value.Observable obj, java.lang.String name)
          Add setter support to a field of an object.
static void setMaxStackDepth(int maxStackDepth)
          Set the maximum allowed depth of recursively nested setters, as a debugging aid.
 
Methods inherited from class org.mozilla.javascript.BaseFunction
construct, createObject, execIdCall, fillConstructorProperties, findInstanceIdInfo, findPrototypeId, getArity, getClassName, getClassPrototype, getFunctionName, getInstanceIdName, getInstanceIdValue, getLength, getMaxInstanceId, hasInstance, initPrototypeId, setImmunePrototypeProperty, setInstanceIdValue
 
Methods inherited from class org.mozilla.javascript.IdScriptableObject
activatePrototypeMap, addIdFunctionProperty, defaultGet, defaultPut, delete, exportAsJSClass, get, getAttributes, has, hasPrototypeMap, incompatibleCallError, initPrototypeConstructor, initPrototypeMethod, initPrototypeValue, instanceIdInfo, put, setAttributes
 
Methods inherited from class org.mozilla.javascript.ScriptableObject
associateValue, avoidObjectDetection, callMethod, callMethod, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineProperty, defineProperty, defineProperty, defineProperty, delete, deleteProperty, deleteProperty, equivalentValues, get, getAllIds, getAssociatedValue, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, has, hasProperty, hasProperty, isConst, isGetterOrSetter, isSealed, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sealObject, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setParentScope, setPrototype
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mozilla.javascript.Scriptable
delete, delete, get, get, getDefaultValue, getIds, getParentScope, getPrototype, has, has, put, put, setParentScope, setPrototype
 

Constructor Detail

Setters

public Setters(java.lang.Object member)
Method Detail

init

public static java.util.Set<org.mozilla.javascript.Callable> init(xdc.services.intern.xsr.Value.Observable obj,
                                                                  java.lang.String name)
Add setter support to a field of an object.

Returns:
The set of user setters for the field.

init

public static java.util.Set<org.mozilla.javascript.Callable> init(xdc.services.intern.xsr.Value.Observable obj,
                                                                  int index)

call

public java.lang.Object call(org.mozilla.javascript.Context cx,
                             org.mozilla.javascript.Scriptable scope,
                             org.mozilla.javascript.Scriptable thisObj,
                             java.lang.Object[] args)
The master setter function called by XDCscript. First calls all the global setters, then calls the individual setters registered on this field.

Specified by:
call in interface org.mozilla.javascript.Callable
Specified by:
call in interface org.mozilla.javascript.Function
Overrides:
call in class org.mozilla.javascript.BaseFunction

addGlobal

public static void addGlobal(org.mozilla.javascript.Callable setter)
Add a setter that is called when any field changes value.


getMaxStackDepth

public static int getMaxStackDepth()
Get the maximum allowed depth of recursively nested setters.


setMaxStackDepth

public static void setMaxStackDepth(int maxStackDepth)
Set the maximum allowed depth of recursively nested setters, as a debugging aid.