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

java.lang.Object
  extended by org.mozilla.javascript.ScriptableObject
      extended by 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: [Object] getData(); [Object] data [Item] getItem(); [Item] item [String] getResourceType(); [String] type [String] getPath(); [String] path

See Also:
Serialized Form

Field Summary
static java.lang.String CLASSNAME
           
static java.lang.Class<?>[] WRAPPED_CLASSES
           
 
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
ScriptableResource()
           
ScriptableResource(Resource resource)
           
 
Method Summary
 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_getMetadata()
          Deprecated. since 2.1.0 because the method is named incorrectly.
 java.lang.Object jsFunction_getObject()
          Helper method to easily retrieve the default adapted object of the resource.
 java.lang.String jsFunction_getPath()
          Mapps getPath() method as getPath() method.
 java.lang.Object jsFunction_getResourceMetadata()
          Maps getResourceMetadata() to getResourceMetadata method.
 java.lang.Object jsFunction_getResourceResolver()
          Maps getResourceResolver() to resourceResolver property.
 java.lang.String jsFunction_getResourceSuperType()
          Maps getResourceSuperType() to the getResourceSuperType() method.
 java.lang.String jsFunction_getResourceType()
          Maps getResourceType() to the getResourceType() method.
 java.lang.Object jsGet_meta()
          Deprecated. since 2.1.0 because it maps the method name incorrectly.
 java.lang.String jsGet_path()
          Mapps getPath() method as path property.
 java.lang.Object jsGet_resourceMetadata()
          Maps getResourceMetadata() to resourceMetadata property.
 java.lang.Object jsGet_resourceResolver()
          Maps getResourceResolver() to getResourceResolver method.
 java.lang.String jsGet_resourceSuperType()
          Maps getResourceSuperType() to resourceSuperType property.
 java.lang.String jsGet_resourceType()
          Maps getResourceType() to resourceType property.
 java.lang.String jsGet_type()
          Deprecated. since 2.1.0 because it maps the method name incorrectly.
 void setResource(Resource entry)
           
 java.lang.Object 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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

ScriptableResource

public ScriptableResource()

ScriptableResource

public ScriptableResource(Resource resource)
Method Detail

jsConstructor

public void jsConstructor(java.lang.Object res)

jsGet_path

public java.lang.String jsGet_path()
Mapps getPath() method as path property.


jsFunction_getPath

public java.lang.String jsFunction_getPath()
Mapps getPath() method as getPath() method.


jsGet_type

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.


jsGet_resourceType

public java.lang.String jsGet_resourceType()
Maps getResourceType() to resourceType property.


jsFunction_getResourceType

public java.lang.String jsFunction_getResourceType()
Maps getResourceType() to the getResourceType() method.


jsGet_resourceSuperType

public java.lang.String jsGet_resourceSuperType()
Maps getResourceSuperType() to resourceSuperType property.


jsFunction_getResourceSuperType

public java.lang.String jsFunction_getResourceSuperType()
Maps getResourceSuperType() to the getResourceSuperType() method.


jsGet_meta

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.


jsGet_resourceMetadata

public java.lang.Object jsGet_resourceMetadata()
Maps getResourceMetadata() to resourceMetadata property.


jsFunction_getMetadata

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.


jsFunction_getResourceMetadata

public java.lang.Object jsFunction_getResourceMetadata()
Maps getResourceMetadata() to getResourceMetadata method.


jsFunction_getResourceResolver

public java.lang.Object jsFunction_getResourceResolver()
Maps getResourceResolver() to resourceResolver property.


jsGet_resourceResolver

public java.lang.Object jsGet_resourceResolver()
Maps getResourceResolver() to getResourceResolver method.


jsFunction_getObject

public java.lang.Object jsFunction_getObject()
Helper method to easily retrieve the default adapted object of the resource. In case of Object Content Mapping support, this method will return the correctly mapped content object for this resource.

Calling this method is equivalent to calling the adaptTo method with the argument "java.lang.Object".


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 context
thisObj - 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 returns null.
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.

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

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

setResource

public void setResource(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 interface SlingWrapper

unwrap

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


Copyright © 2007-2009. All Rights Reserved.