Package gudusoft.gsqlparser.nodes
Class TConstant
Object
gudusoft.gsqlparser.nodes.TParseTreeNode
gudusoft.gsqlparser.nodes.TConstant
- All Implemented Interfaces:
Visitable,Iterator<TSourceToken>
SQL constant (sometimes called a literal) specifies a value.
Constants are classified as:
- string(text) constants
- numeric constants,Numeric constants are further classified as integer, floating-point, or decimal
- datetime constants
- interval constants
- boolean constants
getLiteralType() returns the type of this constant, getValueToken() returns the value of this constant.
TParseTreeNode.toString() returns the text of this constant.-
Field Summary
Fields inherited from class gudusoft.gsqlparser.nodes.TParseTreeNode
dbvendor, doubleLinkedTokenListToString, nodeActionAppend, nodeActionInsert, nodeActionRemove, nodeActionUnknown, nodeActionUpdate, nodeActionUpdateText, nodeChangeEndToken, nodeChangeStartToken -
Constructor Summary
ConstructorsConstructorDescriptionTConstant(ELiteralType pLiteralType) Class constructor, set the type of this constant while creating a new instance of the constantTConstant(ELiteralType literalType, TSourceToken valueToken) Class constructor, set the type and value of this constant when creating a new instance of the constantTConstant(ELiteralType literalType, TSourceToken valueToken, EIntervalType intervalType) Class constructor, set the type and value of this constant when creating a new instance of the constant. -
Method Summary
Modifier and TypeMethodDescriptionvoidAccept a visitorvoidAccept a visitor to iterate this class and sub-nodes of this classvoidaddIntervalTypeByDummy(TDummy dummy) static TConstantcreateConstant(ELiteralType literalType, String valueStr) getBind1()getBind2()Constants can be specified with explicit types.the number of digits in the fractional part of the SECOND datetime field in a interval day to second constant.BigQuery interval literal int64_expressionOracle interval year to month and interval day to second constant.the maximum number of digits in the leading field of a interval constant.get type of this constant, can be strings, integers, and floating point numbers and more.getSign()The '+' or '-' before this constant.String list constant in Hive.Deprecated.getValue()Deprecated.The value of this constant represented by a source token.voidInitialize a query tree node.voidvoidvoidvoidsetBind1(TSourceToken bind1) voidsetBind2(TSourceToken bind2) voidsetCastType(TTypeName castType) Set the explicit type of this constantvoidsetFractionalSecondsPrecision(TSourceToken fractionalSecondsPrecision) set the fractional precision which is the number of digits in the fractional part of the SECOND datetime field in a interval day to second constant.voidsetIndicator(TSourceToken indicator) voidsetIntervalType(EIntervalType intervalType) Set the sub-type of interval constantvoidsetLeadingPrecision(TSourceToken leadingPrecision) set the precision which is the maximum number of digits in the leading field of a interval constant.voidsetLiteralType(ELiteralType literalType) The type of this constant.voidvoidsetSign(TSourceToken sign) The '+' or '-' before this constant.voidsetSignToken(TSourceToken signToken) voidsetStringLiteralSequence(TSourceTokenList stringLiteralSequence) voidsetValueToken(TSourceToken valueToken) set value of this constantMethods inherited from class gudusoft.gsqlparser.nodes.TParseTreeNode
addAllMyTokensToTokenList, addToTokenChain, appendNewNode, calculateTokenCount, doAppendNewNode, doParse, fastSetString, getAnchorNode, getColumnNo, getCommentAfterNode, getCommentBeforeNode, getCompactString, getDummyTag, getEndToken, getEvaluateDatatype, getEvalValue, getGsqlparser, getLineNo, getLocation, getMd5, getNodeStatus, getNodeType, getParentObjectName, getPlainText, getStartToken, getTokenCount, hasNext, init, init, insertAfterAToken, insertNewNodeBeforeMe, isChanged, isTokensInChain, next, refreshAllNodesTokenCount, remove, removeAllMyTokensFromTokenList, removeTokens, removeTokensBetweenNodes, removeTokensBetweenToken, replaceWithNewNode, resetIterator, setAnchorNode, setChanged, setDummyTag, setEndToken, setEndToken, setEndToken, setEndToken, setEndToken, setEndTokenDirectly, setEvaluateDatatype, setEvalValue, setGsqlparser, setIncludingComment, setLocation, setNewSubNode, setNodeStatus, setNodeType, setParent, setPlainText, setStartToken, setStartToken, setStartToken, setStartToken, setStartTokenDirectly, setString, setString2, subNodeInNode, toScript, toString, toString2Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
TConstant
public TConstant() -
TConstant
Class constructor, set the type of this constant while creating a new instance of the constant- Parameters:
pLiteralType- type of this constant
-
TConstant
Class constructor, set the type and value of this constant when creating a new instance of the constant- Parameters:
literalType- type of this constantvalueToken- value of this constant
-
TConstant
Class constructor, set the type and value of this constant when creating a new instance of the constant. set the sub-type of an interval constant.- Parameters:
literalType- type of this constant, must be etIntervalvalueToken- value of this constantintervalType- sub-type of an interval constant
-
-
Method Details
-
getIntegerValue
-
getKeyValues
-
setCastType
Set the explicit type of this constant- Parameters:
castType- explicit type- See Also:
-
setLiteralType
-
getCastType
Constants can be specified with explicit types. This method returns the explicit type. In PostgreSQL, a constant of an arbitrary type can be entered using any one of the following notations:type 'string' 'string'::type CAST 'string' AS type- Returns:
- explicit type for this constant
-
setSignToken
-
getSignToken
-
setIntervalType
Set the sub-type of interval constant- Parameters:
intervalType- sub-type of interval constant- See Also:
-
getIntervalType
Oracle interval year to month and interval day to second constant. This method return sub-type of interval constant such as year to month, minute to second.- Returns:
- sub-type of interval constant
-
setValueToken
set value of this constantINTERVAL '30.12345' SECOND(2,4)'30.12345' in the above SQL in the valueToken- Parameters:
valueToken- value of this constant
-
setLeadingPrecision
set the precision which is the maximum number of digits in the leading field of a interval constant.INTERVAL '400 5' DAY(3) TO HOUR3 in the above SQL is theleadingPrecision- Parameters:
leadingPrecision- the precision of the leading field
-
setFractionalSecondsPrecision
set the fractional precision which is the number of digits in the fractional part of the SECOND datetime field in a interval day to second constant.INTERVAL '30.12345' SECOND(2,4)4 in the above SQL is thefractionalSecondsPrecision, 2 is theleadingPrecision- Parameters:
fractionalSecondsPrecision-
-
getLeadingPrecision
the maximum number of digits in the leading field of a interval constant.INTERVAL '400 5' DAY(3) TO HOUR3 in the above SQL is theleadingPrecision- Returns:
- the leading precision
-
getFractionalSecondsPrecision
the number of digits in the fractional part of the SECOND datetime field in a interval day to second constant.INTERVAL '30.12345' SECOND(2,4)4 in the above SQL is thefractionalSecondsPrecision, 2 is theleadingPrecision- Returns:
- the fractional seconds precision
-
getValue
Deprecated.- Returns:
- text value of this constant without quote characters
-
getStringValue
Deprecated.since 1.8.2.4, usegetValue()instead.- Returns:
- text value of this constant
-
getLiteralType
get type of this constant, can be strings, integers, and floating point numbers and more. Please checkELiteralTypefor more type of constant- Returns:
- type of this constant
-
setStringLiteralSequence
-
getStringLiteralSequence
String list constant in Hive.- Returns:
- a sequence of source token
-
setSign
The '+' or '-' before this constant. Valid only whengetLiteralType()isELiteralType.etNumber- Parameters:
sign- the '+' or '-' token
-
getSign
The '+' or '-' before this constant. Valid only whengetLiteralType()isELiteralType.etNumber- Returns:
- the '+' or '-' token
-
getValueToken
The value of this constant represented by a source token.- Returns:
- the value of this constant
-
accept
Description copied from class:TParseTreeNodeAccept a visitor- Specified by:
acceptin interfaceVisitable- Overrides:
acceptin classTParseTreeNode- Parameters:
v- visitor is a descendant class ofTParseTreeVisitor
-
acceptChildren
Description copied from class:TParseTreeNodeAccept a visitor to iterate this class and sub-nodes of this class- Specified by:
acceptChildrenin interfaceVisitable- Overrides:
acceptChildrenin classTParseTreeNode- Parameters:
v- visitor is a descendant class ofTParseTreeVisitor
-
init
Description copied from class:TParseTreeNodeInitialize a query tree node. Used internally- Overrides:
initin classTParseTreeNode- Parameters:
arg1- first argument
-
setLiteralType
The type of this constant.The most used type are: etNumber,etFloat,etString,etTimestamp,etDate,etInterval
- Parameters:
literalType- the type of this constant
-
createConstant
-
init
- Overrides:
initin classTParseTreeNode
-
setBind1
-
setBind2
-
setIndicator
-
getBind1
-
getBind2
-
getIndicator
-
getIntervalValueTokens
-
getIntervalTypes
-
addIntervalTypeByDummy
-
init
- Overrides:
initin classTParseTreeNode
-
init
- Overrides:
initin classTParseTreeNode
-
getInt64_expression
BigQuery interval literal int64_expression- Returns:
- BigQuery interval literal int64_expression
-
getValue()instead.