Class ScriptableResource
- java.lang.Object
-
- org.mozilla.javascript.ScriptableObject
-
- org.apache.sling.scripting.javascript.wrapper.ScriptableResource
-
- All Implemented Interfaces:
java.io.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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CLASSNAME
-
Constructor Summary
Constructors Constructor Description ScriptableResource()
ScriptableResource(org.apache.sling.api.resource.Resource resource)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.String
getClassName()
The name of the JavaScript host object "class".java.lang.Object
getDefaultValue(java.lang.Class typeHint)
java.lang.Class<?>[]
getWrappedClasses()
The list of Java classes wrapped by this wrapper.void
jsConstructor(java.lang.Object res)
static java.lang.Object
jsFunction_adaptTo(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable thisObj, java.lang.Object[] args, org.mozilla.javascript.Function funObj)
Implements the adaptTo() method for JavaScript scripts.java.lang.Object
jsFunction_getChild(java.lang.String childPath)
Maps getChild(String childPath) to getChild method.org.mozilla.javascript.NativeArray
jsFunction_getChildren()
java.lang.Object
jsFunction_getMetadata()
Deprecated.since 2.1.0 because the method is named incorrectly.java.lang.String
jsFunction_getName()
java.lang.Object
jsFunction_getObject()
java.lang.Object
jsFunction_getParent()
java.lang.String
jsFunction_getPath()
java.lang.Object
jsFunction_getResourceMetadata()
java.lang.Object
jsFunction_getResourceResolver()
java.lang.String
jsFunction_getResourceSuperType()
java.lang.String
jsFunction_getResourceType()
boolean
jsFunction_isResourceType(java.lang.String type)
org.mozilla.javascript.NativeArray
jsFunction_listChildren()
java.lang.Object
jsGet_meta()
Deprecated.since 2.1.0 because it maps the method name incorrectly.java.lang.String
jsGet_name()
java.lang.Object
jsGet_parent()
java.lang.String
jsGet_path()
java.lang.Object
jsGet_properties()
java.lang.Object
jsGet_resourceMetadata()
java.lang.Object
jsGet_resourceResolver()
java.lang.String
jsGet_resourceSuperType()
java.lang.String
jsGet_resourceType()
java.lang.String
jsGet_type()
Deprecated.since 2.1.0 because it maps the method name incorrectly.void
setResource(org.apache.sling.api.resource.Resource entry)
java.lang.Object
unwrap()
-
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, equivalentValues, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasInstance, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, size
-
-
-
-
Field Detail
-
CLASSNAME
public static final java.lang.String CLASSNAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
jsConstructor
public void jsConstructor(java.lang.Object res)
-
jsGet_name
public java.lang.String jsGet_name()
-
jsFunction_getName
public java.lang.String jsFunction_getName()
-
jsGet_path
public java.lang.String jsGet_path()
-
jsFunction_getPath
public java.lang.String jsFunction_getPath()
-
jsGet_type
@Deprecated public java.lang.String 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
public java.lang.String jsGet_resourceType()
-
jsFunction_getResourceType
public java.lang.String jsFunction_getResourceType()
-
jsFunction_listChildren
public org.mozilla.javascript.NativeArray jsFunction_listChildren()
-
jsFunction_getChildren
public org.mozilla.javascript.NativeArray jsFunction_getChildren()
-
jsGet_parent
public java.lang.Object jsGet_parent()
-
jsFunction_getParent
public java.lang.Object jsFunction_getParent()
-
jsGet_resourceSuperType
public java.lang.String jsGet_resourceSuperType()
-
jsFunction_getResourceSuperType
public java.lang.String jsFunction_getResourceSuperType()
-
jsFunction_isResourceType
public boolean jsFunction_isResourceType(java.lang.String type)
-
jsGet_meta
@Deprecated public java.lang.Object 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
public java.lang.Object jsGet_resourceMetadata()
-
jsFunction_getMetadata
@Deprecated public java.lang.Object 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
public java.lang.Object jsFunction_getResourceMetadata()
-
jsFunction_getResourceResolver
public java.lang.Object jsFunction_getResourceResolver()
-
jsGet_resourceResolver
public java.lang.Object jsGet_resourceResolver()
-
jsFunction_getChild
public java.lang.Object jsFunction_getChild(java.lang.String childPath)
Maps getChild(String childPath) to getChild method.- Parameters:
childPath
- the child path- Returns:
- the child resource if one exists at
childPath
ornull
-
jsFunction_getObject
public java.lang.Object jsFunction_getObject()
-
jsFunction_adaptTo
public static java.lang.Object jsFunction_adaptTo(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable thisObj, java.lang.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
public java.lang.Object jsGet_properties()
-
getClassName
public java.lang.String 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
public java.lang.Object getDefaultValue(java.lang.Class typeHint)
- Specified by:
getDefaultValue
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
getDefaultValue
in classorg.mozilla.javascript.ScriptableObject
-
setResource
public void setResource(org.apache.sling.api.resource.Resource entry)
-
getWrappedClasses
public java.lang.Class<?>[] 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
public java.lang.Object unwrap()
- Specified by:
unwrap
in interfaceorg.mozilla.javascript.Wrapper
-
-