org.jaxen

Class SimpleFunctionContext

Implemented Interfaces:
FunctionContext
Known Direct Subclasses:
XPathFunctionContext

public class SimpleFunctionContext
extends java.lang.Object
implements FunctionContext

Simple default implementation of FunctionContext.

This is a simple table-based key-lookup implementation for FunctionContext which can be programmatically extended by registering additional functions.

Author:
bob mcwhirter
See Also:
XPathFunctionContext

Field Summary

private HashMap
functions
Table of functions.

Constructor Summary

SimpleFunctionContext()
Construct an empty function context.

Method Summary

Function
getFunction(String namespaceURI, String prefix, String localName)
void
registerFunction(String namespaceURI, String localName, Function function)
Register a new function.

Field Details

functions

private HashMap functions
Table of functions.

Constructor Details

SimpleFunctionContext

public SimpleFunctionContext()
Construct an empty function context.

Method Details

getFunction

public Function getFunction(String namespaceURI,
                            String prefix,
                            String localName)
            throws UnresolvableException
Specified by:
getFunction in interface FunctionContext

registerFunction

public void registerFunction(String namespaceURI,
                             String localName,
                             Function function)
Register a new function.

By registering a new function, any XPath expression that utilizes this FunctionContext may 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 this FunctionContext functions are only referenced using the URI, not the prefix.

The namespace URI of a function may be null to indicate that it exists without a namespace.

Parameters:
namespaceURI - the namespace URI of the function to be registered with this context
localName - the non-prefixed local portion of the function to be registered with this context
function - a Function implementation object to be used when evaluating the function