public class RexLiteral extends RexNode
There are several methods for creating literals in RexBuilder:
RexBuilder.makeLiteral(boolean) and so forth.
How is the value stored? In that respect, the class is somewhat of a black
box. There is a getValue() method which returns the value as an
object, but the type of that value is implementation detail, and it is best
that your code does not depend upon that knowledge. It is better to use
task-oriented methods such as getValue2() and
toJavaString(java.lang.Comparable, org.apache.calcite.sql.type.SqlTypeName).
The allowable types and combinations are:
| TypeName | Meaing | Value type |
|---|---|---|
SqlTypeName.NULL |
The null value. It has its own special type. | null |
SqlTypeName.BOOLEAN |
Boolean, namely TRUE, FALSE or
UNKNOWN. |
Boolean, or null represents the UNKNOWN value |
SqlTypeName.DECIMAL |
Exact number, for example 0, -.5,
12345. |
BigDecimal |
SqlTypeName.DOUBLE |
Approximate number, for example 6.023E-23. |
BigDecimal |
SqlTypeName.DATE |
Date, for example DATE '1969-04'29' |
Calendar |
SqlTypeName.TIME |
Time, for example TIME '18:37:42.567' |
Calendar |
SqlTypeName.TIMESTAMP |
Timestamp, for example TIMESTAMP '1969-04-29
18:37:42.567' |
Calendar |
SqlTypeName.CHAR |
Character constant, for example 'Hello, world!',
'', _N'Bonjour', _ISO-8859-1'It''s superman!'
COLLATE SHIFT_JIS$ja_JP$2. These are always CHAR, never VARCHAR. |
NlsString |
SqlTypeName.BINARY |
Binary constant, for example X'7F34'. (The number of hexits
must be even; see above.) These constants are always BINARY, never
VARBINARY. |
ByteBuffer |
SqlTypeName.SYMBOL |
A symbol is a special type used to make parsing easier; it is not part of
the SQL standard, and is not exposed to end-users. It is used to hold a flag,
such as the LEADING flag in a call to the function
TRIM([LEADING|TRAILING|BOTH] chars FROM string). |
An enum class |
| Modifier and Type | Method and Description |
|---|---|
<R> R |
accept(RexVisitor<R> visitor)
Accepts a visitor, dispatching to the right overloaded
visitXxx method. |
static boolean |
booleanValue(RexNode node) |
boolean |
equals(Object obj) |
static RexLiteral |
fromJdbcString(RelDataType type,
SqlTypeName typeName,
String literal)
Converts a Jdbc string into a RexLiteral.
|
SqlKind |
getKind()
Returns the kind of node this is.
|
RelDataType |
getType() |
SqlTypeName |
getTypeName() |
Comparable |
getValue()
Returns the value of this literal.
|
Object |
getValue2()
Returns the value of this literal, in the form that the calculator
program builder wants it.
|
Object |
getValue3()
Returns the value of this literal, in the form that the rex-to-lix
translator wants it.
|
int |
hashCode() |
static int |
intValue(RexNode node) |
boolean |
isAlwaysFalse()
Returns whether this expression always returns false.
|
boolean |
isAlwaysTrue()
Returns whether this expression always returns true.
|
static boolean |
isNullLiteral(RexNode node) |
void |
printAsJava(PrintWriter pw)
Prints the value this literal as a Java string constant.
|
static String |
stringValue(RexNode node) |
static boolean |
validConstant(Object o,
Litmus litmus)
Returns whether a value is valid as a constant value, using the same
criteria as
valueMatchesType(java.lang.Comparable, org.apache.calcite.sql.type.SqlTypeName, boolean). |
static boolean |
valueMatchesType(Comparable value,
SqlTypeName typeName,
boolean strict) |
public static boolean valueMatchesType(Comparable value, SqlTypeName typeName, boolean strict)
public static boolean validConstant(Object o, Litmus litmus)
valueMatchesType(java.lang.Comparable, org.apache.calcite.sql.type.SqlTypeName, boolean).public void printAsJava(PrintWriter pw)
public static RexLiteral fromJdbcString(RelDataType type, SqlTypeName typeName, String literal)
If a null literal is provided, then a null pointer will be returned.
type - data type of literal to be readtypeName - type family of literalliteral - the (non-SQL encoded) string representation, as returned
by the Jdbc call to return a column as a stringpublic SqlTypeName getTypeName()
public RelDataType getType()
public SqlKind getKind()
RexNodepublic Comparable getValue()
public Object getValue2()
public Object getValue3()
public static boolean booleanValue(RexNode node)
public boolean isAlwaysTrue()
RexNodeTRUE.)isAlwaysTrue in class RexNodepublic boolean isAlwaysFalse()
RexNodeFALSE.)isAlwaysFalse in class RexNodepublic static int intValue(RexNode node)
public static boolean isNullLiteral(RexNode node)
public <R> R accept(RexVisitor<R> visitor)
RexNodevisitXxx method.
Also see RexUtil.apply(RexVisitor, java.util.List, RexNode),
which applies a visitor to several expressions simultaneously.
Copyright © 2012–2015 The Apache Software Foundation. All rights reserved.