Class SimpleFunctionContext
- java.lang.Object
-
- org.jaxen.SimpleFunctionContext
-
- All Implemented Interfaces:
FunctionContext
- Direct Known Subclasses:
XPathFunctionContext
public class SimpleFunctionContext extends java.lang.Object implements FunctionContext
Simple default implementation ofFunctionContext.This is a simple table-based key-lookup implementation for
FunctionContextwhich can be programmatically extended by registering additional functions.- Author:
- bob mcwhirter
- See Also:
XPathFunctionContext
-
-
Constructor Summary
Constructors Constructor Description SimpleFunctionContext()Construct an empty function context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FunctiongetFunction(java.lang.String namespaceURI, java.lang.String prefix, java.lang.String localName)An implementation should return aFunctionimplementation object based on the namespace URI and local name of the function-call expression.voidregisterFunction(java.lang.String namespaceURI, java.lang.String localName, Function function)Register a new function.
-
-
-
Method Detail
-
registerFunction
public void registerFunction(java.lang.String namespaceURI, java.lang.String localName, Function function)Register a new function.By registering a new function, any XPath expression that utilizes this
FunctionContextmay refer to and use the new function.Functions may exist either in a namespace or not. Namespace prefix-to-URI resolution is the responsibility of a
NamespaceContext. Within thisFunctionContextfunctions are only referenced using the URI, not the prefix.The namespace URI of a function may be
nullto indicate that it exists without a namespace.- Parameters:
namespaceURI- the namespace URI of the function to be registered with this contextlocalName- the non-prefixed local portion of the function to be registered with this contextfunction- aFunctionimplementation object to be used when evaluating the function
-
getFunction
public Function getFunction(java.lang.String namespaceURI, java.lang.String prefix, java.lang.String localName) throws UnresolvableException
Description copied from interface:FunctionContextAn implementation should return aFunctionimplementation object based on the namespace URI and local name of the function-call expression.It must not use the prefix parameter to select an implementation, because a prefix could be bound to any namespace; the prefix parameter could be used in debugging output or other generated information. The prefix may otherwise be completely ignored.
- Specified by:
getFunctionin interfaceFunctionContext- Parameters:
namespaceURI- the namespace URI to which the prefix parameter is bound in the XPath expression. If the function call expression had no prefix, the namespace URI isnull.prefix- the prefix that was used in the function call expressionlocalName- the local name of the function-call expression. If there is no prefix, then this is the whole name of the function.- Returns:
- a Function implementation object.
- Throws:
UnresolvableException- when the function cannot be resolved
-
-