com.ail.core
Class TypeXPathFunctionRegister

java.lang.Object
  extended by com.ail.core.TypeXPathFunctionRegister

public final class TypeXPathFunctionRegister
extends java.lang.Object

This class acts as a singleton defining all the JXPath function libraries available to the system and accessed via the Type class' xpath methods (e.g. xpathGet).

The library is initially create based on the list of function classes defined in the core config's 'JXPathExtensions' group. This group has 0..* Parameters whose names and values are taken to be the namesapces and the function classes to be associated with them.


Method Summary
 org.apache.commons.jxpath.FunctionLibrary getFunctionLibrary()
          Return the currently defined function library.
static TypeXPathFunctionRegister getInstance()
           
 void registerFunctionLibrary(java.lang.String namespace, java.lang.Class clazz)
          Register a new xpath function class.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static TypeXPathFunctionRegister getInstance()

registerFunctionLibrary

public void registerFunctionLibrary(java.lang.String namespace,
                                    java.lang.Class clazz)
Register a new xpath function class. JXPath provides for functions to be executed from xpath expressions - effectively bridging the gap between xpath and java. Functions are referenced from with xpath expressions as follows:

  <namespace>:<method name>(<arg1>, ...)

You can register as many function classes as you like as long as each has a unique namespace. An attempt to add a function class using a namespace which is already in use will fail silently. The library of function classes available to JXPath is shared between all instances of Type so care must be taken to keep namespaces unique.

It is anticipated that the use of this method will be pretty minimal. The Core configuration allows for a set of default functions to be loaded automatically using the JXPathExtensions configuration group.

Parameters:
functionClass - Class containing functions to be added.
namespace - Namespace to register the class as.

getFunctionLibrary

public org.apache.commons.jxpath.FunctionLibrary getFunctionLibrary()
Return the currently defined function library.

Returns:
FunctionLibrary.