Package helma.scripting.rhino
Class HopObject
java.lang.Object
org.mozilla.javascript.ScriptableObject
helma.scripting.rhino.HopObject
- All Implemented Interfaces:
PropertyRecorder
,Serializable
,org.mozilla.javascript.ConstProperties
,org.mozilla.javascript.debug.DebuggableObject
,org.mozilla.javascript.Scriptable
,org.mozilla.javascript.SymbolScriptable
,org.mozilla.javascript.Wrapper
public class HopObject
extends org.mozilla.javascript.ScriptableObject
implements org.mozilla.javascript.Wrapper, PropertyRecorder
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.mozilla.javascript.ScriptableObject
org.mozilla.javascript.ScriptableObject.KeyComparator
-
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
ConstructorsModifierConstructorDescriptionprotected
Creates a new HopObject prototype.protected
HopObject
(String className, RhinoCore core, NodeHandle handle, org.mozilla.javascript.Scriptable proto) Creates a new HopObject.protected
Creates a new HopObject. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clear the set of changed properties.void
defineProperty
(String propertyName, Object value, int attributes) Overwritten to not define constructor property as constant - we need to have the constructor property resettable in Helma.void
protected Object
equivalentValues
(Object value) Custom == operator.get
(int idx, org.mozilla.javascript.Scriptable start) Object[]
Return all property names of this object.Returns a set containing the names of properties changed since the last time startRecording() was called.Get the class/prototype name for this HopObjectgetDefaultValue
(Class hint) Return a primitive representation for this object.Object[]
getIds()
Return all "ordinary" property ids of this object.getNode()
Return the INode wrapped by this HopObject.boolean
has
(int idx, org.mozilla.javascript.Scriptable start) boolean
Check if a property is set in this HopObjectstatic HopObject
Initialize HopObject prototype for Rhino scope.boolean
jsFunction_add
(Object child) boolean
jsFunction_addAt
(int index, Object child) void
Clear the node's cache node.int
Deprecated.use indexOf(Object) instead.int
jsFunction_get
(Object id) Get a childObject by name/id or indexGet a child object by IDjsFunction_getResource
(String resourceName) Returns a prototype's resource of a given name.jsFunction_getResources
(String resourceName) Returns an array containing the prototype's resource with a given name.jsFunction_href
(Object action, Object params) Get the URL for this object with the applicationint
jsFunction_indexOf
(Object obj) Check if node is contained in the subnode collection.boolean
jsFunction_invalidate
(Object childId) Invalidate the node itself or a subnodeboolean
Check whether the wrapped Node is persistent.boolean
Check whether the wrapped Node is transient.org.mozilla.javascript.Scriptable
jsFunction_list
(Object startArg, Object lengthArg) Return a JS array of child objects with the given start and length.Makes the HopObject and all its reachable descendants persistent.void
jsFunction_prefetchChildren
(Object startArg, Object lengthArg) Prefetch child objects from (relational) database.boolean
jsFunction_remove
(Object arg) Remove this object from the database.boolean
jsFunction_removeChild
(Object child) Remove a child node from this node's collection without deleting it from the database.boolean
jsFunction_renderSkin
(Object skinobj, Object paramobj) Render a skin to the response buffer.jsFunction_renderSkinAsString
(Object skinobj, Object paramobj) Render a skin and return its output as string.boolean
jsFunction_set
(Object id, Object value) Set a property on this HopObjectint
void
Set a property in this HopObjectvoid
Tell this PropertyRecorder to start recording changes to propertiesvoid
Tell this PropertyRecorder to stop recording changes to propertiestoString()
Return a string representation of this HopObject.unwrap()
Returns the wrapped Node.Methods inherited from class org.mozilla.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, get, get, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, hasInstance, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, size
-
Constructor Details
-
HopObject
Creates a new HopObject prototype.- Parameters:
className
- the prototype namecore
- the RhinoCore
-
HopObject
protected HopObject(String className, RhinoCore core, INode node, org.mozilla.javascript.Scriptable proto) Creates a new HopObject.- Parameters:
className
- the classNamecore
- the RhinoCorenode
- the wrapped nodeproto
- the object's prototype
-
HopObject
protected HopObject(String className, RhinoCore core, NodeHandle handle, org.mozilla.javascript.Scriptable proto) Creates a new HopObject.- Parameters:
className
- the classNamecore
- the RhinoCorehandle
- the handle for the wrapped nodeproto
- the object's prototype
-
-
Method Details
-
init
Initialize HopObject prototype for Rhino scope.- Parameters:
core
- the RhinoCore- Returns:
- the HopObject prototype
-
getClassName
Get the class/prototype name for this HopObject- Specified by:
getClassName
in interfaceorg.mozilla.javascript.Scriptable
- Specified by:
getClassName
in classorg.mozilla.javascript.ScriptableObject
- Returns:
- The object's class or prototype name
-
defineProperty
Overwritten to not define constructor property as constant - we need to have the constructor property resettable in Helma.- Overrides:
defineProperty
in classorg.mozilla.javascript.ScriptableObject
- Parameters:
propertyName
- the property namevalue
- the property valueattributes
- the property attributes
-
getDefaultValue
Return a primitive representation for this object. FIXME: We always return a string representation.- Specified by:
getDefaultValue
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
getDefaultValue
in classorg.mozilla.javascript.ScriptableObject
- Parameters:
hint
- the type hint- Returns:
- the default value for the object
-
getNode
Return the INode wrapped by this HopObject.- Returns:
- the wrapped INode instance
-
unwrap
Returns the wrapped Node. Implements unwrap() in interface Wrapper.- Specified by:
unwrap
in interfaceorg.mozilla.javascript.Wrapper
-
jsGet_cache
- Returns:
- ...
-
jsFunction_renderSkin
public boolean jsFunction_renderSkin(Object skinobj, Object paramobj) throws UnsupportedEncodingException, IOException Render a skin to the response buffer.- Parameters:
skinobj
- The skin object or nameparamobj
- An optional parameter object- Returns:
- ...
- Throws:
UnsupportedEncodingException
IOException
-
jsFunction_getResource
Returns a prototype's resource of a given name. Walks up the prototype's inheritance chain if the resource is not found- Parameters:
resourceName
- the name of the resource, e.g. "type.properties", "messages.properties", "script.js", etc.- Returns:
- the resource, if found, null otherwise
-
jsFunction_getResources
Returns an array containing the prototype's resource with a given name.- Parameters:
resourceName
- the name of the resource, e.g. "type.properties", "messages.properties", "script.js", etc.- Returns:
- an array of resources with the given name
-
jsFunction_renderSkinAsString
public String jsFunction_renderSkinAsString(Object skinobj, Object paramobj) throws UnsupportedEncodingException, IOException Render a skin and return its output as string.- Parameters:
skinobj
- The skin object or nameparamobj
- An optional parameter object- Returns:
- ...
- Throws:
UnsupportedEncodingException
IOException
-
jsFunction_href
public Object jsFunction_href(Object action, Object params) throws UnsupportedEncodingException, IOException Get the URL for this object with the application- Parameters:
action
- optional action nameparams
- optional query parameters- Returns:
- the URL for the object
- Throws:
UnsupportedEncodingException
- if the application's charset property is not a valid encoding nameIOException
-
jsFunction_get
Get a childObject by name/id or index- Parameters:
id
- The name/id or index, depending if the argument is a String or Number.- Returns:
- ...
-
jsFunction_getById
Get a child object by ID- Parameters:
id
- the child id.- Returns:
- ...
-
jsFunction_set
Set a property on this HopObject- Parameters:
id
- The name/id or index, depending if the argument is a String or Number.- Returns:
- ...
-
jsFunction_count
public int jsFunction_count()- Returns:
- ...
-
jsFunction_size
public int jsFunction_size()- Returns:
- ...
-
jsFunction_prefetchChildren
Prefetch child objects from (relational) database. -
jsFunction_clearCache
public void jsFunction_clearCache()Clear the node's cache node. -
jsFunction_list
Return a JS array of child objects with the given start and length.- Returns:
- A JavaScript Array containing the specified child objects
-
jsFunction_add
- Parameters:
child
- ...- Returns:
- ...
-
jsFunction_addAt
- Parameters:
index
- ...child
- ...- Returns:
- ...
-
jsFunction_remove
Remove this object from the database. -
jsFunction_removeChild
Remove a child node from this node's collection without deleting it from the database. -
jsFunction_persist
Makes the HopObject and all its reachable descendants persistent.- Returns:
- the ID of the newly persisted HopObject or null if operation failed
-
jsFunction_invalidate
Invalidate the node itself or a subnode -
jsFunction_isPersistent
public boolean jsFunction_isPersistent()Check whether the wrapped Node is persistent. This also returns true if the Node is being inserted in the database, or it has been in database and is in the proces of being deleted.- Returns:
- true if the the wrapped Node has a valid database id.
-
jsFunction_isTransient
public boolean jsFunction_isTransient()Check whether the wrapped Node is transient. This also returns false if the Node is being inserted in the database, or it has been in database and is in the proces of being deleted.- Returns:
- true if the the wrapped Node is not stored in a database.
-
jsFunction_indexOf
Check if node is contained in the subnode collection. Return its index position if it is, and -1 otherwise. -
jsFunction_contains
Deprecated.use indexOf(Object) instead.Check if node is contained in the subnode collection. Return its index position if it is, and -1 otherwise. -
put
Set a property in this HopObject- Specified by:
put
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
put
in classorg.mozilla.javascript.ScriptableObject
- Parameters:
name
- property namestart
-value
- ...
-
has
Check if a property is set in this HopObject- Specified by:
has
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
has
in classorg.mozilla.javascript.ScriptableObject
- Parameters:
name
- the property namestart
- the object in which the lookup began- Returns:
- true if the property was found
-
delete
- Specified by:
delete
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
delete
in classorg.mozilla.javascript.ScriptableObject
- Parameters:
name
- ...
-
get
- Specified by:
get
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
get
in classorg.mozilla.javascript.ScriptableObject
- Parameters:
name
- ...start
- ...- Returns:
- ...
-
getAllIds
Return all property names of this object. This method is used by debugger.- Specified by:
getAllIds
in interfaceorg.mozilla.javascript.debug.DebuggableObject
- Overrides:
getAllIds
in classorg.mozilla.javascript.ScriptableObject
- Returns:
- array containing the names of all properties defined in this object
-
getIds
Return all "ordinary" property ids of this object. This "hides" the prototype methods.- Specified by:
getIds
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
getIds
in classorg.mozilla.javascript.ScriptableObject
- Returns:
- array containing the names of this object's data properties
-
has
public boolean has(int idx, org.mozilla.javascript.Scriptable start) - Specified by:
has
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
has
in classorg.mozilla.javascript.ScriptableObject
- Parameters:
idx
- ...start
- ...- Returns:
- ...
-
get
- Specified by:
get
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
get
in classorg.mozilla.javascript.ScriptableObject
- Parameters:
idx
- ...start
- ...- Returns:
- ...
-
equivalentValues
Custom == operator. Must returnScriptable.NOT_FOUND
if this object does not have custom equality operator for the given value, Boolean.TRUE if this object is equivalent to value, Boolean.FALSE if this object is not equivalent to value.- Overrides:
equivalentValues
in classorg.mozilla.javascript.ScriptableObject
-
toString
Return a string representation of this HopObject. -
startRecording
public void startRecording()Tell this PropertyRecorder to start recording changes to properties- Specified by:
startRecording
in interfacePropertyRecorder
-
stopRecording
public void stopRecording()Tell this PropertyRecorder to stop recording changes to properties- Specified by:
stopRecording
in interfacePropertyRecorder
-
getChangeSet
Returns a set containing the names of properties changed since the last time startRecording() was called.- Specified by:
getChangeSet
in interfacePropertyRecorder
- Returns:
- a Set containing the names of changed properties
-
clearChangeSet
public void clearChangeSet()Clear the set of changed properties.- Specified by:
clearChangeSet
in interfacePropertyRecorder
-