public abstract class TParseTreeNode extends Object implements Visitable, Iterator<TSourceToken>
The syntax node usually includes sub-nodes such as a where clause including expression node.
Check getNodeType()
for type of this node.
This node includes all tokens from start token
and end token
Modifier and Type | Field and Description |
---|---|
EDbVendor |
dbvendor
SQL dialect of this statement.
|
static boolean |
doubleLinkedTokenListToString |
static int |
nodeActionAppend |
static int |
nodeActionInsert |
static int |
nodeActionRemove |
static int |
nodeActionUnknown |
static int |
nodeActionUpdate |
static int |
nodeActionUpdateText |
static int |
nodeChangeEndToken |
static int |
nodeChangeStartToken |
Constructor and Description |
---|
TParseTreeNode() |
Modifier and Type | Method and Description |
---|---|
void |
accept(TParseTreeVisitor v)
Accept a visitor
|
void |
acceptChildren(TParseTreeVisitor v)
Accept a visitor to iterate this class and sub-nodes of this class
|
int |
addAllMyTokensToTokenList(TSourceTokenList targetList,
int index)
Deprecated.
since v1.8.8.0, use scriptWriter technology to modify the node
Inserts tokens(from start token to end token ) of this parse tree node at the specified position in this
list. Shifts the element currently at that position (if any) and
any subsequent elements to the right .
|
void |
addToTokenChain(TSourceToken anchorToken,
boolean beforeAnchorToken) |
void |
appendNewNode(TParseTreeNode newNode,
boolean needCommaBefore) |
void |
calculateTokenCount() |
protected void |
doAppendNewNode(TParseTreeNode newNode,
TParseTreeNode anchorNode,
boolean needCommaBefore) |
void |
doParse(TCustomSqlStatement psql,
ESqlClause plocation)
Analyze the sub-nodes inside this node.
|
void |
fastSetString(String sqlSegment) |
TParseTreeNode |
getAnchorNode() |
long |
getColumnNo()
Column position of the first token of this node
|
String |
getCommentAfterNode() |
String |
getCommentBeforeNode()
return null if no comment is found before this node.
|
String |
getCompactString()
representation of this node by removing all spaces, return and comments
|
int |
getDummyTag()
A temporary value can be used for any purposes
|
TSourceToken |
getEndToken()
The last token of the node
|
Class<?> |
getEvaluateDatatype()
Support String, Integer, Double and Boolean type
|
Object |
getEvalValue() |
TGSqlParser |
getGsqlparser()
The parser that generate this node.
|
long |
getLineNo()
Line number of the first token of this node
|
ESqlClause |
getLocation()
SQL clause that include this objectName such as select list, from clause, set clause
|
String |
getMd5()
md5 hash code of the string representation of this node.
|
ENodeStatus |
getNodeStatus() |
int |
getNodeType()
A unique value to distinguish this node from others
|
TParseTreeNode |
getParentObjectName() |
String |
getPlainText() |
TSourceToken |
getStartToken()
The first token in this parse tree node
|
int |
getTokenCount() |
boolean |
hasNext() |
void |
init(Object arg1)
Initialize a query tree node.
|
void |
init(Object arg1,
Object arg2) |
void |
init(Object arg1,
Object arg2,
Object arg3) |
void |
init(Object arg1,
Object arg2,
Object arg3,
Object arg4) |
void |
init(Object arg1,
Object arg2,
Object arg3,
Object arg4,
Object arg5) |
void |
init(Object arg1,
Object arg2,
Object arg3,
Object arg4,
Object arg5,
Object arg6) |
void |
insertAfterAToken(TSourceToken anchorToken) |
void |
insertNewNodeBeforeMe(TParseTreeNode newNode,
boolean needCommaBefore) |
boolean |
isChanged()
Detect wether this node is modified by checking all tokens included in this node.
|
boolean |
isTokensInChain() |
TSourceToken |
next() |
void |
refreshAllNodesTokenCount() |
void |
remove() |
protected int |
removeAllMyTokensFromTokenList(TSourceToken additionalToken)
Deprecated.
since v1.8.8.0, use scriptWriter technology to modify the node
|
void |
removeTokens() |
static void |
removeTokensBetweenNodes(TParseTreeNode startNode,
TParseTreeNode endNode) |
static void |
removeTokensBetweenToken(TSourceToken startToken,
TSourceToken endToken)
both begin and end token will be removed from the chain
|
void |
replaceWithNewNode(TParseTreeNode newNode) |
void |
resetIterator() |
void |
setAnchorNode(TParseTreeNode anchorNode) |
void |
setChanged() |
void |
setDummyTag(int dummyTag) |
void |
setEndToken(ArrayList endNode) |
void |
setEndToken(TFromTableList endNode) |
void |
setEndToken(TParseTreeNode endNode) |
void |
setEndToken(TSourceToken newEndToken) |
void |
setEndToken(TSourceTokenList endTokenList) |
void |
setEndTokenDirectly(TSourceToken newEndToken) |
void |
setEvaluateDatatype(Class<?> evaluateDatatype) |
void |
setEvalValue(Object evalValue) |
void |
setGsqlparser(TGSqlParser gsqlparser) |
void |
setIncludingComment(boolean includingComment) |
void |
setLocation(ESqlClause location) |
void |
setNewSubNode(TParseTreeNode oldSubNode,
TParseTreeNode newSubNode,
TParseTreeNode anchorNode) |
void |
setNodeStatus(ENodeStatus nodeStatus) |
void |
setNodeType(int nodeType)
Set the node type for this node.
|
void |
setParent(TParseTreeNode parent) |
void |
setPlainText(String plainText) |
void |
setStartToken(ArrayList startNode) |
void |
setStartToken(TParseTreeNode startNode) |
void |
setStartToken(TSourceToken newStartToken) |
void |
setStartToken(TSourceTokenList startTokenList) |
void |
setStartTokenDirectly(TSourceToken newStartToken) |
void |
setString(String sqlSegment)
Set the text of the node and update the corresponding source tokens synchronously.
|
void |
setString2(String sqlSegment)
Deprecated.
since v1.8.8.0, use scriptWriter technology to modify the node
Set the new string text of a node will destroy all the sub-node structure
|
static boolean |
subNodeInNode(TParseTreeNode subNode,
TParseTreeNode wholeNode) |
String |
toScript()
Return the text string of this node, the return value is the same as
toString() if this node is not modified manually
after created by parser. |
String |
toString()
The returned text is formed by concatenating the source tokens contained in this node one by one.
|
String |
toString2()
String representation of this parse tree node.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEachRemaining
public static boolean doubleLinkedTokenListToString
public static final int nodeActionUnknown
public static final int nodeActionRemove
public static final int nodeActionInsert
public static final int nodeActionUpdate
public static final int nodeActionUpdateText
public static final int nodeActionAppend
public static final int nodeChangeStartToken
public static final int nodeChangeEndToken
public TParseTreeNode()
public void setEvaluateDatatype(Class<?> evaluateDatatype)
public Class<?> getEvaluateDatatype()
public void setEvalValue(Object evalValue)
public Object getEvalValue()
public void setPlainText(String plainText)
public String getPlainText()
public void setLocation(ESqlClause location)
public ESqlClause getLocation()
public String getCompactString()
public String getMd5()
public TParseTreeNode getParentObjectName()
public void setParent(TParseTreeNode parent)
public void insertAfterAToken(TSourceToken anchorToken)
public void insertNewNodeBeforeMe(TParseTreeNode newNode, boolean needCommaBefore)
public void appendNewNode(TParseTreeNode newNode, boolean needCommaBefore)
public void replaceWithNewNode(TParseTreeNode newNode)
public void resetIterator()
public boolean hasNext()
hasNext
in interface Iterator<TSourceToken>
public TSourceToken next()
next
in interface Iterator<TSourceToken>
public void remove()
remove
in interface Iterator<TSourceToken>
public void setNodeStatus(ENodeStatus nodeStatus)
public ENodeStatus getNodeStatus()
public void addToTokenChain(TSourceToken anchorToken, boolean beforeAnchorToken)
public int getTokenCount()
public void refreshAllNodesTokenCount()
public void calculateTokenCount()
public static void removeTokensBetweenToken(TSourceToken startToken, TSourceToken endToken)
startToken
- endToken
- public static void removeTokensBetweenNodes(TParseTreeNode startNode, TParseTreeNode endNode)
public void removeTokens()
public TGSqlParser getGsqlparser()
public void setIncludingComment(boolean includingComment)
public void setGsqlparser(TGSqlParser gsqlparser)
public void setDummyTag(int dummyTag)
public int getDummyTag()
public TSourceToken getStartToken()
public TSourceToken getEndToken()
public long getColumnNo()
public long getLineNo()
public void setNodeType(int nodeType)
nodeType
- The node type.public int getNodeType()
ENodeType
public void init(Object arg1)
arg1
- first argumentpublic void doParse(TCustomSqlStatement psql, ESqlClause plocation)
psql
- SQL statement this node belongs toplocation
- SQL clause this node belongs topublic void setStartToken(ArrayList startNode)
public void setEndToken(ArrayList endNode)
public void setStartToken(TSourceToken newStartToken)
public void setStartToken(TSourceTokenList startTokenList)
public void setStartToken(TParseTreeNode startNode)
public void setStartTokenDirectly(TSourceToken newStartToken)
public void setEndTokenDirectly(TSourceToken newEndToken)
public void setEndToken(TSourceToken newEndToken)
public void setEndToken(TSourceTokenList endTokenList)
public void setEndToken(TFromTableList endNode)
public void setEndToken(TParseTreeNode endNode)
public void setString2(String sqlSegment)
sqlSegment
- that override original text of this node.public void setString(String sqlSegment)
sqlSegment
- public void fastSetString(String sqlSegment)
public String getCommentBeforeNode()
public String getCommentAfterNode()
public String toString2()
This string was generated by collecting text from the start token of this node to the end token of this node.
If this node was modified, then use toScript()
to get string representation of this node.
public String toString()
public boolean isTokensInChain()
public int addAllMyTokensToTokenList(TSourceTokenList targetList, int index)
targetList
- the new list of source tokensindex
- the position insert the targetListprotected int removeAllMyTokensFromTokenList(TSourceToken additionalToken)
additionalToken
- usually was comma before or after this parse tree node that also need to be deletedpublic void accept(TParseTreeVisitor v)
accept
in interface Visitable
v
- visitor is a descendant class of TParseTreeVisitor
public void acceptChildren(TParseTreeVisitor v)
acceptChildren
in interface Visitable
v
- visitor is a descendant class of TParseTreeVisitor
public String toScript()
toString()
if this node is not modified manually
after created by parser.
toString()
method.public void setChanged()
public boolean isChanged()
protected void doAppendNewNode(TParseTreeNode newNode, TParseTreeNode anchorNode, boolean needCommaBefore)
public void setAnchorNode(TParseTreeNode anchorNode)
public TParseTreeNode getAnchorNode()
public void setNewSubNode(TParseTreeNode oldSubNode, TParseTreeNode newSubNode, TParseTreeNode anchorNode)
public static boolean subNodeInNode(TParseTreeNode subNode, TParseTreeNode wholeNode)