Class ExpressionValue
java.lang.Object
com.blackrook.expression.ExpressionValue
- All Implemented Interfaces:
Comparable<ExpressionValue>
Expression value encapsulation.
- Author:
- Matthew Tropiano
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic voidabsolute(ExpressionValue operand, ExpressionValue out) Absolute calculation.static voidadd(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Add calculation.static voidand(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Bitwise And calculation.booleanGets this value as a boolean.byteasByte()Gets this value as a byte.doubleasDouble()Gets this value as a double-precision float.floatasFloat()Gets this value as a short.intasInt()Gets this value as an integer.longasLong()Gets this value as a long integer.shortasShort()Gets this value as a short.asString()Gets this value as a string.intvoidconvertTo(ExpressionValue.Type newType) Converts this value to another value.static ExpressionValuecreate(boolean value) Creates an expression value.static ExpressionValuecreate(double value) Creates an expression value.static ExpressionValuecreate(long value) Creates an expression value.static ExpressionValuecreate(ExpressionValue value) Creates an expression value.static voiddivide(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Divide calculation.static voidequal(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Logical Equal calculation.booleanequals(ExpressionValue value) booleanstatic voidgreater(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Greater-than calculation.static voidgreaterOrEqual(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Greater-than-or-equal calculation.booleanbooleanisNaN()static voidleftShift(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Left shift calculation.static voidless(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Less-than calculation.static voidlessOrEqual(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Less-than-or-equal calculation.static voidlogicalAnd(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Logical And calculation.static voidlogicalNot(ExpressionValue operand, ExpressionValue out) Logical not calculation.static voidlogicalOr(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Logical Or calculation.static voidmodulo(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Modulo calculation.static voidmultiply(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Multiply calculation.static voidnegate(ExpressionValue operand, ExpressionValue out) Negate calculation.static voidnot(ExpressionValue operand, ExpressionValue out) Bitwise not calculation.static voidnotEqual(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Logical Not Equal calculation.static voidor(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Bitwise Or calculation.static voidrightShift(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Right shift calculation.static voidrightShiftPadded(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Right shift padded calculation.voidset(boolean value) Sets this value using another value.voidset(double value) Sets this value using another value.voidset(long value) Sets this value using another value.voidset(ExpressionValue value) Sets this value using another value.static voidstrictEqual(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Strict Equal calculation.static voidstrictNotEqual(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Strict Not Equal calculation.static voidsubtract(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Subtract calculation.toString()voidwriteBytes(OutputStream out) Write value as bytes (for digest later).static voidxor(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Bitwise XOr calculation.
-
Method Details
-
create
Creates an expression value.- Parameters:
value- the source value.- Returns:
- a new expression value.
-
create
Creates an expression value.- Parameters:
value- the source value.- Returns:
- a new expression value.
-
create
Creates an expression value.- Parameters:
value- the source value.- Returns:
- a new expression value.
-
create
Creates an expression value.- Parameters:
value- the source value.- Returns:
- a new expression value.
-
set
Sets this value using another value.- Parameters:
value- the source value to use.
-
set
public void set(boolean value) Sets this value using another value.- Parameters:
value- the source value to use.
-
set
public void set(long value) Sets this value using another value.- Parameters:
value- the source value to use.
-
set
public void set(double value) Sets this value using another value.- Parameters:
value- the source value to use.
-
isNaN
public boolean isNaN()- Returns:
- true if this value is NaN.
-
isInfinite
public boolean isInfinite()- Returns:
- true if this value is positive or negative infinity.
-
asBoolean
public boolean asBoolean()Gets this value as a boolean.- Returns:
- true if the value is nonzero and not NaN, false otherwise.
-
asDouble
public double asDouble()Gets this value as a double-precision float. If this is a boolean type, this returns1.0. If this is a long type, this is cast to a double.- Returns:
- the double value of this value.
-
asLong
public long asLong()Gets this value as a long integer. If this is a boolean type, this return-1L. If this is a double type, this is cast to a long.- Returns:
- the long value of this value.
-
asByte
public byte asByte()Gets this value as a byte. Depending on the internal value, this may end up truncating data.(byte)asLong()
- Returns:
- the byte value of this value.
-
asShort
public short asShort()Gets this value as a short. Depending on the internal value, this may end up truncating data.(short)asLong()
- Returns:
- the byte value of this value.
-
asInt
public int asInt()Gets this value as an integer. Depending on the internal value, this may end up truncating data.(int)asLong()
- Returns:
- the byte value of this value.
-
asFloat
public float asFloat()Gets this value as a short. Depending on the internal value, this may end up truncating data.isNaN() ? Float.NaN : (float)asDouble()
- Returns:
- the byte value of this value.
-
asString
-
convertTo
Converts this value to another value.- Parameters:
newType- the new type to convert to.- Throws:
IllegalArgumentException- if newType is null.
-
equals
-
equals
- Parameters:
value- the other value.- Returns:
- true if this value is STRICTLY EQUAL to another.
-
compareTo
- Specified by:
compareToin interfaceComparable<ExpressionValue>
-
toString
-
not
Bitwise not calculation.- Parameters:
operand- the input value.out- the output value.
-
negate
Negate calculation.- Parameters:
operand- the input value.out- the output value.
-
absolute
Absolute calculation.- Parameters:
operand- the input value.out- the output value.
-
logicalNot
Logical not calculation.- Parameters:
operand- the input value.out- the output value.
-
add
Add calculation.- Parameters:
operand- the source operand.operand2- the second operand.out- the output value.
-
subtract
Subtract calculation.- Parameters:
operand- the source operand.operand2- the second operand.out- the output value.
-
multiply
Multiply calculation.- Parameters:
operand- the source operand.operand2- the second operand.out- the output value.
-
divide
Divide calculation.- Parameters:
operand- the source operand.operand2- the second operand.out- the output value.
-
modulo
Modulo calculation.- Parameters:
operand- the source operand.operand2- the second operand.out- the output value.
-
and
Bitwise And calculation.- Parameters:
operand- the source operand.operand2- the second operand.out- the output value.
-
or
Bitwise Or calculation.- Parameters:
operand- the source operand.operand2- the second operand.out- the output value.
-
xor
Bitwise XOr calculation.- Parameters:
operand- the source operand.operand2- the second operand.out- the output value.
-
logicalAnd
public static void logicalAnd(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Logical And calculation.- Parameters:
operand- the source operand.operand2- the second operand.out- the output value.
-
logicalOr
public static void logicalOr(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Logical Or calculation.- Parameters:
operand- the source operand.operand2- the second operand.out- the output value.
-
leftShift
public static void leftShift(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Left shift calculation.- Parameters:
operand- the source operand.operand2- the second operand.out- the output value.
-
rightShift
public static void rightShift(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Right shift calculation.- Parameters:
operand- the source operand.operand2- the second operand.out- the output value.
-
rightShiftPadded
public static void rightShiftPadded(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Right shift padded calculation.- Parameters:
operand- the source operand.operand2- the second operand.out- the output value.
-
less
Less-than calculation.- Parameters:
operand- the source operand.operand2- the second operand.out- the output value.
-
lessOrEqual
public static void lessOrEqual(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Less-than-or-equal calculation.- Parameters:
operand- the source operand.operand2- the second operand.out- the output value.
-
greater
Greater-than calculation.- Parameters:
operand- the source operand.operand2- the second operand.out- the output value.
-
greaterOrEqual
public static void greaterOrEqual(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Greater-than-or-equal calculation.- Parameters:
operand- the source operand.operand2- the second operand.out- the output value.
-
equal
Logical Equal calculation.- Parameters:
operand- the source operand.operand2- the second operand.out- the output value.
-
notEqual
Logical Not Equal calculation.- Parameters:
operand- the source operand.operand2- the second operand.out- the output value.
-
strictEqual
public static void strictEqual(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Strict Equal calculation.- Parameters:
operand- the source operand.operand2- the second operand.out- the output value.
-
strictNotEqual
public static void strictNotEqual(ExpressionValue operand, ExpressionValue operand2, ExpressionValue out) Strict Not Equal calculation.- Parameters:
operand- the source operand.operand2- the second operand.out- the output value.
-
writeBytes
Write value as bytes (for digest later).- Parameters:
out- the output stream.- Throws:
IOException- if a write error occurs.
-