org.apache.sling.scripting.javascript.wrapper
Class ScriptableNode

java.lang.Object
  extended by org.mozilla.javascript.ScriptableObject
      extended by org.apache.sling.scripting.javascript.wrapper.ScriptableBase
          extended by org.apache.sling.scripting.javascript.wrapper.ScriptableNode
All Implemented Interfaces:
java.io.Serializable, SlingWrapper, org.mozilla.javascript.ConstProperties, org.mozilla.javascript.debug.DebuggableObject, org.mozilla.javascript.Scriptable, org.mozilla.javascript.Wrapper
Direct Known Subclasses:
ScriptableVersion, ScriptableVersionHistory

public class ScriptableNode
extends ScriptableBase
implements SlingWrapper

A wrapper for JCR nodes that exposes all properties and child nodes as properties of a Javascript object.

See Also:
Serialized Form

Field Summary
static java.lang.String CLASSNAME
           
static java.lang.Class<?>[] WRAPPED_CLASSES
           
 
Fields inherited from class org.apache.sling.scripting.javascript.wrapper.ScriptableBase
JSFUNC_PREFIX
 
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
ScriptableNode()
           
 
Method Summary
 java.lang.Object get(java.lang.String name, org.mozilla.javascript.Scriptable start)
          Gets the value of a (Javascript) property or child node.
 java.lang.String getClassName()
          The name of the JavaScript host object "class"
 java.lang.Object getDefaultValue(java.lang.Class typeHint)
           
 java.lang.Object[] getIds()
           
protected  java.lang.Class<?> getStaticType()
           
 java.lang.Class<?>[] getWrappedClasses()
          The list of Java classes wrapped by this wrapper
protected  java.lang.Object getWrappedObject()
           
 boolean has(java.lang.String name, org.mozilla.javascript.Scriptable start)
           
 void jsConstructor(java.lang.Object res)
           
 java.lang.Object jsFunction_addNode(java.lang.String path, java.lang.String primaryType)
           
 java.lang.Object jsFunction_getBaseVersion()
           
 boolean jsFunction_getCheckedOut()
           
 java.lang.Object jsFunction_getChildren()
           
 java.lang.Object jsFunction_getDefinition()
           
 int jsFunction_getDepth()
           
 int jsFunction_getIndex()
           
 java.lang.Object jsFunction_getLock()
           
 boolean jsFunction_getLocked()
           
 javax.jcr.nodetype.NodeType[] jsFunction_getMixinNodeTypes()
           
 boolean jsFunction_getModified()
           
 java.lang.String jsFunction_getName()
           
 boolean jsFunction_getNew()
           
 java.lang.Object jsFunction_getNode(java.lang.String path)
           
 java.lang.Object jsFunction_getNodes(java.lang.String namePattern)
           
 java.lang.Object jsFunction_getParent()
           
 java.lang.String jsFunction_getPath()
           
 java.lang.Object jsFunction_getPrimaryItem()
           
 java.lang.Object jsFunction_getPrimaryNodeType()
           
 java.lang.Object jsFunction_getProperties()
           
 java.lang.Object jsFunction_getProperty(java.lang.String name)
           
 java.util.Iterator<?> jsFunction_getReferences()
           
 java.lang.Object jsFunction_getSession()
           
 java.lang.String jsFunction_getUUID()
           
 java.lang.Object jsFunction_getVersionHistory()
           
 boolean jsFunction_hasNode(java.lang.String path)
           
 void jsFunction_remove()
           
 java.lang.Class<?> jsGet_javascriptWrapperClass()
          Used in testing, to check that the right wrapper is used.
 java.lang.String toString()
           
 java.lang.Object unwrap()
           
 
Methods inherited from class org.apache.sling.scripting.javascript.wrapper.ScriptableBase
getNative
 
Methods inherited from class org.mozilla.javascript.ScriptableObject
associateValue, callMethod, callMethod, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, equivalentValues, get, getAllIds, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getObjectPrototype, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, has, hasInstance, hasProperty, hasProperty, isConst, isSealed, put, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setParentScope, setPrototype
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASSNAME

public static final java.lang.String CLASSNAME
See Also:
Constant Field Values

WRAPPED_CLASSES

public static final java.lang.Class<?>[] WRAPPED_CLASSES
Constructor Detail

ScriptableNode

public ScriptableNode()
Method Detail

jsConstructor

public void jsConstructor(java.lang.Object res)

getClassName

public java.lang.String getClassName()
Description copied from interface: SlingWrapper
The name of the JavaScript host object "class"

Specified by:
getClassName in interface SlingWrapper
Specified by:
getClassName in interface org.mozilla.javascript.Scriptable
Specified by:
getClassName in class org.mozilla.javascript.ScriptableObject

