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:
- Serialized Form
-
-
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 StringgetClassName()The name of the JavaScript host object "class".ObjectgetDefaultValue(Class typeHint)Class<?>[]getWrappedClasses()The list of Java classes wrapped by this wrapper.voidjsConstructor(Object res)static ObjectjsFunction_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.ObjectjsFunction_getChild(String childPath)Maps getChild(String childPath) to getChild method.org.mozilla.javascript.NativeArrayjsFunction_getChildren()ObjectjsFunction_getMetadata()Deprecated.since 2.1.0 because the method is named incorrectly.StringjsFunction_getName()ObjectjsFunction_getObject()ObjectjsFunction_getParent()StringjsFunction_getPath()ObjectjsFunction_getResourceMetadata()ObjectjsFunction_getResourceResolver()StringjsFunction_getResourceSuperType()StringjsFunction_getResourceType()booleanjsFunction_isResourceType(String type)org.mozilla.javascript.NativeArrayjsFunction_listChildren()ObjectjsGet_meta()Deprecated.since 2.1.0 because it maps the method name incorrectly.StringjsGet_name()ObjectjsGet_parent()StringjsGet_path()ObjectjsGet_properties()ObjectjsGet_resourceMetadata()ObjectjsGet_resourceResolver()StringjsGet_resourceSuperType()StringjsGet_resourceType()StringjsGet_type()Deprecated.since 2.1.0 because it maps the method name incorrectly.voidsetResource(org.apache.sling.api.resource.Resource entry)Objectunwrap()-
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 String CLASSNAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
jsConstructor
public void jsConstructor(Object res)
-
jsGet_name
public String jsGet_name()
-
jsFunction_getName
public String jsFunction_getName()
-
jsGet_path
public String jsGet_path()
-
jsFunction_getPath
public String jsFunction_getPath()
-
jsGet_type
@Deprecated public 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 String jsGet_resourceType()
-
jsFunction_getResourceType
public String jsFunction_getResourceType()
-
jsFunction_listChildren
public org.mozilla.javascript.NativeArray jsFunction_listChildren()
-
jsFunction_getChildren
public org.mozilla.javascript.NativeArray jsFunction_getChildren()
-
jsGet_parent
public Object jsGet_parent()
-
jsFunction_getParent
public Object jsFunction_getParent()
-
jsGet_resourceSuperType
public String jsGet_resourceSuperType()
-
jsFunction_getResourceSuperType
public String jsFunction_getResourceSuperType()
-
jsFunction_isResourceType
public boolean jsFunction_isResourceType(String type)
-
jsGet_meta
@Deprecated public 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 Object jsGet_resourceMetadata()
-
jsFunction_getMetadata
@Deprecated public 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 Object jsFunction_getResourceMetadata()
-
jsFunction_getResourceResolver
public Object jsFunction_getResourceResolver()
-
jsGet_resourceResolver
public Object jsGet_resourceResolver()
-
jsFunction_getChild
public Object jsFunction_getChild(String childPath)
Maps getChild(String childPath) to getChild method.- Parameters:
childPath- the child path- Returns:
- the child resource if one exists at
childPathornull
-
jsFunction_getObject
public Object 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
nullif the resource does not adapt to the required type or if the argument is of the wrong type or missing.
-
jsGet_properties
public Object jsGet_properties()
-
getClassName
public String getClassName()
Description copied from interface:SlingWrapperThe name of the JavaScript host object "class".- Specified by:
getClassNamein interfaceorg.mozilla.javascript.Scriptable- Specified by:
getClassNamein interfaceSlingWrapper- Specified by:
getClassNamein classorg.mozilla.javascript.ScriptableObject- Returns:
- the class name
-
getDefaultValue
public Object getDefaultValue(Class typeHint)
- Specified by:
getDefaultValuein interfaceorg.mozilla.javascript.Scriptable- Overrides:
getDefaultValuein classorg.mozilla.javascript.ScriptableObject
-
setResource
public void setResource(org.apache.sling.api.resource.Resource entry)
-
getWrappedClasses
public Class<?>[] getWrappedClasses()
Description copied from interface:SlingWrapperThe list of Java classes wrapped by this wrapper.- Specified by:
getWrappedClassesin interfaceSlingWrapper- Returns:
- the wrapped classes
-
unwrap
public Object unwrap()
- Specified by:
unwrapin interfaceorg.mozilla.javascript.Wrapper
-
-