com.virtualweaver.xotics.datamodel.xpath.function
Class XpfAbstractFunction

java.lang.Object
  extended bycom.virtualweaver.xotics.datamodel.xpath.function.XpfAbstractFunction
All Implemented Interfaces:
XpFunction

public abstract class XpfAbstractFunction
extends java.lang.Object
implements XpFunction

This class is a default base implementation for an XPath function. To create a new XPath function, this class should be derived by implementing one of the two evaluate() methods : generally, evaluate(XpContext, XoDataType[]) method is used, as XpEvaluable arguments have been resolved by a call to XpEvaluable.evaluate(XpContext). However, to have full control on how XpEvaluable arguments are resolved, the other method evaluate(XpContext, XpEvaluable[]) can be rewritten.

Version:
4.1

Field Summary
protected  int column
           
protected  int line
           
 
Constructor Summary
XpfAbstractFunction()
           
 
Method Summary
 XoDataType evaluate(XpContext ectx, XoDataType[] args)
          default implementation consists in implementing this method.
 XoDataType evaluate(XpContext ectx, XpEvaluable[] arguments)
          This method resolves arguments by calling XpEvaluable.evaluate(XpContext), then call evaluate(XpContext, XoDataType[]) with resolved arguments.
abstract  java.lang.String getLocalName()
          Returns the local name of the function
abstract  java.lang.String getNameSpace()
          Returns the namespace of the function
 void setTokenPosition(int line, int col)
          This method is called by XPath engine to give positions of this in XPath request string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

line

protected int line

column

protected int column
Constructor Detail

XpfAbstractFunction

public XpfAbstractFunction()
Method Detail

evaluate

public XoDataType evaluate(XpContext ectx,
                           XpEvaluable[] arguments)
                    throws XoException
This method resolves arguments by calling XpEvaluable.evaluate(XpContext), then call evaluate(XpContext, XoDataType[]) with resolved arguments. So, default implementation consists to let this method unchanged and implement the other method, but this method can be rewritten as needed.

Specified by:
evaluate in interface XpFunction
Parameters:
ectx - dynamic XPath context
arguments - function arguments
Returns:
an XPath compatible object as the result of function performing
Throws:
XoException - if some error occurs.

evaluate

public XoDataType evaluate(XpContext ectx,
                           XoDataType[] args)
                    throws XoException
default implementation consists in implementing this method.

Parameters:
ectx - dynamic XPath context
args - function arguments
Returns:
an XPath compatible object as the result of function performing
Throws:
XoException - if some error occurs.

getLocalName

public abstract java.lang.String getLocalName()
Description copied from interface: XpFunction
Returns the local name of the function

Specified by:
getLocalName in interface XpFunction
See Also:
XpFunction.getLocalName()

getNameSpace

public abstract java.lang.String getNameSpace()
Description copied from interface: XpFunction
Returns the namespace of the function

Specified by:
getNameSpace in interface XpFunction
See Also:
XpFunction.getNameSpace()

setTokenPosition

public void setTokenPosition(int line,
                             int col)
Description copied from interface: XpFunction
This method is called by XPath engine to give positions of this in XPath request string.

Specified by:
setTokenPosition in interface XpFunction
Parameters:
line - line position of this function in XPath request
col - column position of this function in XPath request
See Also:
XpFunction.setTokenPosition(int, int)