com.endeca.navigation.analytics
Class ExprFunction

java.lang.Object
  extended by com.endeca.navigation.analytics.ExprFunction
All Implemented Interfaces:
Expr, QueryNode

public class ExprFunction
extends Object
implements Expr

ExprFunction instances represent unary scalar function expressions.


Nested Class Summary
static class ExprFunction.ExprFunctionOp
          Enumeration of Endeca unary scalar functions.
 
Field Summary
static ExprFunction.ExprFunctionOp ABS
          Absolute value function.
static ExprFunction.ExprFunctionOp CEIL
          Ceiling function.
static ExprFunction.ExprFunctionOp COS
          Cosine function.
static int DATE
          Date constant.
static int DAY_OF_MONTH
          Day-of-month constant.
static int DAY_OF_WEEK
          Day-of-week constant.
static int DAY_OF_YEAR
          Day-of-year constant.
static ExprFunction.ExprFunctionOp EXP
          Exponential function.
static ExprFunction.ExprFunctionOp EXTRACT
          Date Extraction function.
static ExprFunction.ExprFunctionOp FLOOR
          Floor function.
static int HOUR
          Hour constant.
static ExprFunction.ExprFunctionOp LAG
          Lag function.
static ExprFunction.ExprFunctionOp LEAD
          Lead function.
static ExprFunction.ExprFunctionOp LN
          Natural logarithm function.
static int MINUTE
          Minute constant.
static int MONTH
          Month constant.
static int QUARTER
          Quarter year constant.
static ExprFunction.ExprFunctionOp ROUND
          Round function.
static int SECOND
          Second constant.
static ExprFunction.ExprFunctionOp SIGN
          Sign function.
static ExprFunction.ExprFunctionOp SIN
          Sine function.
static ExprFunction.ExprFunctionOp SQRT
          Square root function.
static ExprFunction.ExprFunctionOp TAN
          Tangent function.
static ExprFunction.ExprFunctionOp TO_DURATION
          Duration function.
static ExprFunction.ExprFunctionOp TRUNC
          Date Truncation function.
static int WEEK
          Week constant.
static int YEAR
          Year constant.
 
Constructor Summary
ExprFunction(ExprFunction.ExprFunctionOp func, Expr subExpr, int param)
          Creates a new ExprFunction of the specified subexpression subExpr.
 
Method Summary
 Expr getExpr()
          Gets the subexpression for this ExprFunction.
 void setExpr(Expr expr)
          Sets the subexpression for this ExprFunction.
 ExprFunction.ExprFunctionOp setFunction()
          Gets the mathematical function for this ExprFunction.
 void setFunction(ExprFunction.ExprFunctionOp function)
          Sets the function for this ExprFunction.
 String toString()
          Returns the string form of this ExprFunction.
 String toWire()
          Returns the wire form of this ExprFunction.
 void validateSyntax()
          Validates the syntax of this ExprFunction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ABS

public static final ExprFunction.ExprFunctionOp ABS
Absolute value function. Returns the absolute value of a number.


CEIL

public static final ExprFunction.ExprFunctionOp CEIL
Ceiling function. Returns the smallest integer that is greater than or equal to a given numeric expression.


COS

public static final ExprFunction.ExprFunctionOp COS
Cosine function. Returns the cosine, in radians, of an angle.


EXP

public static final ExprFunction.ExprFunctionOp EXP
Exponential function. Returns the log exponential (base e) value of a given numeric expression.


EXTRACT

public static final ExprFunction.ExprFunctionOp EXTRACT
Date Extraction function. Extracts a portion of a DateTime property value, such as the day of the week or month of the year. The portion to be extracted is specified with an integer in the param parameter of the constructor. See the "Constant Field Values" page for the constants that map to the extracted portion (such as 8 for the month).


FLOOR

public static final ExprFunction.ExprFunctionOp FLOOR
Floor function. Returns the largest integer less than or equal to a given numeric expression.


LAG

public static final ExprFunction.ExprFunctionOp LAG
Lag function. Returns a value in a row a specified number of rows from a current row. LAG provides access to a row at a given offset prior to the current position. The offset is specified with the param parameter of the constructor.


LEAD

public static final ExprFunction.ExprFunctionOp LEAD
Lead function. Returns a value in a row a specified number of rows from a current row. LEAD provides access to a row at a given offset after the current position. The offset is specified with the param parameter of the constructor.


LN

public static final ExprFunction.ExprFunctionOp LN
Natural logarithm function. Returns the logarithm of its single argument, the base of which is e.


ROUND

public static final ExprFunction.ExprFunctionOp ROUND
Round function. Rounds a number to the nearest integer.


SIGN

public static final ExprFunction.ExprFunctionOp SIGN
Sign function. Returns the sign of a given numeric expression. SIGN returns -1 (if the expression is less than zero), 0 (if the expression is zero), or 1 (if the expression is greater than zero).


SIN

public static final ExprFunction.ExprFunctionOp SIN
Sine function. Returns the sine, in radians, of an angle.


SQRT

public static final ExprFunction.ExprFunctionOp SQRT
Square root function. Returns the square root of a given numeric expression.


TAN

public static final ExprFunction.ExprFunctionOp TAN
Tangent function. Returns the tangent, in radians, of an angle.


TO_DURATION

public static final ExprFunction.ExprFunctionOp TO_DURATION
Duration function. Casts an integer into a number of milliseconds, so that it can be used as a duration.


