|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.rex.RexNode org.eigenbase.rex.RexLiteral
public class RexLiteral
Constant value in a row-expression.
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.eigenbase.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) . |
A class which implements the Enum14.Value
interface |
Field Summary | |
---|---|
private RelDataType |
type
The real type of this literal, as reported by getType() . |
private SqlTypeName |
typeName
An indication of the broad type of this literal -- even if its type isn't a SQL type. |
private Comparable |
value
The value of this literal. |
Fields inherited from class org.eigenbase.rex.RexNode |
---|
digest, EMPTY_ARRAY |
Constructor Summary | |
---|---|
RexLiteral(Comparable value,
RelDataType type,
SqlTypeName typeName)
Creates a RexLiteral . |
Method Summary | ||
---|---|---|
|
accept(RexVisitor<R> visitor)
Accepts a visitor, dispatching to the right overloaded visitXxx method. |
|
static boolean |
booleanValue(RexNode node)
|
|
RexLiteral |
clone()
|
|
boolean |
equals(Object obj)
|
|
private static boolean |
equals(Object o1,
Object o2)
|
|
private static Comparable |
findValue(RexNode node)
|
|
static RexLiteral |
fromJdbcString(RelDataType type,
SqlTypeName typeName,
String literal)
Converts a Jdbc string into a RexLiteral. |
|
private static String |
getCalendarFormat(SqlTypeName typeName)
|
|
RexKind |
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. |
|
int |
hashCode()
|
|
static int |
intValue(RexNode node)
|
|
boolean |
isAlwaysTrue()
Returns whether this expression always returns true. |
|
static boolean |
isNullLiteral(RexNode node)
|
|
private static void |
printAsJava(Comparable value,
PrintWriter pw,
SqlTypeName typeName,
boolean java)
Prints a value as a Java string. |
|
void |
printAsJava(PrintWriter pw)
Prints the value this literal as a Java string constant. |
|
private static void |
printDatetime(PrintWriter pw,
ZonelessDatetime datetime,
Comparable value)
|
|
static String |
stringValue(RexNode node)
|
|
private static String |
toJavaString(Comparable value,
SqlTypeName typeName)
|
|
static boolean |
valueMatchesType(Comparable value,
SqlTypeName typeName)
|
Methods inherited from class org.eigenbase.rex.RexNode |
---|
isA, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private final Comparable value
valueMatchesType(java.lang.Comparable, org.eigenbase.sql.type.SqlTypeName)
. For example, you can't store an Integer
value here just because you feel like it -- all numbers are
represented by a BigDecimal
. But since this field is private, it
doesn't really matter how the values are stored.
private final RelDataType type
getType()
.
private final SqlTypeName typeName
SqlTypeName.DECIMAL
. See valueMatchesType(java.lang.Comparable, org.eigenbase.sql.type.SqlTypeName)
for the definitive
story.
Constructor Detail |
---|
RexLiteral(Comparable value, RelDataType type, SqlTypeName typeName)
RexLiteral
.
Method Detail |
---|
public static boolean valueMatchesType(Comparable value, SqlTypeName typeName)
private static String toJavaString(Comparable value, SqlTypeName typeName)
public void printAsJava(PrintWriter pw)
private static void printAsJava(Comparable value, PrintWriter pw, SqlTypeName typeName, boolean java)
valueMatchesType(java.lang.Comparable, org.eigenbase.sql.type.SqlTypeName)
.
Typical return values:
value
- Valuepw
- Writer to write totypeName
- Type familyprivate static void printDatetime(PrintWriter pw, ZonelessDatetime datetime, Comparable value)
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 string
private static String getCalendarFormat(SqlTypeName typeName)
public SqlTypeName getTypeName()
public RelDataType getType()
getType
in class RexNode
public RexKind getKind()
RexNode
getKind
in class RexNode
RexKind
value, never nullpublic Comparable getValue()
public Object getValue2()
public static boolean booleanValue(RexNode node)
public boolean isAlwaysTrue()
RexNode
TRUE
.)
isAlwaysTrue
in class RexNode
public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
public static int intValue(RexNode node)
public static String stringValue(RexNode node)
private static Comparable findValue(RexNode node)
public static boolean isNullLiteral(RexNode node)
public RexLiteral clone()
clone
in class RexNode
private static boolean equals(Object o1, Object o2)
public <R> R accept(RexVisitor<R> visitor)
RexNode
visitXxx
method.
Also see RexProgram.apply(RexVisitor, RexNode[], RexNode)
,
which applies a visitor to several expressions simultaneously.
accept
in class RexNode
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |