public class BinaryArithmeticExpression extends Object implements Expression
Modifier and Type | Class and Description |
---|---|
static class |
BinaryArithmeticExpression.Operator |
Modifier and Type | Field and Description |
---|---|
static BinaryArithmeticExpression.Operator |
OP_ADD |
static BinaryArithmeticExpression.Operator |
OP_DIV |
static BinaryArithmeticExpression.Operator |
OP_MUL |
static BinaryArithmeticExpression.Operator |
OP_SUB |
Constructor and Description |
---|
BinaryArithmeticExpression(Expression lhs,
BinaryArithmeticExpression.Operator op,
Expression rhs)
Creates a binary arithmetic expression by wrapping two expressions and
one operator.
|
Modifier and Type | Method and Description |
---|---|
Constant |
asConstant()
Return the evaluated constant value if both expressions are constant.
|
String |
asFieldName()
This method should never be called.
|
Constant |
evaluate(Record rec)
Evaluates the arithmetic expression by computing on the values from the
record.
|
boolean |
isApplicableTo(Schema sch)
Returns true if both expressions are in the specified schema.
|
boolean |
isConstant()
Returns true if both expressions are constant.
|
boolean |
isFieldName()
Returns false.
|
String |
toString() |
public static final BinaryArithmeticExpression.Operator OP_ADD
public static final BinaryArithmeticExpression.Operator OP_SUB
public static final BinaryArithmeticExpression.Operator OP_MUL
public static final BinaryArithmeticExpression.Operator OP_DIV
public BinaryArithmeticExpression(Expression lhs, BinaryArithmeticExpression.Operator op, Expression rhs)
lhs
- the left hand side expressionop
- the operatorrhs
- the right hand side expressionpublic boolean isConstant()
isConstant
in interface Expression
Expression.isConstant()
public boolean isFieldName()
isFieldName
in interface Expression
Expression.isFieldName()
public Constant asConstant()
asConstant
in interface Expression
Expression.asConstant()
public String asFieldName()
asFieldName
in interface Expression
Expression.asFieldName()
public Constant evaluate(Record rec)
evaluate
in interface Expression
rec
- the recordExpression.evaluate(Record)
public boolean isApplicableTo(Schema sch)
isApplicableTo
in interface Expression
sch
- the schemaExpression.isApplicableTo(Schema)
Copyright © 2022 VanillaDB Organization. All rights reserved.