Class SqlNodeList
- java.lang.Object
-
- org.apache.calcite.sql.SqlNode
-
- org.apache.calcite.sql.SqlNodeList
-
-
Field Summary
Fields Modifier and Type Field Description static SqlNodeList
EMPTY
An immutable, empty SqlNodeList.private java.util.List<SqlNode>
list
-
Fields inherited from class org.apache.calcite.sql.SqlNode
EMPTY_ARRAY, pos
-
-
Constructor Summary
Constructors Constructor Description SqlNodeList(java.util.Collection<? extends SqlNode> collection, SqlParserPos pos)
Creates aSqlNodeList
containing the nodes inlist
.SqlNodeList(SqlParserPos pos)
Creates an emptySqlNodeList
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <R> R
accept(SqlVisitor<R> visitor)
Accepts a generic visitor.void
add(SqlNode node)
(package private) void
andOrList(SqlWriter writer, SqlKind sepKind)
SqlNodeList
clone(SqlParserPos pos)
Clones a SqlNode with a different position.(package private) void
commaList(SqlWriter writer)
boolean
equalsDeep(SqlNode node, Litmus litmus)
Returns whether this node is structurally equivalent to another node.SqlNode
get(int n)
java.util.List<SqlNode>
getList()
static boolean
isEmptyList(SqlNode node)
java.util.Iterator<SqlNode>
iterator()
static SqlNodeList
of(SqlNode node1)
static SqlNodeList
of(SqlNode node1, SqlNode node2)
static SqlNodeList
of(SqlNode node1, SqlNode node2, SqlNode... nodes)
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.apache.calcite.sql.SqlNode
clone, clone, cloneArray, equalDeep, equalDeep, equalsDeep, findValidOptions, getKind, getMonotonicity, getParserPosition, isA, toSqlString, toSqlString, toString
-
-
-
-
Field Detail
-
EMPTY
public static final SqlNodeList EMPTY
An immutable, empty SqlNodeList.
-
list
private final java.util.List<SqlNode> list
-
-
Constructor Detail
-
SqlNodeList
public SqlNodeList(SqlParserPos pos)
Creates an emptySqlNodeList
.
-
SqlNodeList
public SqlNodeList(java.util.Collection<? extends SqlNode> collection, SqlParserPos pos)
Creates aSqlNodeList
containing the nodes inlist
. The list is copied, but the nodes in it are not.
-
-
Method Detail
-
iterator
public java.util.Iterator<SqlNode> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<SqlNode>
-
getList
public java.util.List<SqlNode> getList()
-
add
public void add(SqlNode node)
-
clone
public SqlNodeList clone(SqlParserPos pos)
Description copied from class:SqlNode
Clones a SqlNode with a different position.
-
get
public SqlNode get(int n)
-
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
andrightPrec
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.apache.calcite.sql.SqlWriter, int, int)
.
-
commaList
void commaList(SqlWriter writer)
-
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.apache.calcite.sql.SqlLiteral)
for these purposes.
-
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 thevisitor object
.The type parameter
R
must be consistent with the type parameter of the visitor.
-
equalsDeep
public boolean equalsDeep(SqlNode node, Litmus litmus)
Description copied from class:SqlNode
Returns whether this node is structurally equivalent to another node. Some examples:- 1 + 2 is structurally equivalent to 1 + 2
- 1 + 2 + 3 is structurally equivalent to (1 + 2) + 3, but not to 1 + (2 + 3), because the '+' operator is left-associative
- Specified by:
equalsDeep
in classSqlNode
-
toArray
public SqlNode[] toArray()
-
isEmptyList
public static boolean isEmptyList(SqlNode node)
-
of
public static SqlNodeList of(SqlNode node1)
-
of
public static SqlNodeList of(SqlNode node1, SqlNode node2)
-
of
public static SqlNodeList of(SqlNode node1, SqlNode node2, SqlNode... nodes)
-
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.apache.calcite.sql.validate.SqlValidator, org.apache.calcite.sql.validate.SqlValidatorScope)
, but aSqlIdentifier
can occur in expression and non-expression contexts.- Overrides:
validateExpr
in classSqlNode
-
-