de.mguennewig.pobjects
Class FctCall

java.lang.Object
  extended by de.mguennewig.pobjects.FctCall
All Implemented Interfaces:
Term, java.lang.Iterable<Term>

public class FctCall
extends java.lang.Object
implements Term, java.lang.Iterable<Term>

A function call within an SQL expression.

Author:
Michael Günnewig

Constructor Summary
FctCall(java.lang.String fctName, Term... args)
          Create a function call.
 
Method Summary
static FctCall abs(Term arg)
          Absolute value.
static FctCall coalesce(Term... terms)
          The COALESCE function returns the first of its arguments that is not null.
 boolean equals(java.lang.Object o)
          
 Term getArgument(int i)
           
 java.lang.String getFunctionName()
           
 int getNumArguments()
           
 java.lang.String getSqlValue(EvalContext eval)
          Returns the SQL expression for this term.
 int hashCode()
          
 boolean isConstant()
          Tests whether the function call can be evaluated without an object.
 boolean isJoin()
          Tests whether this expression enforces any kind of join.
 boolean isSelection()
          Tests whether this expression is a selection.
 java.util.Iterator<Term> iterator()
          
static FctCall length(Term arg)
          Length of a string.
static FctCall lower(Term arg)
          Convert string to lower case.
static FctCall nullif(Term term1, Term term2)
          The NULLIF function returns a null value if the terms term1 and term2 evaluate to equal values, otherwise it returns the value of term1.
static FctCall substring(Term arg, int start, int end)
          Compute a substring.
 java.lang.String toString()
          
static FctCall upper(Term arg)
          Convert string to upper case.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FctCall

public FctCall(java.lang.String fctName,
               Term... args)
Create a function call.

Parameters:
fctName - the name of the function.
args - the argument list.
Throws:
java.lang.IllegalArgumentException - if any argument term is null
Method Detail

equals

public boolean equals(java.lang.Object o)

Overrides:
equals in class java.lang.Object

getFunctionName

public final java.lang.String getFunctionName()

getNumArguments

public final int getNumArguments()

getArgument

public final Term getArgument(int i)

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

iterator

public java.util.Iterator<Term> iterator()

Specified by:
iterator in interface java.lang.Iterable<Term>

isConstant

public boolean isConstant()
Tests whether the function call can be evaluated without an object.

Specified by:
isConstant in interface Term

isJoin

public boolean isJoin()
Description copied from interface: Term
Tests whether this expression enforces any kind of join.

Specified by:
isJoin in interface Term

isSelection

public boolean isSelection()
Description copied from interface: Term
Tests whether this expression is a selection.

With selection is an expression meant that binds a Member to one Literal.

Specified by:
isSelection in interface Term

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

abs

public static FctCall abs(Term arg)
Absolute value.

Parameters:
arg - a Term that evaluates to a number.
Throws:
java.lang.IllegalArgumentException - if the argument term is null

coalesce

public static FctCall coalesce(Term... terms)
The COALESCE function returns the first of its arguments that is not null. Null is returned only if all arguments are null.


length

public static FctCall length(Term arg)
Length of a string.

Parameters:
arg - a Term that evaluates to a string value.
Throws:
java.lang.IllegalArgumentException - if the argument term is null

lower

public static FctCall lower(Term arg)
Convert string to lower case.

Parameters:
arg - a Term that evaluates to a string value.
Throws:
java.lang.IllegalArgumentException - if the argument term is null
See Also:
upper(Term)

nullif

public static FctCall nullif(Term term1,
                             Term term2)
The NULLIF function returns a null value if the terms term1 and term2 evaluate to equal values, otherwise it returns the value of term1.


upper

public static FctCall upper(Term arg)
Convert string to upper case.

Parameters:
arg - a Term that evaluates to a string value.
Throws:
java.lang.IllegalArgumentException - if the argument term is null
See Also:
lower(Term)

substring

public static FctCall substring(Term arg,
                                int start,
                                int end)
Compute a substring.

Parameters:
arg - a Term that evaluates to a string value.
Throws:
java.lang.IllegalArgumentException - if argument term is null, the start position is less then 1 or the end is less then the start position.

getSqlValue

public java.lang.String getSqlValue(EvalContext eval)
Description copied from interface: Term
Returns the SQL expression for this term.

Specified by:
getSqlValue in interface Term