gudusoft.gsqlparser
Class TSourceToken

java.lang.Object
  extended by gudusoft.gsqlparser.TSourceToken

public class TSourceToken
extends java.lang.Object

Source token is the basic syntactical unit of SQL. A token is a sequence of one or more characters. A token can be an identifier, a constant, a special charactor or an operator. TSourceToken is the basic element of other classes such as TConstant, TObjectName.


Field Summary
 TSourceToken alternativeToken
           
 java.lang.String astext
          Text representation for current token.
 long columnNo
          the column number of the first character for current token.
 TSourceTokenList container
          Container for current token.
 long lineNo
          the line number of the first character for current token.
 long offset
           
 int posinlist
          Position in the container, start from 0
 TCustomSqlStatement stmt
          position in activeTokenList, start from 0
 int tag
           
 int tokencode
          Numberic code of this token used by parser internally.
 ETokenStatus tokenstatus
           
 ETokenType tokentype
           
 
Constructor Summary
TSourceToken()
           
TSourceToken(java.lang.String s)
           
 
Method Summary
 TSourceToken getAlternativeToken()
          If you find a start token of parse tree node has an alternativetoken,
 int getDbObjType()
           
 EDbVendor getDbvendor()
           
 TGSqlParser getGsqlparser()
           
 TParseTreeNodeList getNodesEndWithThisToken()
           
 TParseTreeNodeList getNodesStartFromThisToken()
           
 TSourceToken getReplaceToken()
           
 TSourceTokenList getTokensAfter()
           
 TSourceTokenList getTokensBefore()
           
 boolean isnonsolidtoken()
          Is current token a solid token or not.
static boolean isnonsolidtoken(ETokenType tokentype)
          Token except ttwhitespace,ttreturn,ttsimplecomment,ttbracketedcomment is solid token.
 boolean issolidtoken()
          Is current token a non-solid token or not.
 int removeMyFromTokenList()
           
 TSourceToken searchToken(int targetTokenCode, int range)
           
 TSourceToken searchToken(java.lang.String targetTokenText, int range)
           
 void setAlternativeToken(TSourceToken alternativeToken)
           
 void setDbObjType(int dbObjType)
           
 void setDbvendor(EDbVendor dbvendor)
           
 void setGsqlparser(TGSqlParser gsqlparser)
           
 void setReplaceToken(TSourceToken replaceToken)
           
 void setString(java.lang.String str)
          set new string of this token
 java.lang.String toString()
          Original text for current token.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tokencode

public int tokencode
Numberic code of this token used by parser internally.


lineNo

public long lineNo
the line number of the first character for current token.


columnNo

public long columnNo
the column number of the first character for current token.


offset

public long offset

tokentype

public ETokenType tokentype

container

public TSourceTokenList container
Container for current token.


posinlist

public int posinlist
Position in the container, start from 0


astext

public java.lang.String astext
Text representation for current token.


tokenstatus

public ETokenStatus tokenstatus

stmt

public TCustomSqlStatement stmt
position in activeTokenList, start from 0


tag

public int tag

alternativeToken

public TSourceToken alternativeToken
Constructor Detail

TSourceToken

public TSourceToken()

TSourceToken

public TSourceToken(java.lang.String s)
Method Detail

getGsqlparser

public TGSqlParser getGsqlparser()

setGsqlparser

public void setGsqlparser(TGSqlParser gsqlparser)

getNodesEndWithThisToken

public TParseTreeNodeList getNodesEndWithThisToken()

getNodesStartFromThisToken

public TParseTreeNodeList getNodesStartFromThisToken()

setDbObjType

public void setDbObjType(int dbObjType)

getDbObjType

public int getDbObjType()

setAlternativeToken

public void setAlternativeToken(TSourceToken alternativeToken)

getAlternativeToken

public TSourceToken getAlternativeToken()

If you find a start token of parse tree node has an alternativetoken,

then text of this node should be modified by using TParseTreeNode.setString(String sqlSegment)

1. new string will be tokenized into a list of source tokens: stlist

2. link alternativetoken of start token of this node to the first token in stlist generated in step 1.

3. link back alternativetoken of last token in stlist to the last token of this node.


setDbvendor

public void setDbvendor(EDbVendor dbvendor)

getDbvendor

public EDbVendor getDbvendor()
Returns:
dbvendor of this source token

setString

public void setString(java.lang.String str)
set new string of this token

Parameters:
str -

toString

public java.lang.String toString()
Original text for current token.

Overrides:
toString in class java.lang.Object
Returns:
Original token text.

isnonsolidtoken

public static boolean isnonsolidtoken(ETokenType tokentype)
Token except ttwhitespace,ttreturn,ttsimplecomment,ttbracketedcomment is solid token.

Parameters:
tokentype -
Returns:
True if token type is not one of ttwhitespace,ttreturn,ttsimplecomment,ttbracketedcomment

isnonsolidtoken

public boolean isnonsolidtoken()
Is current token a solid token or not.

Returns:
true if it's a non-solid token.

issolidtoken

public boolean issolidtoken()
Is current token a non-solid token or not.

Returns:
true if it's a solid token.

getTokensAfter

public TSourceTokenList getTokensAfter()

getTokensBefore

public TSourceTokenList getTokensBefore()

setReplaceToken

public void setReplaceToken(TSourceToken replaceToken)

getReplaceToken

public TSourceToken getReplaceToken()

searchToken

public TSourceToken searchToken(int targetTokenCode,
                                int range)

searchToken

public TSourceToken searchToken(java.lang.String targetTokenText,
                                int range)

removeMyFromTokenList

public int removeMyFromTokenList()