Interface IStatement
- All Known Subinterfaces:
ICast,IColumn,ICompositeType,IConstraint,IConstraintFk,IConstraintPk,IDatabase,IForeignTable,IFunction,IIndex,IOperator,IOptionContainer,IPartitionTable,IPolicy,IRelation,IRule,ISchema,ISearchPath,ISequence,ISimpleColumnContainer,ISimpleOptionContainer,IStatementContainer,IStatistics,ISubElement,ITable,ITrigger,IType,IView,MsSourceStatement,PgForeignOptionContainer
- All Known Implementing Classes:
AbstractStatement,ChAbstractStatement,ChColumn,ChConstraint,ChDatabase,ChDictionary,ChFunction,ChIndex,ChPolicy,ChRole,ChSchema,ChTable,ChTableLog,ChUser,ChView,GpExternalTable,GpPartitionTable,MetaCast,MetaCompositeType,MetaConstraint,MetaFunction,MetaOperator,MetaRelation,MetaStatement,MsAbstractClrFunction,MsAbstractCommonFunction,MsAbstractFunction,MsAbstractStatement,MsAbstractStatementContainer,MsAssembly,MsClrFunction,MsClrProcedure,MsColumn,MsConstraint,MsConstraintCheck,MsConstraintFk,MsConstraintPk,MsDatabase,MsFunction,MsIndex,MsProcedure,MsRole,MsSchema,MsSequence,MsStatistics,MsTable,MsTrigger,MsType,MsUser,MsView,PgAbstractForeignTable,PgAbstractFunction,PgAbstractRegularTable,PgAbstractStatement,PgAbstractStatementContainer,PgAbstractTable,PgAbstractType,PgAbstractView,PgAggregate,PgBaseType,PgCast,PgCollation,PgColumn,PgCompositeType,PgConstraint,PgConstraintCheck,PgConstraintExclude,PgConstraintFk,PgConstraintNotNull,PgConstraintPk,PgDatabase,PgDomain,PgEnumType,PgEventTrigger,PgExtension,PgForeignDataWrapper,PgFtsConfiguration,PgFtsDictionary,PgFtsParser,PgFtsTemplate,PgFunction,PgIndex,PgMaterializedView,PgOperator,PgPartitionForeignTable,PgPartitionTable,PgPolicy,PgProcedure,PgRangeType,PgRule,PgSchema,PgSequence,PgServer,PgShellType,PgSimpleForeignTable,PgSimpleTable,PgStatistics,PgTrigger,PgTypedTable,PgUserMapping,PgView
public interface IStatement
Base interface for all database statements and objects.
Provides common functionality for identifying and accessing database objects.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddDependency(ObjectReference dependency) Adds a dependency to this statement.appendAlterSQL(IStatement newCondition, SQLScript script) Fill script with object changes and return change typevoidappendOwnerSQL(SQLScript script) Appends ALTER OWNER SQL statement to the script for this database object.booleancanDrop()booleanChecks if this statement can be dropped before being recreated.voidRemoves all privileges from this statement.booleancompare(IStatement statement) deepCopy()PerformsshallowCopy()on this object and all its children.formatSql(String sql, int offset, int length, IFormatConfiguration formatConfiguration) Formats stringGets the bare name without qualifiers or arguments.Stream<? extends IStatement>Returns all subelements of current elementGets the comment associated with this statement.voidgetCreationSQL(SQLScript script) Generates the SQL statements needed to create this database object.default IDatabaseGets the database that contains this statement.Stream<? extends IStatement>Returns all subtree elementsvoidgetDropSQL(SQLScript script, boolean generateExists) Generates DROP SQL for this statement.Gets the name of the library this statement comes from.Gets the location information for this statement.getName()Gets the name of this statement.getOwner()Returns owner of the objectGets the parent statement that contains this statement.Gets an unmodifiable set of privileges for this statement.Gets the fully qualified name of this statement.default StringgetRenameCommand(String newName) Returns sql command to rename the given object.Gets the SQL representation of this statement with optional formatting.Gets the type of this database object.default StringGets the type name of this statement for SQL generation.booleanbooleanisLib()default booleanisOwned()Checks if this statement type supports ownership.default StringvoidsetComment(String comment) voidsetLibName(String libName) voidvoidCopies all object properties into a new object and leaves all its children empty.default ObjectReference
-
Method Details
-
getName
String getName()Gets the name of this statement.- Returns:
- the statement name
-
getStatementType
DbObjType getStatementType()Gets the type of this database object.- Returns:
- the database object type
-
getDatabase
Gets the database that contains this statement.- Returns:
- the containing database
-
getTypeName
Gets the type name of this statement for SQL generation.- Returns:
- the type name
-
isOwned
default boolean isOwned()Checks if this statement type supports ownership.- Returns:
- true if the statement can have an owner
-
getParent
IStatement getParent()Gets the parent statement that contains this statement.- Returns:
- the parent statement, or null if this is a top-level object
-
getQualifiedName
String getQualifiedName()Gets the fully qualified name of this statement.- Returns:
- the qualified name
-
getComment
String getComment()Gets the comment associated with this statement.- Returns:
- the comment, or null if no comment is set
-
getBareName
String getBareName()Gets the bare name without qualifiers or arguments.- Returns:
- the bare name
-
getTwin
- Returns:
- an element in another db sharing the same name and location
-
deepCopy
IStatement deepCopy()PerformsshallowCopy()on this object and all its children.- Returns:
- a fully recursive copy of this statement.
-
shallowCopy
IStatement shallowCopy()Copies all object properties into a new object and leaves all its children empty.- Returns:
- shallow copy of a DB object.
-
compare
-
addDependency
Adds a dependency to this statement.- Parameters:
dependency- the dependency to add
-
getDependencies
Set<ObjectReference> getDependencies()- Returns:
- all object dependencies
-
getPrivileges
Set<IPrivilege> getPrivileges()Gets an unmodifiable set of privileges for this statement.- Returns:
- unmodifiable set of privileges
-
clearPrivileges
void clearPrivileges()Removes all privileges from this statement. -
getSQL
Gets the SQL representation of this statement with optional formatting.- Parameters:
isFormatted- whether to apply formatting to the SQLsettings- the settings to use for SQL generation and formatting- Returns:
- the SQL string representation of this statement
-
getChildren
Stream<? extends IStatement> getChildren()Returns all subelements of current element -
getDescendants
Stream<? extends IStatement> getDescendants()Returns all subtree elements -
getOwner
String getOwner()Returns owner of the object -
setOwner
-
getLocation
ObjectLocation getLocation()Gets the location information for this statement.- Returns:
- the location where this statement is defined
-
isLib
boolean isLib()- Returns:
- true if this statement is from a library
-
getLibName
String getLibName()Gets the name of the library this statement comes from.- Returns:
- the library name, or null if not from a library
-
setLibName
-
appendAlterSQL
Fill script with object changes and return change type- Parameters:
newCondition- new object statescript- script to collect changes- Returns:
- object change type
-
getCreationSQL
Generates the SQL statements needed to create this database object. This is an abstract method that must be implemented by subclasses to provide the specific CREATE SQL for each object type.- Parameters:
script- the SQL script to append creation statements to
-
appendOwnerSQL
Appends ALTER OWNER SQL statement to the script for this database object.- Parameters:
script- the SQL script to append the owner statement to- Throws:
IllegalArgumentException- if database type is unsupported
-
getDropSQL
Generates DROP SQL for this statement.- Parameters:
script- the SQL script to append the DROP statement togenerateExists- whether to include "IF EXISTS" in the DROP statement
-
canDrop
boolean canDrop()- Returns:
- true if the statement can be dropped
-
getSeparator
String getSeparator() -
canDropBeforeCreate
boolean canDropBeforeCreate()Checks if this statement can be dropped before being recreated. Override in subclasses that support drop-before-create behavior.- Returns:
- true if the statement can be dropped before recreation
-
toObjectReference
-
formatSql
Formats string- Parameters:
sql- The source SQL text to formatoffset- Starting offset in the source textlength- Length of text to formatformatConfiguration- Formatting configuration options- Returns:
- formatted string
-
getQuotedName
- Returns:
- the quoted name
-
quote
- Parameters:
name- string to quote- Returns:
- the quoted string
-
getQuoter
UnaryOperator<String> getQuoter()- Returns:
- a function that quotes name
-
getRenameCommand
Returns sql command to rename the given object.- Parameters:
newName- the new name for given object- Returns:
- sql command to rename the given object
-
setLocation
-
hasChildren
boolean hasChildren() -
setComment
-
getAuthor
String getAuthor()
-