org.eigenbase.sql
Class SqlTimestampLiteral

java.lang.Object
  extended by org.eigenbase.sql.SqlNode
      extended by org.eigenbase.sql.SqlLiteral
          extended by org.eigenbase.sql.SqlAbstractDateTimeLiteral
              extended by org.eigenbase.sql.SqlTimestampLiteral
All Implemented Interfaces:
Cloneable

public class SqlTimestampLiteral
extends SqlAbstractDateTimeLiteral

A SQL literal representing a TIMESTAMP value, for example TIMESTAMP '1969-07-21 03:15 GMT'.

Create values using SqlLiteral.createTimestamp(java.util.Calendar, int, org.eigenbase.sql.parser.SqlParserPos).


Nested Class Summary
 
Nested classes/interfaces inherited from class org.eigenbase.sql.SqlLiteral
SqlLiteral.SqlSymbol
 
Field Summary
 
Fields inherited from class org.eigenbase.sql.SqlAbstractDateTimeLiteral
formatString, hasTimeZone, precision
 
Fields inherited from class org.eigenbase.sql.SqlLiteral
value
 
Fields inherited from class org.eigenbase.sql.SqlNode
emptyArray
 
Constructor Summary
SqlTimestampLiteral(Calendar cal, int precision, boolean hasTimeZone, SqlParserPos pos)
           
SqlTimestampLiteral(Calendar cal, int precision, boolean hasTimeZone, String format, SqlParserPos pos)
           
 
Method Summary
 SqlNode clone(SqlParserPos pos)
          Converts this literal to a Time object.
 String toFormattedString()
          Returns e.g.
 String toString()
          Returns e.g.
 void unparse(SqlWriter writer, int leftPrec, int rightPrec)
          Writes a SQL representation of this node to a writer.
 
Methods inherited from class org.eigenbase.sql.SqlAbstractDateTimeLiteral
createSqlType, getCal, getDate, getPrec, getTime, getTimestamp, getTimeZone, toValue
 
Methods inherited from class org.eigenbase.sql.SqlLiteral
accept, bigDecimalValue, booleanValue, createApproxNumeric, createBinaryString, createBinaryString, createBoolean, createCharString, createCharString, createDate, createExactNumeric, createInterval, createNegative, createNull, createSample, createSymbol, createTime, createTimestamp, createUnknown, equals, equalsDeep, getKind, getMonotonicity, getStringValue, getTypeName, getValue, hashCode, intValue, longValue, sampleValue, stringValue, symbolValue, unescapeUnicode, validate, valueMatchesType
 
Methods inherited from class org.eigenbase.sql.SqlNode
clone, cloneArray, equalDeep, findValidOptions, getParserPosition, isA, toSqlString, toSqlString, validateExpr
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SqlTimestampLiteral

public SqlTimestampLiteral(Calendar cal,
                           int precision,
                           boolean hasTimeZone,
                           SqlParserPos pos)

SqlTimestampLiteral

public SqlTimestampLiteral(Calendar cal,
                           int precision,
                           boolean hasTimeZone,
                           String format,
                           SqlParserPos pos)
Method Detail

clone

public SqlNode clone(SqlParserPos pos)
Converts this literal to a Time object.

Overrides:
clone in class SqlLiteral

toString

public String toString()
Description copied from class: SqlAbstractDateTimeLiteral
Returns e.g. DATE '1969-07-21'.

Specified by:
toString in class SqlAbstractDateTimeLiteral

toFormattedString

public String toFormattedString()
Returns e.g. '03:05:67.456'.

Specified by:
toFormattedString in class SqlAbstractDateTimeLiteral

unparse

public void unparse(SqlWriter writer,
                    int leftPrec,
                    int rightPrec)
Description copied from class: SqlNode
Writes a SQL representation of this node to a writer.

The leftPrec and rightPrec parameters give us enough context to decide whether we need to enclose the expression in parentheses. For example, we need parentheses around "2 + 3" if preceded by "5 *". This is because the precedence of the "*" operator is greater than the precedence of the "+" operator.

The algorithm handles left- and right-associative operators by giving them slightly different left- and right-precedence.

If SqlWriter.isAlwaysUseParentheses() is true, we use parentheses even when they are not required by the precedence rules.

For the details of this algorithm, see SqlCall.unparse(org.eigenbase.sql.SqlWriter, int, int).

Overrides:
unparse in class SqlAbstractDateTimeLiteral
Parameters:
writer - Target writer
leftPrec - The precedence of the SqlNode immediately preceding this node in a depth-first scan of the parse tree
rightPrec - The precedence of the SqlNode immediately