public class TObjectName extends TParseTreeNode
The general syntax of database object in Oracle: [schema.]object[.part][@dblink]
The general syntax of database object in SQL Server: [server.][database.][schema.]object
The meaning of getObjectToken()
and getPartToken()
depends on the getDbObjectType()
.
If this database object is a schema object such as table, index, then the objectToken represents this
database object and partToken is null.
If this TObjectName represents a column, the partToken represents the column name, the objectToken is table/view
name of this column if this column is qualified like table.column
, otherwise, the objectToken is
null.
schemaToken, databaseToken, serverToken is the qualified part of a database object name.
If this objectName represents a database name in the create database statement like this
CREATE DATABASE menagerie
, then, the objectToken is menagerie and databaseToken is null.
EDbObjectType
Modifier and Type | Field and Description |
---|---|
int |
searchLevel
Internal use only
|
static int |
ttobjAliasName
Deprecated.
replaced by
EDbObjectType .
alias name in objectToken |
static int |
ttobjAttribute
Deprecated.
replaced by
EDbObjectType .
attribute name is in partToken |
static int |
ttobjColumn
Deprecated.
replaced by
EDbObjectType .
column in table, objectToken is table if specified, and partToken is column name. |
static int |
ttobjColumnAlias
Deprecated.
replaced by
EDbObjectType .
column alias in objectToken. |
static int |
ttobjColumnMethod
Deprecated.
replaced by
EDbObjectType .
column method like SetXY below, column method in methodToken , and colomn name in partToken .
UPDATE Cities SET Location.SetXY(23.5, 23.5) |
static int |
ttobjConstraintName
Deprecated.
replaced by
EDbObjectType .
constraint name in objectToken |
static int |
ttobjCursorName
Deprecated.
replaced by
EDbObjectType .
cursor name in objectToken |
static int |
ttobjDatabaseName
Deprecated.
replaced by
EDbObjectType .
Database name in objectToken |
static int |
ttobjDatatype
Deprecated.
replaced by
EDbObjectType .
datatype was not represented by a TObjectName object, this constant was used in source tokens that consist of TTypeName. |
static int |
ttobjFieldName
Deprecated.
replaced by
EDbObjectType .
check TExpression.getFieldName() for more |
static int |
ttobjFunctionName
Deprecated.
replaced by
EDbObjectType .
function name in objectToken |
static int |
ttobjIndexName
Deprecated.
replaced by
EDbObjectType .
index name in objectToken |
static int |
ttobjIndexType
Deprecated.
replaced by
EDbObjectType . |
static int |
ttobjLabelName
Deprecated.
replaced by
EDbObjectType .
label name in objectToken |
static int |
ttObjLibrary |
static int |
ttobjMaterializedView
Deprecated.
replaced by
EDbObjectType . |
static int |
ttobjMaterializedViewName
Deprecated.
replaced by
EDbObjectType .
materialized view name in objectToken |
static int |
ttobjMiningModel
Deprecated.
replaced by
EDbObjectType . |
static int |
ttobjMixed
Deprecated.
replaced by
EDbObjectType .
this type is used in TObjectNameList, when objects in TObjectNameList includes more than
one type, objtype of that TObjectNameList was set to ttobjMixed. |
static int |
ttobjNotAObject
Deprecated.
replaced by
EDbObjectType .
this is not an object, like sysdate function in oracle database |
static int |
ttobjOperator
Deprecated.
replaced by
EDbObjectType . |
static int |
ttObjOracleHint |
static int |
ttobjPackage
Deprecated.
replaced by
EDbObjectType .
package name in objectToken |
static int |
ttobjParameter
Deprecated.
replaced by
EDbObjectType .
parameter name in objectToken. |
static int |
ttobjPositionalParameters
Deprecated.
replaced by
EDbObjectType .
postgresql
Positional Parameters, $1, $1[1], $1[1,10]
parameter name is in partToken of $1,
and parameter name is in objectToken of $1.columnName,
and column name is in partToken |
static int |
ttobjProcedureName
Deprecated.
replaced by
EDbObjectType .
procedure name in objectToken |
static int |
ttobjPropertyName
Deprecated.
replaced by
EDbObjectType .
property name in propertyToken |
static int |
ttobjSchemaName
Deprecated.
replaced by
EDbObjectType .
schema name in schemaToken |
static int |
ttobjSequence
Deprecated.
replaced by
EDbObjectType .
Sequence name in objectToken |
static int |
ttobjServerName
Deprecated.
replaced by
EDbObjectType .
server name in serverToken |
static int |
ttobjStringConstant
Deprecated.
replaced by
EDbObjectType .
string constant in objectToken |
static int |
ttobjTable
Deprecated.
replaced by
EDbObjectType .
table name in objectToken. |
static int |
ttObjTableAlias
Deprecated.
replaced by
EDbObjectType .
table alias in objectToken |
static int |
ttobjTableCTE
Deprecated.
replaced by
EDbObjectType .
table name in objectToken. |
static int |
ttobjTablePivot
Deprecated.
replaced by
EDbObjectType . |
static int |
ttobjTableTemp
Deprecated.
replaced by
EDbObjectType .
table name in objectToken. |
static int |
ttobjTableVar
Deprecated.
replaced by
EDbObjectType .
table variable in objectToken. |
static int |
ttobjTransactionName
Deprecated.
replaced by
EDbObjectType .
Transaction name in objectToken |
static int |
ttobjTrigger
Deprecated.
replaced by
EDbObjectType .
Trigger name in objectToken |
static int |
ttobjTypeName
Deprecated.
replaced by
EDbObjectType .
type name in objectToken |
static int |
ttobjUnknown
Deprecated.
replaced by
EDbObjectType .
object type can't be determined. |
static int |
ttobjVariable
Deprecated.
replaced by
EDbObjectType .
variable name in objectToken. |
static int |
ttobjViewName
Deprecated.
replaced by
EDbObjectType .
view name in objectToken |
Constructor and Description |
---|
TObjectName() |
TObjectName(TSourceToken token,
EDbObjectType dbObjectType)
Class constructor specifying object name and object type.
|
TObjectName(TSourceToken pObjectToken,
TSourceToken pPartToken,
EDbObjectType dbObjectType)
Class constructor specifying object, part name and object type.
|
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
|
void |
appendObjectName(TObjectName objectName) |
void |
attributesToPropertyToken(TObjectNameList attributes)
used in Oracle and teradata SQL syntax
|
String |
coordinate()
The X and Y position of this objectName in the SQL
|
TSourceToken |
getAtsign() |
TObjectNameList |
getAttributes()
The data type of this column is structured UDT, this method returns the column's attributes.
|
String |
getColumnNameOnly()
Returns only the column name if it's prefixed with a table name
|
long |
getColumnNo()
The column position of this objectName in the SQL
|
TSourceToken |
getColumnToken()
|
TSourceToken |
getCommentString() |
String |
getDatabaseString()
String text of the database name
|
TSourceToken |
getDatabaseToken()
The database part of this objectName: [server.][database.][schema.]object
|
TObjectName |
getDblink()
The database link part
remoreserver in this objectName: scott.emp@remoreserver |
EDbObjectType |
getDbObjectType()
The database object type of this objectName such as table, view, column for example.
|
TSourceToken |
getExclamationmark() |
TIndirection |
getIndirection()
Array element of this objectName
|
long |
getLineNo()
The line number of this objectName in SQL
|
TColumnDefinition |
getLinkedColumnDef()
The column definition in create/alter table statement that include this column name object.
|
ESqlClause |
getLocation()
SQL clause that include this objectName such as select list, from clause, set clause
|
TSourceToken |
getMethodToken() |
TObjectName |
getNamespace()
The Couchbase namespace before keyspace
|
int |
getNumberOfPart()
List the number of parts made up this objectName
|
String |
getObjectString()
String text of the object name
|
TSourceToken |
getObjectToken()
The object part of this objectName such as table name, view name.
|
int |
getObjectType()
Deprecated.
use
getDbObjectType() instead. |
String |
getPackageString()
String text of the package name.
|
TSourceToken |
getPackageToken()
Oracle package name
|
String |
getPartString()
String text of the part name
|
TSourceToken |
getPartToken()
The column name of this objectName if
getDbObjectType() is EDbObjectType.column . |
TSourceToken |
getPropertyToken() |
EQuoteType |
getQuoteType()
Tell whether this is a quoted objectName.
|
TObjectNameList |
getReferencedObjects() |
String |
getSchemaString()
String text of schema name
|
TSourceToken |
getSchemaToken()
The schema name of this objectName.
|
String |
getServerString()
String text of the server name
|
TSourceToken |
getServerToken()
The server part of this objectName: [server.][database.][schema.]object
|
TSourceToken |
getSortType()
When this object is column in primary key(column,...), unique key(column,...) in sql server
there maybe sort information like column asc, column desc
this token represents for ASC, DESC if specified.
|
TResultColumn |
getSourceColumn()
The result column which include this column
|
TTable |
getSourceTable()
The table this columns belongs to.
|
String |
getStringValue()
This method is not used.
|
String |
getTableString()
String text of the table name
|
TSourceToken |
getTableToken()
The table name of this objectName, it's the same value as
getObjectToken() if getDbObjectType()
is EDbObjectType.table |
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) |
boolean |
isAttributeNameInObjectName(TSourceToken leftparen,
TSourceToken rightparen) |
boolean |
isPrefixed()
Check whether a column is prefixed by a table like this:
table.column |
boolean |
isPrefixedThisTable(TTable pTable)
This column must be in this syntax: table.column, otherwise, this method always return false.
|
boolean |
isReservedKeyword() |
boolean |
isSubscripts()
PostgreSQL column with array types
|
boolean |
isTableDetermined()
Sometime, a non-qualified column can't be linked to a table without additional metadata from database.
|
boolean |
isValidColumnName(EDbVendor pDBVendor)
Check whether a column name is syntax valid in a specific database vendor.
|
void |
mergeObjectName(TObjectName objectName)
Used internally in hive .y file to merge two objectNames
|
void |
mergeObjectName(TObjectName objectName,
TObjectName objectName2) |
void |
setAtsign(TSourceToken atsign) |
void |
setAttributes(TObjectNameList attributes) |
void |
setCommentString(TSourceToken commentString) |
void |
setDatabaseToken(TSourceToken databaseToken) |
void |
setDblink(TObjectName dblink) |
void |
setDbObjectType(EDbObjectType dbObjectType)
Set object type of this objectName
|
void |
setExclamationmark(TSourceToken exclamationmark) |
void |
setIndirection(TIndirection indirection) |
void |
setLinkedColumnDef(TColumnDefinition linkedColumnDef) |
void |
setLocation(ESqlClause location) |
void |
setMethodToken(TSourceToken methodToken) |
void |
setNamespace(TObjectName namespace) |
void |
setObjectToken(TSourceToken objectToken) |
void |
setObjectType(int objectType)
Deprecated.
|
void |
setPackageToken(TSourceToken packageToken) |
void |
setPartToken(TSourceToken partToken) |
void |
setPropertyToken(TSourceToken propertyToken) |
void |
setQuoteType(EQuoteType quoteType) |
void |
setSchemaToken(TSourceToken schemaToken) |
void |
setServerToken(TSourceToken serverToken) |
void |
setSortType(TSourceToken sortType) |
void |
setSourceColumn(TResultColumn sourceColumn)
Set the result column which include this column name.
|
void |
setSourceTable(TTable sourceTable)
Set the table this column belongs to.
|
void |
setStringValue(String stringValue)
This method is not used.
|
void |
setTableDetermined(boolean tableDetermined) |
void |
TObjectName() |
String |
toString()
String representation of this parse tree node.
|
addAllMyTokensToTokenList, appendString, doParse, fastSetString, getDummyTag, getEndToken, getGsqlparser, getNodeType, getStartToken, removeAllMyTokensFromTokenList, setDummyTag, setEndToken, setEndToken, setEndToken, setEndToken, setGsqlparser, setIncludingComment, setNodeType, setStartToken, setStartToken, setStartToken, setStartToken, setString, toScript
public int searchLevel
public static final int ttobjNotAObject
EDbObjectType
.
this is not an object, like sysdate function in oracle databasepublic static final int ttobjUnknown
EDbObjectType
.
object type can't be determined.public static final int ttobjColumn
EDbObjectType
.
column in table, objectToken is table if specified, and partToken is column name.public static final int ttobjColumnAlias
EDbObjectType
.
column alias in objectToken.public static final int ttobjTable
EDbObjectType
.
table name in objectToken.public static final int ttObjTableAlias
EDbObjectType
.
table alias in objectTokenpublic static final int ttobjTableCTE
EDbObjectType
.
table name in objectToken.public static final int ttobjTableTemp
EDbObjectType
.
table name in objectToken.public static final int ttobjTablePivot
EDbObjectType
.public static final int ttobjTableVar
EDbObjectType
.
table variable in objectToken.public static final int ttobjParameter
EDbObjectType
.
parameter name in objectToken.public static final int ttobjVariable
EDbObjectType
.
variable name in objectToken.public static final int ttobjColumnMethod
EDbObjectType
.
column method like SetXY below, column method in methodToken
, and colomn name in partToken
.
UPDATE Cities
SET Location.SetXY(23.5, 23.5)
public static final int ttobjProcedureName
EDbObjectType
.
procedure name in objectToken
public static final int ttobjFunctionName
EDbObjectType
.
function name in objectToken
public static final int ttobjLabelName
EDbObjectType
.
label name in objectToken
public static final int ttobjIndexName
EDbObjectType
.
index name in objectToken
public static final int ttobjMaterializedViewName
EDbObjectType
.
materialized view name in objectToken
public static final int ttobjCursorName
EDbObjectType
.
cursor name in objectToken
public static final int ttobjViewName
EDbObjectType
.
view name in objectToken
public static final int ttobjConstraintName
EDbObjectType
.
constraint name in objectToken
public static final int ttobjPropertyName
EDbObjectType
.
property name in propertyToken
public static final int ttobjTransactionName
EDbObjectType
.
Transaction name in objectToken
public static final int ttobjDatabaseName
EDbObjectType
.
Database name in objectToken
public static final int ttobjStringConstant
EDbObjectType
.
string constant in objectToken
public static final int ttobjTrigger
EDbObjectType
.
Trigger name in objectToken
public static final int ttobjAliasName
EDbObjectType
.
alias name in objectToken
public static final int ttobjAttribute
EDbObjectType
.
attribute name is in partToken
public static final int ttobjTypeName
EDbObjectType
.
type name in objectToken
public static final int ttobjPackage
EDbObjectType
.
package name in objectToken
public static final int ttobjSequence
EDbObjectType
.
Sequence name in objectToken
public static final int ttobjDatatype
EDbObjectType
.
datatype was not represented by a TObjectName object, this constant was used in source tokens that consist of TTypeName.public static final int ttobjSchemaName
EDbObjectType
.
schema name in schemaToken
public static final int ttobjServerName
EDbObjectType
.
server name in serverToken
public static final int ttobjOperator
EDbObjectType
.public static final int ttobjIndexType
EDbObjectType
.public static final int ttobjMaterializedView
EDbObjectType
.public static final int ttobjMiningModel
EDbObjectType
.public static final int ttobjFieldName
EDbObjectType
.
check TExpression.getFieldName()
for morepublic static final int ttobjPositionalParameters
EDbObjectType
.
postgresql
Positional Parameters, $1, $1[1], $1[1,10]
parameter name is in partToken
of $1,
and parameter name is in objectToken
of $1.columnName,
and column name is in partToken
public static final int ttObjOracleHint
public static final int ttObjLibrary
public static final int ttobjMixed
EDbObjectType
.
this type is used in TObjectNameList, when objects in TObjectNameList includes more than
one type, objtype of that TObjectNameList was set to ttobjMixed.public TObjectName()
public TObjectName(TSourceToken token, EDbObjectType dbObjectType)
Use TGSqlParser.parseObjectName(java.lang.String)
to create an objectName more than 2 parts.
token
- name of this objectdbObjectType
- type of this objectpublic TObjectName(TSourceToken pObjectToken, TSourceToken pPartToken, EDbObjectType dbObjectType)
table.column
objectName.
Use TGSqlParser.parseObjectName(java.lang.String)
to create an objectName more than 2 parts.pObjectToken
- name of this object, usually it's the table namepPartToken
- name of the columndbObjectType
- type of this object, usually it's EDbObjectType.column
public boolean isReservedKeyword()
public void setLinkedColumnDef(TColumnDefinition linkedColumnDef)
public TColumnDefinition getLinkedColumnDef()
CREATE TABLE table_name ( column1 datatype, column2 datatype );In above SQL,
column1 datatype
is the column definition while column1
is this
object name.public void setNamespace(TObjectName namespace)
public TObjectName getNamespace()
public String toString()
TParseTreeNode
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 later, then use TParseTreeNode.toScript()
to get string representation of this node.
toString
in class TParseTreeNode
public void setQuoteType(EQuoteType quoteType)
public EQuoteType getQuoteType()
public void setStringValue(String stringValue)
stringValue
- text value of this objectNamepublic String getStringValue()
toString()
or TParseTreeNode.toScript()
instead.public void setSourceColumn(TResultColumn sourceColumn)
sourceColumn
- the result column includes this column namepublic TResultColumn getSourceColumn()
select salary + 1000 from empIn the above SQL,
salary + 1000
is the result column while salary
is this column name.public boolean isPrefixedThisTable(TTable pTable)
pTable
- table used to match getTableToken()
of this column objectpublic boolean isPrefixed()
table.column
table.column
public boolean isValidColumnName(EDbVendor pDBVendor)
rowid
is not a valid column name.pDBVendor
- in which the database vendor the syntax of this column is checkedpublic void setSourceTable(TTable sourceTable)
sourceTable
- table contains this columnpublic TTable getSourceTable()
Please check getTableColumn demo shipped together with this library to find out more information such as column impact and data lineage of the table and column in the SQL script.
public void TObjectName()
public boolean isSubscripts()
CREATE TABLE sal_emp ( name text, pay_by_quarter integer[], schedule text[][] );In the above SQL, this method returns true for
pay_by_quarter
column.public void setIndirection(TIndirection indirection)
public TIndirection getIndirection()
select arraycolumn[4] from t;In the above SQL, this method returns
[4]
of this objectName.TIndirection
public void setPropertyToken(TSourceToken propertyToken)
public TSourceToken getAtsign()
public TSourceToken getMethodToken()
public TSourceToken getPropertyToken()
public TSourceToken getServerToken()
public TSourceToken getExclamationmark()
public TObjectName getDblink()
remoreserver
in this objectName: scott.emp@remoreserverpublic TSourceToken getDatabaseToken()
public void setTableDetermined(boolean tableDetermined)
public boolean isTableDetermined()
select name from emp, deptIn the above SQL, the
name
column can't be determined which table it belongs to.
Below is a more complicated SQL that shows the relationship between column and table.
select s2.s2t1a1, s3.s3t1a1 from ( select * from subselect2table1 s2t1 ) s2, ( select * from subselect3table1, subselect3table2 ) s3column s2t1a1 was linked to subselect2table1,
isTableDetermined()
returns true for this column.
isTableDetermined()
returns false for this column.
Provide database metadata will help GSP links the column to the table correctly.
TGSqlParser.setMetaDatabase(gudusoft.gsqlparser.IMetaDatabase)
public void attributesToPropertyToken(TObjectNameList attributes)
teradata:
column.attribute()
column.attribute().attribute()
attributes
- public void setAttributes(TObjectNameList attributes)
public TObjectNameList getAttributes()
CREATE TYPE school_record AS ( school_name VARCHAR(20), GPA FLOAT); CREATE TYPE college_record AS ( school school_record, major VARCHAR(20), minor VARCHAR(20)); CREATE TABLE student_record ( student_id INTEGER, Last_name VARCHAR(20), First_name VARCHAR(20), high_school school_record, college college_record); SELECT student_id, last_name, first_name, high_school.school_name(), high_school.GPA(), college.school().school_name(), college.school().GPA(), college.major(), college.minor() FROM student_record; SELECT *.ALL FROM student_record; SELECT student_record.*.ALL;Take this column
college.school().school_name()
for example, the partToken of this objectName
should be college
, and the value returned by this method should be
school().school_name()
PLEASE NOTE THAT CURRENT VERSION CAN'T HANDLE THE ABOVE SQL CORRECTLY.
public void setObjectType(int objectType)
setDbObjectType(gudusoft.gsqlparser.EDbObjectType)
insteadobjectType
- object type of this objectNamepublic void setDbObjectType(EDbObjectType dbObjectType)
dbObjectType
- database object typepublic EDbObjectType getDbObjectType()
EDbObjectType.column
, getPartToken()
represents
the column name, for all other object type, the name of this database object is stored in getObjectToken()
public int getObjectType()
getDbObjectType()
instead.public void setAtsign(TSourceToken atsign)
public void setDblink(TObjectName dblink)
public void setServerToken(TSourceToken serverToken)
public void setDatabaseToken(TSourceToken databaseToken)
public void setObjectToken(TSourceToken objectToken)
public void setPartToken(TSourceToken partToken)
public void setMethodToken(TSourceToken methodToken)
public void setSchemaToken(TSourceToken schemaToken)
public void setPackageToken(TSourceToken packageToken)
public TSourceToken getPackageToken()
public void setLocation(ESqlClause location)
public ESqlClause getLocation()
public TSourceToken getObjectToken()
public TSourceToken getPartToken()
getDbObjectType()
is EDbObjectType.column
.
getColumnToken()
returns the same value.public TSourceToken getSchemaToken()
public String getPackageString()
public String getServerString()
public String getDatabaseString()
public String getSchemaString()
public TSourceToken getTableToken()
getObjectToken()
if getDbObjectType()
is EDbObjectType.table
public String getTableString()
public String getObjectString()
public String getPartString()
public void setExclamationmark(TSourceToken exclamationmark)
public int getNumberOfPart()
public void init(Object arg1)
TParseTreeNode
init
in class TParseTreeNode
arg1
- first argumentpublic void init(Object arg1, Object arg2)
init
in class TParseTreeNode
public void init(Object arg1, Object arg2, Object arg3)
init
in class TParseTreeNode
public void init(Object arg1, Object arg2, Object arg3, Object arg4)
init
in class TParseTreeNode
public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5)
init
in class TParseTreeNode
public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6)
init
in class TParseTreeNode
public long getColumnNo()
getColumnNo
in class TParseTreeNode
public long getLineNo()
getLineNo
in class TParseTreeNode
public TObjectNameList getReferencedObjects()
public String getColumnNameOnly()
public void accept(TParseTreeVisitor v)
TParseTreeNode
accept
in interface Visitable
accept
in class TParseTreeNode
v
- visitor is a descendant class of TParseTreeVisitor
public void acceptChildren(TParseTreeVisitor v)
TParseTreeNode
acceptChildren
in interface Visitable
acceptChildren
in class TParseTreeNode
v
- visitor is a descendant class of TParseTreeVisitor
public void setSortType(TSourceToken sortType)
public TSourceToken getSortType()
public TSourceToken getColumnToken()
public boolean isAttributeNameInObjectName(TSourceToken leftparen, TSourceToken rightparen)
public void mergeObjectName(TObjectName objectName)
public void mergeObjectName(TObjectName objectName, TObjectName objectName2)
public void appendObjectName(TObjectName objectName)
public void setCommentString(TSourceToken commentString)
public TSourceToken getCommentString()
public String coordinate()
Copyright © 2019. All rights reserved.