com.novell.xsl.extensions
Class ECMAScriptFunction

java.lang.Object
  extended bycom.novell.xml.xpath.Function
      extended bycom.novell.xsl.extensions.ECMAScriptFunction
Direct Known Subclasses:
ECMAScriptFunctionImpl

public class ECMAScriptFunction
extends Function

This class represents a java class member with a particular name. This class is only used during the parsing stage. The getInstance() member returns the actual JavaMethodInstance object that is used by the FunctionCall object. It is abstract to add a level of separation from the underlying Rhino engine in case it isn't there so we can check for the existence and not throw ClassNotFound exceptions


Field Summary
protected static Class defaultParameterType
           
protected static Class defaultReturnType
           
static String ECMASCRIPT_EXTENSION_FUNCTION_NAMESPACE
          The start of the URI used to signify extension functions and non-built in extension elements: "http://www.novell.com/nxsl/ecmascript"
static String ECMASCRIPT_SCOPE_PROPERTY
          The name of the property in the ExpressionContext that holds the ECMAScript execution environment
protected static Class[] optArgs
           
protected static AttrDef[] scriptAttr
           
 
Constructor Summary
protected ECMAScriptFunction(FunctionSignature signature)
          Construct a placeholder for the function library for the desired java class member(s).
 
Method Summary
 boolean available(ExpressionContext eContext)
          Checks whether or not the function that this object represents actual has an implementation This gets overridden by ECMAScriptFunctionImpl when Rhino is available.
static ECMAScriptFunction create(ExpandedQName name, ClassLoader classLoader)
          factory method
static Object evaluateCommandLineScripts(List scripts, ClassLoader classLoader)
          Evaluate scripts passed in on the command line
 ExpressionValue invoke(Object[] args)
          Invoke the function using the passed list of arguments.
static boolean isECMAScriptAvailable()
          find out if ECMAScript interpreter is available
static void parse(StylesheetParser stylesheetParser, Element element, URL baseURI, ClassLoader classLoader)
          Parses the specified ecmascript:script element and returns the result as a ECMAScriptParser object.
 
Methods inherited from class com.novell.xml.xpath.Function
getInstance, getSignature, isConstant, registerForReset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ECMASCRIPT_EXTENSION_FUNCTION_NAMESPACE

public static final String ECMASCRIPT_EXTENSION_FUNCTION_NAMESPACE
The start of the URI used to signify extension functions and non-built in extension elements: "http://www.novell.com/nxsl/ecmascript"

See Also:
Constant Field Values

ECMASCRIPT_SCOPE_PROPERTY

public static final String ECMASCRIPT_SCOPE_PROPERTY
The name of the property in the ExpressionContext that holds the ECMAScript execution environment

See Also:
Constant Field Values

defaultParameterType

protected static final Class defaultParameterType

defaultReturnType

protected static final Class defaultReturnType

optArgs

protected static final Class[] optArgs

scriptAttr

protected static final AttrDef[] scriptAttr
Constructor Detail

ECMAScriptFunction

protected ECMAScriptFunction(FunctionSignature signature)
Construct a placeholder for the function library for the desired java class member(s).

Parameters:
signature - The function signature
Method Detail

create

public static ECMAScriptFunction create(ExpandedQName name,
                                        ClassLoader classLoader)
factory method

Parameters:
name - name of the function
classLoader - class loader to use (null for default)
Returns:
ECMAScriptFunctionImpl if Rhino is available, a stub otherwise

invoke

public ExpressionValue invoke(Object[] args)
                       throws XPathEvaluationException
Invoke the function using the passed list of arguments. This gets overridden by ECMAScriptFunctionImpl when Rhino is available.

Overrides:
invoke in class Function
Parameters:
args - List of arguments.
Returns:
An object containing the result of the function invocation.
Throws:
XPathEvaluationException

available

public boolean available(ExpressionContext eContext)
Checks whether or not the function that this object represents actual has an implementation This gets overridden by ECMAScriptFunctionImpl when Rhino is available.

Parameters:
eContext - the ExpressionContext to get the scope from or put the new scope into
Returns:
true if the function has an implementation

parse

public static void parse(StylesheetParser stylesheetParser,
                         Element element,
                         URL baseURI,
                         ClassLoader classLoader)
                  throws XSLTParserException
Parses the specified ecmascript:script element and returns the result as a ECMAScriptParser object.

Parameters:
stylesheetParser - The StylesheetParser for which the element is to be parsed.
element - the element to be parsed
classLoader - class loader to use (null for default)
Throws:
XSLTParserException - if a fatal error occurs during parsing

evaluateCommandLineScripts

public static Object evaluateCommandLineScripts(List scripts,
                                                ClassLoader classLoader)
                                         throws XSLException,
                                                IOException
Evaluate scripts passed in on the command line

Parameters:
scripts - a list of Strings containing URI of scripts to evaluate
classLoader - class loader to use (null for default)
Returns:
A scope object containing the objects created by the script
Throws:
XSLException
IOException

isECMAScriptAvailable

public static boolean isECMAScriptAvailable()
find out if ECMAScript interpreter is available

Returns:
true if available