ice.storm
Class DynamicObject

java.lang.Object
  extended byice.storm.DynamicObject
Direct Known Subclasses:
DAttr, DNode, DocumentProxy, DOM, DOMEvent, DynamicList

public class DynamicObject
extends Object

Object should extends from this class if it can be exposed to a scripter. In general methods with word Dynamic are to access a fixed number of methods and fields known at compile time and Slot variants are responsible for more flexible structures. If accessing named property, scripter should first call Dynamic method, then imploy reflection if necessary and then call Slot method if field/method was not found. All methods with `DynEnv env' argument should use it to warp/unwrap script objects to a particular type.


Field Summary
static Object NOT_FOUND
          Indicates that dynamic value was does not present
static int SETD_IGNORE
          Return values for setDynamicValue
static int SETD_NOT_FOUND
          Return values for setDynamicValue
static int SETD_OK
          Return values for setDynamicValue
 
Constructor Summary
DynamicObject()
           
 
Method Summary
 void deleteSlot(int index)
           
 void deleteSlot(String name)
           
 Object execDynamicMethod(String name, Object[] args, DynEnv env)
          Perform function-like actions for `name' with the given args.
 Object getDynamicScopeParent()
          This is only relevant to support scope chain during event handler execution.
 Object getDynamicValue(String name, DynEnv env)
          Returns the `key' field or Defs.NOT_FOUND if `name' does not exist.
 Object[] getEnumeratableIds(DynEnv env, int add_head_allocation)
           
 DynamicObject getMethodPropertySource(String methodName, DynEnv env)
          ALERT: this is some-what weired method but it helps to merge same named properties and methods
protected  Object getScriptDataLock()
          Return lock object to get exclusive access for scripta data or null if no synchronization should be used
 Object getScriptWrapper(Object key)
           
 Object getSlot(int index, DynEnv env)
           
 Object getSlot(String name, DynEnv env)
           
 boolean hasSlot(int index, DynEnv env)
           
 boolean hasSlot(String name, DynEnv env)
           
 Object javaReflectionTarget()
          Returns null if Java reflection should not be used for this object.
 boolean readOnlySlots()
          Returns true if access to object via Slot-type methods are read-only
protected  Object script_toSource(DynEnv env)
          Overwrite if notion of `source' can be implemented in a resonable way.
 String script_toString(DynEnv env)
          Overwrite if Java toString() is not good enough for script Invoked via execDynamicMethod("toString", ...)
 int setDynamicValue(String name, Object value, DynEnv env)
          Set field `name' to `value'.
 Object setScriptWrapperIfAbsent(Object key, Object value)
           
 void setSlot(int index, Object value, DynEnv env)
          Set index slot to `value'.
 void setSlot(String name, Object value, DynEnv env)
          Set named slot to `value'.
 void unlinkAllSlots()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOT_FOUND

public static final Object NOT_FOUND
Indicates that dynamic value was does not present


SETD_NOT_FOUND

public static final int SETD_NOT_FOUND
Return values for setDynamicValue

See Also:
Constant Field Values

SETD_OK

public static final int SETD_OK
Return values for setDynamicValue

See Also:
Constant Field Values

SETD_IGNORE

public static final int SETD_IGNORE
Return values for setDynamicValue

See Also:
Constant Field Values
Constructor Detail

DynamicObject

public DynamicObject()
Method Detail

getScriptDataLock

protected Object getScriptDataLock()
Return lock object to get exclusive access for scripta data or null if no synchronization should be used


javaReflectionTarget

public Object javaReflectionTarget()
Returns null if Java reflection should not be used for this object. Otherwise returns object upon which Java reflection will be used to get additional dynamic properties. Can return Defs.NOT_FOUND to indicate that undefined should be returned as wrapper to scrits


readOnlySlots

public boolean readOnlySlots()
Returns true if access to object via Slot-type methods are read-only


getDynamicValue

public Object getDynamicValue(String name,
                              DynEnv env)
Returns the `key' field or Defs.NOT_FOUND if `name' does not exist. Returns `FUNCTION_MARK' if `name' represent a function that can be invoke via execDynamicMethod. Note that returned `null' indicates that value is present but set to null.


setDynamicValue

public int setDynamicValue(String name,
                           Object value,
                           DynEnv env)
Set field `name' to `value'. Use `env' to unwrap `value' to a particular type or store it as is

Returns:
SETD_NOT_FOUND if fied `name' is absent, SETD_IGNORE if field exist but set is ignored SETD_OK if set opeartion was ok

execDynamicMethod

public Object execDynamicMethod(String name,
                                Object[] args,
                                DynEnv env)
Perform function-like actions for `name' with the given args. Returns the result or Defs.NOT_FOUND if name is not associated with function action. Should return result of env.wrapVoid() to indicate method without return value. Use `env' to unwrap `args' elements to a particular type.

See Also:
DynEnv

getMethodPropertySource

public DynamicObject getMethodPropertySource(String methodName,
                                             DynEnv env)
ALERT: this is some-what weired method but it helps to merge same named properties and methods


getDynamicScopeParent

public Object getDynamicScopeParent()
This is only relevant to support scope chain during event handler execution. In ideal world this should always return null


script_toSource

protected Object script_toSource(DynEnv env)
Overwrite if notion of `source' can be implemented in a resonable way. Invoked via execDynamicMethod("toSource", ...)


script_toString

public String script_toString(DynEnv env)
Overwrite if Java toString() is not good enough for script Invoked via execDynamicMethod("toString", ...)


hasSlot

public boolean hasSlot(String name,
                       DynEnv env)

hasSlot

public boolean hasSlot(int index,
                       DynEnv env)

getSlot

public Object getSlot(String name,
                      DynEnv env)

getSlot

public Object getSlot(int index,
                      DynEnv env)

setSlot

public void setSlot(String name,
                    Object value,
                    DynEnv env)
Set named slot to `value'. If `value' should be converted to some type, use `env' for conversions


setSlot

public void setSlot(int index,
                    Object value,
                    DynEnv env)
Set index slot to `value'. If `value' should be converted to some type, use `env' for conversions


deleteSlot

public void deleteSlot(String name)

deleteSlot

public void deleteSlot(int index)

setScriptWrapperIfAbsent

public Object setScriptWrapperIfAbsent(Object key,
                                       Object value)

getScriptWrapper

public Object getScriptWrapper(Object key)

unlinkAllSlots

public void unlinkAllSlots()

getEnumeratableIds

public Object[] getEnumeratableIds(DynEnv env,
                                   int add_head_allocation)