Top Description Fields Constructors Methods
org.h2.expression.function

public final Class MathFunction

extends Function1_2
Class Inheritance
Imports
java.math.BigDecimal, .RoundingMode, org.h2.api.ErrorCode, org.h2.engine.SessionLocal, org.h2.expression.Expression, .TypedValueExpression, org.h2.message.DbException, org.h2.mvstore.db.Store, org.h2.value.DataType, .TypeInfo, .Value, .ValueBigint, .ValueDecfloat, .ValueDouble, .ValueInteger, .ValueNull, .ValueNumeric, .ValueReal

A math function.

Field Summary

Modifier and TypeField and Description
public static final int
ABS

ABS().

public static final int
CEIL

CEIL() or CEILING().

private TypeInfo
public static final int
FLOOR

FLOOR().

private final int
public static final int
MOD

MOD().

private static final String[]
public static final int
ROUND

ROUND() (non-standard)

public static final int
ROUNDMAGIC

ROUNDMAGIC() (non-standard)

public static final int
SIGN

SIGN() (non-standard)

public static final int
TRUNC

TRUNC() (non-standard)

Constructor Summary

AccessConstructor and Description
public
MathFunction(Expression arg1, Expression arg2, int function)

Method Summary

Modifier and TypeMethod and Description
private static int
public String
public Value
getValue(SessionLocal
the session
session
,
Value
the value of first argument
v1
,
Value
the value of second argument, or null
v2
)

Overrides org.h2.expression.function.Function1_2.getValue.

Returns the value of this function.

public Expression
optimize(SessionLocal
the session
session
)

Implements abstract org.h2.expression.Expression.optimize.

Try to optimize the expression.

private Expression

Returns:

the optimized expression or null if this function should be used
optimizeRound
(int
the scale, if known
scale
,
boolean
whether scale is known
scaleIsKnown
,
boolean
whether scale is NULL
scaleIsNull
,
boolean
true if result of rounding can have larger precision than precision of argument, false otherwise
possibleRoundUp
)

Optimizes rounding and truncation functions.

private Expression
optimizeRoundWithScale(SessionLocal session, boolean possibleRoundUp)

private Value
round(Value v1, Value v2, RoundingMode roundingMode)

private static double
roundMagic(double d)

Inherited from org.h2.expression.function.Function1_2:
getUnenclosedSQLgetValue

Field Detail

ABSback to summary
public static final int ABS

ABS().

CEILback to summary
public static final int CEIL

CEIL() or CEILING().

commonTypeback to summary
private TypeInfo commonType
FLOORback to summary
public static final int FLOOR

FLOOR().

functionback to summary
private final int function
MODback to summary
public static final int MOD

MOD().

NAMESback to summary
private static final String[] NAMES
ROUNDback to summary
public static final int ROUND

ROUND() (non-standard)

ROUNDMAGICback to summary
public static final int ROUNDMAGIC

ROUNDMAGIC() (non-standard)

SIGNback to summary
public static final int SIGN

SIGN() (non-standard)

TRUNCback to summary
public static final int TRUNC

TRUNC() (non-standard)

Constructor Detail

MathFunctionback to summary
public MathFunction(Expression arg1, Expression arg2, int function)

Method Detail

checkScaleback to summary
private static int checkScale(Value v)
getNameback to summary
public String getName()

Implements org.h2.expression.function.NamedExpression.getName.

Doc from org.h2.expression.function.NamedExpression.getName.

Get the name.

Returns:String

the name in uppercase

Annotations
@Override
getValueback to summary
public Value getValue(SessionLocal session, Value v1, Value v2)

Overrides org.h2.expression.function.Function1_2.getValue.

Doc from org.h2.expression.function.Function1_2.getValue.

Returns the value of this function.

Parameters
session:SessionLocal

the session

v1:Value

the value of first argument

v2:Value

the value of second argument, or null

Returns:Value

the resulting value

Annotations
@Override
optimizeback to summary
public Expression optimize(SessionLocal session)

Implements abstract org.h2.expression.Expression.optimize.

Doc from org.h2.expression.Expression.optimize.

Try to optimize the expression.

Parameters
session:SessionLocal

the session

Returns:Expression

the optimized expression

Annotations
@Override
optimizeRoundback to summary
private Expression optimizeRound(int scale, boolean scaleIsKnown, boolean scaleIsNull, boolean possibleRoundUp)

Optimizes rounding and truncation functions.

Parameters
scale:int

the scale, if known

scaleIsKnown:boolean

whether scale is known

scaleIsNull:boolean

whether scale is NULL

possibleRoundUp:boolean

true if result of rounding can have larger precision than precision of argument, false otherwise

Returns:Expression

the optimized expression or null if this function should be used

optimizeRoundWithScaleback to summary
private Expression optimizeRoundWithScale(SessionLocal session, boolean possibleRoundUp)
roundback to summary
private Value round(Value v1, Value v2, RoundingMode roundingMode)
Annotations
@SuppressWarnings:incomplete-switch
roundMagicback to summary
private static double roundMagic(double d)