TRUNC

public static final ExprFunction.ExprFunctionOp TRUNC
Date Truncation function. Rounds the value of a DateTime property down to a coarser granularity. The granularity is specified with an integer in the param parameter of the constructor. See the "Constant Field Values" page for the constants that map to the truncated portion (such as 8 for the month).


SECOND

public static final int SECOND
Second constant. Used to designate that a second be the value for the EXTRACT and TRUNC functions.

See Also:
Constant Field Values

MINUTE

public static final int MINUTE
Minute constant. Use to designate that a minute be the value for the EXTRACT and TRUNC functions.

See Also:
Constant Field Values

HOUR

public static final int HOUR
Hour constant. Used to designate that an hour be the value for the EXTRACT and TRUNC functions.

See Also:
Constant Field Values

DAY_OF_WEEK

public static final int DAY_OF_WEEK
Day-of-week constant. Used to designate that a day in the week be the value for the EXTRACT and TRUNC functions.

See Also:
Constant Field Values

DAY_OF_MONTH

public static final int DAY_OF_MONTH
Day-of-month constant. Used to designate that a day in the month be the value for the EXTRACT and TRUNC functions.

See Also:
Constant Field Values

DAY_OF_YEAR

public static final int DAY_OF_YEAR
Day-of-year constant. Used to designate that a day in the year be the value for the EXTRACT and TRUNC functions.

See Also:
Constant Field Values

DATE

public static final int DATE
Date constant. Used to designate the date as a day in the month, as the value for the EXTRACT and TRUNC functions.

See Also:
Constant Field Values

WEEK

public static final int WEEK
Week constant. Used to designate that a week be the value for the EXTRACT and TRUNC functions.

See Also:
Constant Field Values

MONTH

public static final int MONTH
Month constant. Used to designate that a month be the value for the EXTRACT and TRUNC functions.

See Also:
Constant Field Values

QUARTER

public static final int QUARTER
Quarter year constant. Used to designate that a quarter in the year be the value for the EXTRACT and TRUNC functions.

See Also:
Constant Field Values

YEAR

public static final int YEAR
Year constant. Used to designate that a year be the value for the EXTRACT and TRUNC functions.

See Also:
Constant Field Values
Constructor Detail

ExprFunction

public ExprFunction(ExprFunction.ExprFunctionOp func,
                    Expr subExpr,
                    int param)
Creates a new ExprFunction of the specified subexpression subExpr.

Parameters:
func - a function of type ExprFunction.ExprFunctionOp that specifies the type of operation to be made. See the setFunction method for a list of the function names.
subExpr - a subexpression of type Expr. If func is LAG or LEAD, then subExpr must be an ExprKey.
param - an integer to be used only with the EXTRACT, LAG, LEAD, ROUND, and TRUNC functions. For ROUND and TRUNC, positive numbers round to the equivalent number of decimal places; negative numbers round to the equivalent place to the left of the decimal place. For TRUNC (when subExpr is a date/time) and EXTRACT, param is a constant such as HOUR or YEAR.
Method Detail

setFunction

public void setFunction(ExprFunction.ExprFunctionOp function)
Sets the function for this ExprFunction.

Parameters:
function - a function of type ExprFunction.ExprFunctionOp that specifies the type of operation to be made. The functions are: ExprFunction.ABS, ExprFunction.CEIL, ExprFunction.COS, ExprFunction.EXP, ExprFunction.EXTRACT, ExprFunction.FLOOR, ExprFunction.LAG, ExprFunction.LEAD, ExprFunction.LN, ExprFunction.ROUND, ExprFunction.SIGN, ExprFunction.SIN, ExprFunction.SQRT, ExprFunction.TAN, ExprFunction.TO_DURATION, and ExprFunction.TRUNC.

setFunction

public ExprFunction.ExprFunctionOp setFunction()
Gets the mathematical function for this ExprFunction.

Returns:
The function (of type ExprFunction.ExprFunctionOp) for this ExprFunction. See the setFunction method for a list of the function names.

setExpr

public void setExpr(Expr expr)
Sets the subexpression for this ExprFunction.

Parameters:
expr - an expression of type Expr.

getExpr

public Expr getExpr()
Gets the subexpression for this ExprFunction.

Returns:
The subexpression object (of type Expr) for this ExprFunction.

toString

public String toString()
Returns the string form of this ExprFunction. The format for the EXTRACT, LAG, LEAD, ROUND, and TRUNC functions is:
FUNCTION(subexpression), param
where FUNCTION is a function name and param is a value set by the param parameter to the constructor.

The format for the other functions omits the param setting.

Specified by:
toString in interface QueryNode
Overrides:
toString in class Object
Returns:
A string representation of this ExprFunction in the specified format.

toWire

public String toWire()
Returns the wire form of this ExprFunction. This method is not intended for public use because the wire format is subject to change.

Specified by:
toWire in interface QueryNode
Returns:
A wire format representation of this ExprFunction.

validateSyntax

public void validateSyntax()
                    throws SyntaxException
Validates the syntax of this ExprFunction. An ExprFunction is valid if the function is not null and the subexpression is non-null and valid.

Specified by:
validateSyntax in interface QueryNode
Throws:
SyntaxException - if the syntax requirements are not satisfied.


2010 Endeca Technologies, Inc.
Endeca Confidential