getWrappedClasses

public java.lang.Class<?>[] getWrappedClasses()
Description copied from interface: SlingWrapper
The list of Java classes wrapped by this wrapper

Specified by:
getWrappedClasses in interface SlingWrapper

getStaticType

protected java.lang.Class<?> getStaticType()
Specified by:
getStaticType in class ScriptableBase
Returns:
the static type to use for NativeJavaObject wrapping

getWrappedObject

protected java.lang.Object getWrappedObject()
Specified by:
getWrappedObject in class ScriptableBase
Returns:
the Java object that we're wrapping, used to create a NativeJavaObject instance for default wrapping.

jsFunction_addNode

public java.lang.Object jsFunction_addNode(java.lang.String path,
                                           java.lang.String primaryType)
                                    throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

jsFunction_getNode

public java.lang.Object jsFunction_getNode(java.lang.String path)
                                    throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

jsFunction_getChildren

public java.lang.Object jsFunction_getChildren()

jsFunction_getNodes

public java.lang.Object jsFunction_getNodes(java.lang.String namePattern)

jsFunction_getProperties

public java.lang.Object jsFunction_getProperties()

jsFunction_getPrimaryItem

public java.lang.Object jsFunction_getPrimaryItem()

jsFunction_getProperty

public java.lang.Object jsFunction_getProperty(java.lang.String name)
                                        throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

jsFunction_getUUID

public java.lang.String jsFunction_getUUID()

jsFunction_getIndex

public int jsFunction_getIndex()

jsFunction_getReferences

public java.util.Iterator<?> jsFunction_getReferences()

jsFunction_getPrimaryNodeType

public java.lang.Object jsFunction_getPrimaryNodeType()

jsFunction_getMixinNodeTypes

public javax.jcr.nodetype.NodeType[] jsFunction_getMixinNodeTypes()

jsFunction_getDefinition

public java.lang.Object jsFunction_getDefinition()

jsFunction_getCheckedOut

public boolean jsFunction_getCheckedOut()

jsFunction_getVersionHistory

public java.lang.Object jsFunction_getVersionHistory()

jsFunction_getBaseVersion

public java.lang.Object jsFunction_getBaseVersion()

jsFunction_getLock

public java.lang.Object jsFunction_getLock()

jsFunction_getLocked

public boolean jsFunction_getLocked()

jsFunction_getSession

public java.lang.Object jsFunction_getSession()

jsFunction_getPath

public java.lang.String jsFunction_getPath()

jsFunction_getName

public java.lang.String jsFunction_getName()

jsFunction_getParent

public java.lang.Object jsFunction_getParent()

jsFunction_getDepth

public int jsFunction_getDepth()

jsFunction_getNew

public boolean jsFunction_getNew()

jsFunction_getModified

public boolean jsFunction_getModified()

jsFunction_remove

public void jsFunction_remove()
                       throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

jsFunction_hasNode

public boolean jsFunction_hasNode(java.lang.String path)
                           throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

get

public java.lang.Object get(java.lang.String name,
                            org.mozilla.javascript.Scriptable start)
Gets the value of a (Javascript) property or child node. If there is a single single-value JCR property of this node, return its string value. If there are multiple properties of the same name or child nodes of the same name, return an array.

Specified by:
get in interface org.mozilla.javascript.Scriptable
Overrides:
get in class org.mozilla.javascript.ScriptableObject

getIds

public java.lang.Object[] getIds()
Specified by:
getIds in interface org.mozilla.javascript.Scriptable
Overrides:
getIds in class org.mozilla.javascript.ScriptableObject

getDefaultValue

public java.lang.Object getDefaultValue(java.lang.Class typeHint)
Specified by:
getDefaultValue in interface org.mozilla.javascript.Scriptable
Overrides:
getDefaultValue in class org.mozilla.javascript.ScriptableObject

has

public boolean has(java.lang.String name,
                   org.mozilla.javascript.Scriptable start)
Specified by:
has in interface org.mozilla.javascript.Scriptable
Overrides:
has in class org.mozilla.javascript.ScriptableObject

jsGet_javascriptWrapperClass

public java.lang.Class<?> jsGet_javascriptWrapperClass()
Description copied from class: ScriptableBase
Used in testing, to check that the right wrapper is used. For some reason, defining the method here didn't work, it had to be defined in all descendant classes.

Specified by:
jsGet_javascriptWrapperClass in class ScriptableBase

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

unwrap

public java.lang.Object unwrap()
Specified by:
unwrap in interface org.mozilla.javascript.Wrapper


Copyright © 2007-2009. All Rights Reserved.