org.inria.ns.reflex.processor.xcl
Class GroupFunction

java.lang.Object
  extended by org.inria.ns.reflex.xml.xpath.XPathFunction.NamedXPathFunction
      extended by org.inria.ns.reflex.processor.xcl.GroupFunction
All Implemented Interfaces:
DeferrableFunction, XPathFunction

public class GroupFunction
extends XPathFunction.NamedXPathFunction
implements XPathFunction, DeferrableFunction

The xcl:group() function group items of a #adt:list regarding one or more grouping criteria.

The result is a #adt:list of #adt:list. Each inner list contains all the items of the same group. All inner lists are items of the outer list. While the outer list is browsed, the current object is set to the first item of the inner list.

Items of the outer list and the inner list are built dynamically while browsing the list to group. The outer list doesn't intend to be browsed entirely ignoring the items of the inner list. If inner groups are not browsed, a new outer group item is considered with the remainder. Because the outer list doesn't read in advance items of the list to group (it can't predict if the next item is in the same group or not).

*** This list must be read forward ; once completed, this list must not be read again. ***

Author:
Philippe Poulard

Nested Class Summary
static class GroupFunction.OuterList
          A list used for grouping items according to some criteria.
 
Nested classes/interfaces inherited from interface org.inria.ns.reflex.xml.xpath.XPathFunction
XPathFunction.NamedXPathFunction
 
Constructor Summary
GroupFunction()
           
 
Method Summary
 Object evaluate(XPathContext context, List args)
          Groups item of a list.
 boolean isDeferred(int argument)
          The first argument is not deferred (evaluated to the stuff to group), others are deferred (evaluated for each item of the stuff to group).
 
Methods inherited from class org.inria.ns.reflex.xml.xpath.XPathFunction.NamedXPathFunction
getQName, setQName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.inria.ns.reflex.xml.xpath.XPathFunction
getQName
 

Constructor Detail

GroupFunction

public GroupFunction()
Method Detail

evaluate

public Object evaluate(XPathContext context,
                       List args)
                throws XPathFunctionException
Groups item of a list.

Specified by:
evaluate in interface XPathFunction
Parameters:
context - The context when evaluating this function : XPath variables, current node, etc.
args - The arguments of this function :
  • the first is the list of items to group,
  • the others are the grouping criteria.
Returns:
A list of list.
Throws:
XPathFunctionException - When this function fails to be evaluated.
See Also:
XPathFunction.evaluate(org.inria.ns.reflex.xml.xpath.XPathContext, java.util.List)

isDeferred

public boolean isDeferred(int argument)
The first argument is not deferred (evaluated to the stuff to group), others are deferred (evaluated for each item of the stuff to group).

Specified by:
isDeferred in interface DeferrableFunction
Parameters:
argument - The index of the argument.
Returns:
false if argument=0, true otherwise.
See Also:
DeferrableFunction.isDeferred(int)