Class MetaStatement
java.lang.Object
org.pgcodekeeper.core.database.base.schema.meta.MetaStatement
- All Implemented Interfaces:
Serializable,IStatement
- Direct Known Subclasses:
MetaCast,MetaCompositeType,MetaConstraint,MetaFunction,MetaOperator,MetaRelation
Base class for all database metadata statement objects.
Provides common functionality for accessing object location, names, and comments.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionMetaStatement(ObjectLocation object) Creates a new metadata statement with location information.MetaStatement(ObjectReference reference) Creates a new metadata statement from object reference. -
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()PerformsIStatement.shallowCopy()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.Gets the database that contains this statement.Stream<? extends IStatement>Returns all subtree elementsvoidgetDropSQL(SQLScript script, boolean generateExists) Generates DROP SQL for this statement.Returns the file path where this object is defined.Gets the name of the library this statement comes from.intReturns the line number where this object is defined.Gets the location information for this statement.getName()Gets the name of this statement.Returns the object location information.intReturns the length of the object in the source file.intReturns the offset of the object in the source file.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.getRenameCommand(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.booleanbooleanisLib()voidsetComment(String comment) voidsetLibName(String libName) voidvoidCopies all object properties into a new object and leaves all its children empty.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.pgcodekeeper.core.database.api.schema.IStatement
getQuotedName, getTypeName, isOwned, quote, toObjectReference
-
Constructor Details
-
MetaStatement
Creates a new metadata statement with location information.- Parameters:
object- the object location information
-
MetaStatement
Creates a new metadata statement from object reference.- Parameters:
reference- object reference
-
-
Method Details
-
getName
Description copied from interface:IStatementGets the name of this statement.- Specified by:
getNamein interfaceIStatement- Returns:
- the statement name
-
getBareName
Description copied from interface:IStatementGets the bare name without qualifiers or arguments.- Specified by:
getBareNamein interfaceIStatement- Returns:
- the bare name
-
getStatementType
Description copied from interface:IStatementGets the type of this database object.- Specified by:
getStatementTypein interfaceIStatement- Returns:
- the database object type
-
getObjectReference
- Returns:
- object reference for this statement
-
getObject
Returns the object location information.- Returns:
- the object location
-
getQualifiedName
Description copied from interface:IStatementGets the fully qualified name of this statement.- Specified by:
getQualifiedNamein interfaceIStatement- Returns:
- the qualified name
-
getComment
Description copied from interface:IStatementGets the comment associated with this statement.- Specified by:
getCommentin interfaceIStatement- Returns:
- the comment, or null if no comment is set
-
setComment
- Specified by:
setCommentin interfaceIStatement
-
getAuthor
- Specified by:
getAuthorin interfaceIStatement
-
getObjLength
public int getObjLength()Returns the length of the object in the source file.- Returns:
- the object length
-
getOffset
public int getOffset()Returns the offset of the object in the source file.- Returns:
- the object offset
-
getFilePath
Returns the file path where this object is defined.- Returns:
- the file path
-
getLineNumber
public int getLineNumber()Returns the line number where this object is defined.- Returns:
- the line number
-
getParent
Description copied from interface:IStatementGets the parent statement that contains this statement.- Specified by:
getParentin interfaceIStatement- Returns:
- the parent statement, or null if this is a top-level object
-
getDatabase
Description copied from interface:IStatementGets the database that contains this statement.- Specified by:
getDatabasein interfaceIStatement- Returns:
- the containing database
-
getTwin
- Specified by:
getTwinin interfaceIStatement- Returns:
- an element in another db sharing the same name and location
-
deepCopy
Description copied from interface:IStatementPerformsIStatement.shallowCopy()on this object and all its children.- Specified by:
deepCopyin interfaceIStatement- Returns:
- a fully recursive copy of this statement.
-
shallowCopy
Description copied from interface:IStatementCopies all object properties into a new object and leaves all its children empty.- Specified by:
shallowCopyin interfaceIStatement- Returns:
- shallow copy of a DB object.
-
compare
- Specified by:
comparein interfaceIStatement
-
addDependency
Description copied from interface:IStatementAdds a dependency to this statement.- Specified by:
addDependencyin interfaceIStatement- Parameters:
dependency- the dependency to add
-
getDependencies
- Specified by:
getDependenciesin interfaceIStatement- Returns:
- all object dependencies
-
getPrivileges
Description copied from interface:IStatementGets an unmodifiable set of privileges for this statement.- Specified by:
getPrivilegesin interfaceIStatement- Returns:
- unmodifiable set of privileges
-
clearPrivileges
public void clearPrivileges()Description copied from interface:IStatementRemoves all privileges from this statement.- Specified by:
clearPrivilegesin interfaceIStatement
-
getSQL
Description copied from interface:IStatementGets the SQL representation of this statement with optional formatting.- Specified by:
getSQLin interfaceIStatement- 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
Description copied from interface:IStatementReturns all subelements of current element- Specified by:
getChildrenin interfaceIStatement
-
getDescendants
Description copied from interface:IStatementReturns all subtree elements- Specified by:
getDescendantsin interfaceIStatement
-
getOwner
Description copied from interface:IStatementReturns owner of the object- Specified by:
getOwnerin interfaceIStatement
-
appendOwnerSQL
Description copied from interface:IStatementAppends ALTER OWNER SQL statement to the script for this database object.- Specified by:
appendOwnerSQLin interfaceIStatement- Parameters:
script- the SQL script to append the owner statement to
-
getDropSQL
Description copied from interface:IStatementGenerates DROP SQL for this statement.- Specified by:
getDropSQLin interfaceIStatement- Parameters:
script- the SQL script to append the DROP statement togenerateExists- whether to include "IF EXISTS" in the DROP statement
-
getLocation
Description copied from interface:IStatementGets the location information for this statement.- Specified by:
getLocationin interfaceIStatement- Returns:
- the location where this statement is defined
-
isLib
public boolean isLib()- Specified by:
isLibin interfaceIStatement- Returns:
- true if this statement is from a library
-
getLibName
Description copied from interface:IStatementGets the name of the library this statement comes from.- Specified by:
getLibNamein interfaceIStatement- Returns:
- the library name, or null if not from a library
-
appendAlterSQL
Description copied from interface:IStatementFill script with object changes and return change type- Specified by:
appendAlterSQLin interfaceIStatement- Parameters:
newCondition- new object statescript- script to collect changes- Returns:
- object change type
-
getCreationSQL
Description copied from interface:IStatementGenerates 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.- Specified by:
getCreationSQLin interfaceIStatement- Parameters:
script- the SQL script to append creation statements to
-
canDrop
public boolean canDrop()- Specified by:
canDropin interfaceIStatement- Returns:
- true if the statement can be dropped
-
canDropBeforeCreate
public boolean canDropBeforeCreate()Description copied from interface:IStatementChecks if this statement can be dropped before being recreated. Override in subclasses that support drop-before-create behavior.- Specified by:
canDropBeforeCreatein interfaceIStatement- Returns:
- true if the statement can be dropped before recreation
-
formatSql
public String formatSql(String sql, int offset, int length, IFormatConfiguration formatConfiguration) Description copied from interface:IStatementFormats string- Specified by:
formatSqlin interfaceIStatement- 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
-
getQuoter
- Specified by:
getQuoterin interfaceIStatement- Returns:
- a function that quotes name
-
getRenameCommand
Description copied from interface:IStatementReturns sql command to rename the given object.- Specified by:
getRenameCommandin interfaceIStatement- Parameters:
newName- the new name for given object- Returns:
- sql command to rename the given object
-
setOwner
- Specified by:
setOwnerin interfaceIStatement
-
setLibName
- Specified by:
setLibNamein interfaceIStatement
-
setLocation
- Specified by:
setLocationin interfaceIStatement
-
hasChildren
public boolean hasChildren()- Specified by:
hasChildrenin interfaceIStatement
-
getSeparator
- Specified by:
getSeparatorin interfaceIStatement
-