org.eigenbase.sql
Class SqlNodeList

java.lang.Object
  extended by org.eigenbase.sql.SqlNode
      extended by org.eigenbase.sql.SqlNodeList
All Implemented Interfaces:
Cloneable, Iterable<SqlNode>

public class SqlNodeList
extends SqlNode
implements Iterable<SqlNode>

A SqlNodeList is a list of SqlNodes. It is also a SqlNode, so may appear in a parse tree.


Field Summary
static SqlNodeList Empty
          An immutable, empty SqlNodeList.
private  List<SqlNode> list
           
 
Fields inherited from class org.eigenbase.sql.SqlNode
emptyArray
 
Constructor Summary
SqlNodeList(Collection collection, SqlParserPos pos)
          Creates a SqlNodeList containing the nodes in list.
SqlNodeList(SqlParserPos pos)
          Creates an empty SqlNodeList.
 
Method Summary
(package private)  void _andOrList(SqlWriter writer, SqlKind sepKind)
           
<R> R
accept(SqlVisitor<R> visitor)
          Accepts a generic visitor.
 void add(SqlNode node)
           
(package private)  void andOrList(SqlWriter writer, SqlKind sepKind)
           
 SqlNode clone(SqlParserPos pos)
          Clones a SqlNode with a different position.
(package private)  void commaList(SqlWriter writer)
           
 boolean equalsDeep(SqlNode node, boolean fail)
          Returns whether this node is structurally equivalent to another node.
 SqlNode get(int n)
           
 List<SqlNode> getList()
           
static boolean isEmptyList(SqlNode node)
           
 Iterator<SqlNode> iterator()
           
 SqlNode set(int n, SqlNode node)
           
 int size()
           
 SqlNode[] toArray()
           
 void unparse(SqlWriter writer, int leftPrec, int rightPrec)
          Writes a SQL representation of this node to a writer.
 void validate(SqlValidator validator, SqlValidatorScope scope)
          Validates this node.
 void validateExpr(SqlValidator validator, SqlValidatorScope scope)
          Validates this node in an expression context.
 
Methods inherited from class org.eigenbase.sql.SqlNode
clone, cloneArray, equalDeep, findValidOptions, getKind, getMonotonicity, getParserPosition, isA, toSqlString, toSqlString, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Empty

public static final SqlNodeList Empty
An immutable, empty SqlNodeList.


list

private final List<SqlNode> list
Constructor Detail

SqlNodeList

public SqlNodeList(SqlParserPos pos)
Creates an empty SqlNodeList.


SqlNodeList

public SqlNodeList(Collection collection,
                   SqlParserPos pos)
Creates a SqlNodeList containing the nodes in list. The list is copied, but the nodes in it are not.

Method Detail

iterator

public Iterator<SqlNode> iterator()
Specified by:
iterator in interface Iterable<SqlNode>

getList

public List<SqlNode> getList()

add

public void add(SqlNode node)

clone

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

Overrides:
clone in class SqlNode

get

public SqlNode get(int n)

set

public SqlNode set(int n,
                   SqlNode node)

size

public int size()

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).

Specified by:
unparse in class SqlNode
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

commaList

void commaList(SqlWriter writer)

andOrList

void andOrList(SqlWriter writer,
               SqlKind sepKind)

_andOrList

void _andOrList(SqlWriter writer,
                SqlKind sepKind)

validate

public void validate(SqlValidator validator,
                     SqlValidatorScope scope)
Description copied from class: SqlNode
Validates this node.

The typical implementation of this method will make a callback to the validator appropriate to the node type and context. The validator has methods such as SqlValidator.validateLiteral(org.eigenbase.sql.SqlLiteral) for these purposes.

Specified by:
validate in class SqlNode
scope - Validator

accept

public <R> R accept(SqlVisitor<R> visitor)
Description copied from class: SqlNode
Accepts a generic visitor.

Implementations of this method in subtypes simply call the appropriate visit method on the visitor object.

The type parameter R must be consistent with the type parameter of the visitor.

Specified by:
accept in class SqlNode

equalsDeep

public boolean equalsDeep(SqlNode node,
                          boolean fail)
Description copied from class: SqlNode
Returns whether this node is structurally equivalent to another node. Some examples:

Specified by:
equalsDeep in class SqlNode

toArray

public SqlNode[] toArray()

isEmptyList

public static boolean isEmptyList(SqlNode node)

validateExpr

public void validateExpr(SqlValidator validator,
                         SqlValidatorScope scope)
Description copied from class: SqlNode
Validates this node in an expression context.

Usually, this method does much the same as SqlNode.validate(org.eigenbase.sql.validate.SqlValidator, org.eigenbase.sql.validate.SqlValidatorScope), but a SqlIdentifier can occur in expression and non-expression contexts.

Overrides:
validateExpr in class SqlNode