Class ScriptableResource
java.lang.Object
org.mozilla.javascript.ScriptableObject
org.apache.sling.scripting.javascript.wrapper.ScriptableResource
- All Implemented Interfaces:
Serializable
,SlingWrapper
,org.mozilla.javascript.ConstProperties
,org.mozilla.javascript.debug.DebuggableObject
,org.mozilla.javascript.Scriptable
,org.mozilla.javascript.Wrapper
public class ScriptableResource
extends org.mozilla.javascript.ScriptableObject
implements SlingWrapper
Resource in JavaScript has following signature:
- [String] getName()
- [String] name
- [Object] getResourceMetadata()
- [Object] resourceMetadata
- [String] getPath()
- [String] path
- [String] getResourceType()
- [String] resourceType
- [String] getResourceSuperType()
- [String] resourceSuperType
- [Resource] getParent()
- [Resource] parent
- [ResourceResolver] getResourceResolver()
- [ResourceResolver] resourceResolver
- [Resource] getChild(String)
- [Resource[]] getChildren()
- [Resource[]] listChildren()
- [Boolean] isResourceType(String)
- [Object] properties
- See Also:
-
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
-
Method Summary
Modifier and TypeMethodDescriptionThe name of the JavaScript host object "class".getDefaultValue
(Class typeHint) Class<?>[]
The list of Java classes wrapped by this wrapper.void
jsConstructor
(Object res) static Object
jsFunction_adaptTo
(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable thisObj, Object[] args, org.mozilla.javascript.Function funObj) Implements the adaptTo() method for JavaScript scripts.jsFunction_getChild
(String childPath) Maps getChild(String childPath) to getChild method.org.mozilla.javascript.NativeArray
Deprecated.since 2.1.0 because the method is named incorrectly.boolean
org.mozilla.javascript.NativeArray
Deprecated.since 2.1.0 because it maps the method name incorrectly.Deprecated.since 2.1.0 because it maps the method name incorrectly.void
setResource
(Resource entry) unwrap()
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, get, getAllIds, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, has, has, hasInstance, hasProperty, hasProperty, isConst, isSealed, put, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setParentScope, setPrototype
-
Field Details
-
CLASSNAME
- See Also:
-
-
Constructor Details
-
ScriptableResource
public ScriptableResource() -
ScriptableResource
-
-
Method Details
-
jsConstructor
-
jsGet_name
-
jsFunction_getName
-
jsGet_path
-
jsFunction_getPath
-
jsGet_type
Deprecated.since 2.1.0 because it maps the method name incorrectly.Maps getResourceType() to type property. This property is deprecated since it does not correctly map the getResourceType() method name to a property.- Returns:
- the resource type
-
jsGet_resourceType
-
jsFunction_getResourceType
-
jsFunction_listChildren
public org.mozilla.javascript.NativeArray jsFunction_listChildren() -
jsFunction_getChildren
public org.mozilla.javascript.NativeArray jsFunction_getChildren() -
jsGet_parent
-
jsFunction_getParent
-
jsGet_resourceSuperType
-
jsFunction_getResourceSuperType
-
jsFunction_isResourceType
-
jsGet_meta
Deprecated.since 2.1.0 because it maps the method name incorrectly.Maps getResourceMetadata() to meta property. This property is deprecated since it does not correctly map the getResourceType() method name to a property.- Returns:
- the resource metadata
-
jsGet_resourceMetadata
-
jsFunction_getMetadata
Deprecated.since 2.1.0 because the method is named incorrectly.Maps getResourceMetadata() to getMetadata() method. This method is deprecated since it has the wrong name to support the getResourceMetadata() method.- Returns:
- the resource metadata
-
jsFunction_getResourceMetadata
-
jsFunction_getResourceResolver
-
jsGet_resourceResolver
-
jsFunction_getChild
Maps getChild(String childPath) to getChild method.- Parameters:
childPath
- the child path- Returns:
- the child resource if one exists at
childPath
ornull
-
jsFunction_getObject
-
jsFunction_adaptTo
public static Object jsFunction_adaptTo(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable thisObj, Object[] args, org.mozilla.javascript.Function funObj) Implements the adaptTo() method for JavaScript scripts. This method takes either a java.lang.Class object or a String containing the fully qualified name of the class to adapt to.Supporting String as an argument to this method allows for much easier use in JavaScript since instead of for example writing "javax.jcr.Node" instead of the much clumsier Packages.javax.jcr.Node.
- Parameters:
cx
- The current Rhino contextthisObj
- The ScriptableResource object in which the method is called.args
- The argument vector. Only the first argument is used which is expected to be a Class object or a String. If no argument is supplied or it has the wrong type, this method just returnsnull
.funObj
- The object representing the JavaScript adaptTo function.- Returns:
- The object to which the resource adapts or
null
if the resource does not adapt to the required type or if the argument is of the wrong type or missing.
-
jsGet_properties
-
getClassName
Description copied from interface:SlingWrapper
The name of the JavaScript host object "class".- Specified by:
getClassName
in interfaceorg.mozilla.javascript.Scriptable
- Specified by:
getClassName
in interfaceSlingWrapper
- Specified by:
getClassName
in classorg.mozilla.javascript.ScriptableObject
- Returns:
- the class name
-
getDefaultValue
- Specified by:
getDefaultValue
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
getDefaultValue
in classorg.mozilla.javascript.ScriptableObject
-
setResource
-
getWrappedClasses
Description copied from interface:SlingWrapper
The list of Java classes wrapped by this wrapper.- Specified by:
getWrappedClasses
in interfaceSlingWrapper
- Returns:
- the wrapped classes
-
unwrap
- Specified by:
unwrap
in interfaceorg.mozilla.javascript.Wrapper
-