xxl.functions
Class Function

java.lang.Object
  |
  +--xxl.functions.Function
Direct Known Subclasses:
Constant, Projection

public class Function
extends java.lang.Object

A Function can be used to pass a Function-parameter to a method.


Field Summary
static Function IDENTITY
          The prototype function returns the argument (identity-function).
 
Constructor Summary
Function()
           
 
Method Summary
 Function concatenate(Function[] functions)
          Creates a new function by concatenating an array of functions with this function.
 java.lang.Object invoke()
          Returns the function value.
 java.lang.Object invoke(java.lang.Object argument)
          Returns the function value.
 java.lang.Object invoke(java.lang.Object[] arguments)
          Returns the function value.
 java.lang.Object invoke(java.lang.Object argument0, java.lang.Object argument1)
          Returns the function value.
 java.lang.Object returnFirst(java.util.Iterator iterator)
          Returns the first function value (function takes 1 argument).
 java.lang.Object returnFirst(java.util.Iterator[] iterators)
          Returns the first function value (function takes m arguments).
 java.lang.Object returnFirst(java.util.Iterator iterator0, java.util.Iterator iterator1)
          Returns the first function value (function takes 2 arguments).
 java.lang.Object returnLast(java.util.Iterator iterator)
          Returns the last function value (function takes 1 argument).
 java.lang.Object returnLast(java.util.Iterator[] iterators)
          Returns the last function value (function takes m arguments).
 java.lang.Object returnLast(java.util.Iterator iterator0, java.util.Iterator iterator1)
          Returns the last function value (function takes 2 arguments).
 java.lang.Object returnNth(java.util.Iterator[] iterators, int n)
          Returns the n-th function value (function takes m arguments).
 java.lang.Object returnNth(java.util.Iterator iterator, int n)
          Returns the n-th function value (function takes 1 argument).
 java.lang.Object returnNth(java.util.Iterator iterator0, java.util.Iterator iterator1, int n)
          Returns the n-th function value (function takes 2 arguments).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IDENTITY

public static final Function IDENTITY
The prototype function returns the argument (identity-function).
Constructor Detail

Function

public Function()
Method Detail

invoke

public java.lang.Object invoke(java.lang.Object[] arguments)
Returns the function value. This method determines arguments.length and calls the appropriate invoke-method (see below). The other invoke-methods call this method. This means, that the user either has to overwrite this method or one (!) of the other invoke()-methods.
implementation:

switch (arguments.length) {                               
case 0:                                           
return invoke();                          
case 1:                                           
return invoke(arguments[0]);              
case 2:                                           
return invoke(arguments[0], arguments[1]);
default:                                          
return null;                              
}                                                         
Parameters:
arguments - the arguments to the function
Returns:
the function value is returned

invoke

public java.lang.Object invoke()
Returns the function value.
implementation:

return invoke(new Object[0]);
Returns:
the function value is returned

invoke

public java.lang.Object invoke(java.lang.Object argument)
Returns the function value.
implementation:

return invoke(new Object [] {argument});
Parameters:
argument - the argument to the function
Returns:
the function value is returned

invoke

public java.lang.Object invoke(java.lang.Object argument0,
                               java.lang.Object argument1)
Returns the function value.
implementation:

return invoke(new Object [] {argument0, argument1});
Parameters:
argument0 - the first argument to the function
argument1 - the second argument to the function
Returns:
the function value is returned

returnFirst

public java.lang.Object returnFirst(java.util.Iterator iterator)
                             throws java.util.NoSuchElementException
Returns the first function value (function takes 1 argument).
Parameters:
iterator - Iterator of arguments to the function

returnFirst

public java.lang.Object returnFirst(java.util.Iterator[] iterators)
                             throws java.util.NoSuchElementException
Returns the first function value (function takes m arguments).
Parameters:
iterators - Iterator-array of arguments to the function. array.length should correspond to the number of arguments of the function

returnFirst

public java.lang.Object returnFirst(java.util.Iterator iterator0,
                                    java.util.Iterator iterator1)
                             throws java.util.NoSuchElementException
Returns the first function value (function takes 2 arguments).
Parameters:
iterator0 - first Iterator of arguments to the function
iterator1 - second Iterator of arguments to the function

returnLast

public java.lang.Object returnLast(java.util.Iterator iterator)
                            throws java.util.NoSuchElementException
Returns the last function value (function takes 1 argument).
Parameters:
iterator - Iterator of arguments to the function

returnLast

public java.lang.Object returnLast(java.util.Iterator[] iterators)
                            throws java.util.NoSuchElementException
Returns the last function value (function takes m arguments).
Parameters:
iterators - Iterator-array of arguments to the function. array.length should correspond to the number of arguments of the function

returnLast

public java.lang.Object returnLast(java.util.Iterator iterator0,
                                   java.util.Iterator iterator1)
                            throws java.util.NoSuchElementException
Returns the last function value (function takes 2 arguments).
Parameters:
iterator0 - first Iterator of arguments to the function
iterator1 - second Iterator of arguments to the function

returnNth

public java.lang.Object returnNth(java.util.Iterator iterator,
                                  int n)
                           throws java.util.NoSuchElementException
Returns the n-th function value (function takes 1 argument).
Parameters:
iterator - Iterator of arguments to the function

returnNth

public java.lang.Object returnNth(java.util.Iterator[] iterators,
                                  int n)
                           throws java.util.NoSuchElementException
Returns the n-th function value (function takes m arguments).
Parameters:
iterators - Iterator-array of arguments to the function. array.length should correspond to the number of arguments of the function

returnNth

public java.lang.Object returnNth(java.util.Iterator iterator0,
                                  java.util.Iterator iterator1,
                                  int n)
                           throws java.util.NoSuchElementException
Returns the n-th function value (function takes 2 arguments).
Parameters:
iterator0 - first Iterator of arguments to the function
iterator1 - second Iterator of arguments to the function

concatenate

public Function concatenate(Function[] functions)
Creates a new function by concatenating an array of functions with this function. Whenever the new function is invoked, its parameters are passed to each function of the array, and the resulting objects serve as the parameters to this function which produces the final value.
Parameters:
functions - The functions to be concatenated with this function.