|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.sql.SqlNode org.eigenbase.sql.SqlIdentifier
public class SqlIdentifier
A SqlIdentifier
is an identifier, possibly compound.
Field Summary | |
---|---|
(package private) SqlCollation |
collation
This identifier's collation (if any). |
private SqlParserPos[] |
componentPositions
A list of the positions of the components of compound identifiers. |
String[] |
names
Array of the components of this compound identifier. |
Fields inherited from class org.eigenbase.sql.SqlNode |
---|
emptyArray |
Constructor Summary | |
---|---|
SqlIdentifier(String[] names,
SqlCollation collation,
SqlParserPos pos,
SqlParserPos[] componentPositions)
Creates a compound identifier, for example foo.bar . |
|
SqlIdentifier(String[] names,
SqlParserPos pos)
|
|
SqlIdentifier(String name,
SqlCollation collation,
SqlParserPos pos)
Creates a simple identifier, for example foo , with a
collation. |
|
SqlIdentifier(String name,
SqlParserPos pos)
Creates a simple identifier, for example foo . |
Method Summary | ||
---|---|---|
|
accept(SqlVisitor<R> visitor)
Accepts a generic visitor. |
|
void |
assignNamesFrom(SqlIdentifier other)
Copies names and components from another identifier. |
|
SqlNode |
clone(SqlParserPos pos)
Clones a SqlNode with a different position. |
|
boolean |
equalsBaseName(String name)
|
|
boolean |
equalsDeep(SqlNode node,
boolean fail)
Returns whether this node is structurally equivalent to another node. |
|
SqlCollation |
getCollation()
|
|
SqlIdentifier |
getComponent(int ordinal)
Creates an identifier which contains only the ordinal th
component of this compound identifier. |
|
SqlParserPos |
getComponentParserPosition(int i)
Returns the position of the i th component of a compound
identifier, or the position of the whole identifier if that information
is not present. |
|
SqlKind |
getKind()
Returns the type of node this is, or SqlKind.Other if it's nothing special. |
|
SqlMonotonicity |
getMonotonicity(SqlValidatorScope scope)
Returns whether expression is always ascending, descending or constant. |
|
String |
getSimple()
|
|
boolean |
isSimple()
Returns whether this is a simple identifier. |
|
boolean |
isStar()
Returns whether this identifier is a star, such as "*" or "foo.bar.*". |
|
void |
setNames(String[] names,
SqlParserPos[] poses)
Deprecated. Identifiers should be immutable |
|
String |
toString()
|
|
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, getParserPosition, isA, toSqlString, toSqlString |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public String[] names
It's convenient to have this member public, and it's convenient to
have this member not-final, but it's a shame it's public and not-final.
If you assign to this member, please use setNames(String[],
SqlParserPos[])
. And yes, we'd like to make identifiers immutable one
day.
SqlCollation collation
private SqlParserPos[] componentPositions
Constructor Detail |
---|
public SqlIdentifier(String[] names, SqlCollation collation, SqlParserPos pos, SqlParserPos[] componentPositions)
foo.bar
.
names
- Parts of the identifier, length >= 1public SqlIdentifier(String[] names, SqlParserPos pos)
public SqlIdentifier(String name, SqlCollation collation, SqlParserPos pos)
foo
, with a
collation.
public SqlIdentifier(String name, SqlParserPos pos)
foo
.
Method Detail |
---|
public SqlKind getKind()
SqlNode
SqlKind.Other
if it's nothing special.
getKind
in class SqlNode
SqlKind
value, never nullpublic SqlNode clone(SqlParserPos pos)
SqlNode
clone
in class SqlNode
public String toString()
toString
in class SqlNode
public void setNames(String[] names, SqlParserPos[] poses)
names
- Names of componentsposes
- Positions of componentspublic SqlParserPos getComponentParserPosition(int i)
i
th component of a compound
identifier, or the position of the whole identifier if that information
is not present.
i
- Ordinal of component.
public void assignNamesFrom(SqlIdentifier other)
other
- identifer from which to copypublic SqlIdentifier getComponent(int ordinal)
ordinal
th
component of this compound identifier. It will have the correct SqlParserPos
, provided that detailed position information is available.
public void unparse(SqlWriter writer, int leftPrec, int rightPrec)
SqlNode
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)
.
unparse
in class SqlNode
writer
- Target writerleftPrec
- The precedence of the SqlNode
immediately
preceding this node in a depth-first scan of the parse treerightPrec
- The precedence of the SqlNode
immediatelypublic void validate(SqlValidator validator, SqlValidatorScope scope)
SqlNode
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.
validate
in class SqlNode
scope
- Validatorpublic void validateExpr(SqlValidator validator, SqlValidatorScope scope)
SqlNode
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.
validateExpr
in class SqlNode
public boolean equalsDeep(SqlNode node, boolean fail)
SqlNode
equalsDeep
in class SqlNode
public <R> R accept(SqlVisitor<R> visitor)
SqlNode
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.
accept
in class SqlNode
public SqlCollation getCollation()
public String getSimple()
public boolean isStar()
public boolean isSimple()
public SqlMonotonicity getMonotonicity(SqlValidatorScope scope)
SqlNode
The default implementation returns SqlMonotonicity.NotMonotonic
.
getMonotonicity
in class SqlNode
public boolean equalsBaseName(String name)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |