org.eigenbase.sql
Class SqlDateLiteral

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.SqlDateLiteral
All Implemented Interfaces:
Cloneable

public class SqlDateLiteral
extends SqlAbstractDateTimeLiteral

A SQL literal representing a DATE value, such as DATE '2004-10-22'.

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

Version:
$Id: //open/dev/farrago/src/org/eigenbase/sql/SqlDateLiteral.java#15 $
Author:
jhyde

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
SqlDateLiteral(Calendar d, SqlParserPos pos)
           
SqlDateLiteral(Calendar d, String format, SqlParserPos pos)
           
 
Method Summary
 SqlNode clone(SqlParserPos pos)
          Clones a SqlNode with a different position.
 RelDataType createSqlType(RelDataTypeFactory typeFactory)
           
 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
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

SqlDateLiteral

SqlDateLiteral(Calendar d,
               SqlParserPos pos)

SqlDateLiteral

SqlDateLiteral(Calendar d,
               String format,
               SqlParserPos pos)
Method Detail

clone

public SqlNode clone(SqlParserPos pos)
Description copied from class: SqlNode
Clones a SqlNode with a different position.

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. '1969-07-21'.

Specified by:
toFormattedString in class SqlAbstractDateTimeLiteral

createSqlType

public RelDataType createSqlType(RelDataTypeFactory typeFactory)
Overrides:
createSqlType 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