org.eigenbase.sql
Class SqlBinaryStringLiteral

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

public class SqlBinaryStringLiteral
extends SqlAbstractStringLiteral

A binary (or hexadecimal) string literal.

The SqlLiteral.value field is a BitString and SqlLiteral.typeName is SqlTypeName.BINARY.

Version:
$Id: //open/dev/farrago/src/org/eigenbase/sql/SqlBinaryStringLiteral.java#13 $
Author:
wael

Nested Class Summary
 
Nested classes/interfaces inherited from class org.eigenbase.sql.SqlLiteral
SqlLiteral.SqlSymbol
 
Field Summary
 
Fields inherited from class org.eigenbase.sql.SqlLiteral
value
 
Fields inherited from class org.eigenbase.sql.SqlNode
emptyArray
 
Constructor Summary
protected SqlBinaryStringLiteral(BitString val, SqlParserPos pos)
           
 
Method Summary
 SqlNode clone(SqlParserPos pos)
          Clones a SqlNode with a different position.
protected  SqlAbstractStringLiteral concat1(SqlLiteral[] lits)
          Helper routine for SqlUtil.concatenateLiterals(org.eigenbase.sql.SqlLiteral[]).
 BitString getBitString()
           
 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.SqlLiteral
accept, bigDecimalValue, booleanValue, createApproxNumeric, createBinaryString, createBinaryString, createBoolean, createCharString, createCharString, createDate, createExactNumeric, createInterval, createNegative, createNull, createSample, createSqlType, createSymbol, createTime, createTimestamp, createUnknown, equals, equalsDeep, getKind, getMonotonicity, getStringValue, getTypeName, getValue, hashCode, intValue, longValue, sampleValue, stringValue, symbolValue, toValue, unescapeUnicode, validate, valueMatchesType
 
Methods inherited from class org.eigenbase.sql.SqlNode
clone, cloneArray, equalDeep, findValidOptions, getParserPosition, isA, toSqlString, toSqlString, toString, validateExpr
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SqlBinaryStringLiteral

protected SqlBinaryStringLiteral(BitString val,
                                 SqlParserPos pos)
Method Detail

getBitString

public BitString getBitString()
Returns:
the underlying BitString

clone

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

Overrides:
clone in class SqlLiteral

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 SqlLiteral
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

concat1

protected SqlAbstractStringLiteral concat1(SqlLiteral[] lits)
Description copied from class: SqlAbstractStringLiteral
Helper routine for SqlUtil.concatenateLiterals(org.eigenbase.sql.SqlLiteral[]).

Specified by:
concat1 in class SqlAbstractStringLiteral
Parameters:
lits - homogeneous StringLiteral[] args.
Returns:
StringLiteral with concatenated value. this == lits[0], used only for method dispatch.