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

public class MetaStatement extends Object implements IStatement, Serializable
Base class for all database metadata statement objects. Provides common functionality for accessing object location, names, and comments.
See Also:
  • Constructor Details

    • MetaStatement

      public MetaStatement(ObjectLocation object)
      Creates a new metadata statement with location information.
      Parameters:
      object - the object location information
    • MetaStatement

      public MetaStatement(ObjectReference reference)
      Creates a new metadata statement from object reference.
      Parameters:
      reference - object reference
  • Method Details

    • getName

      public String getName()
      Description copied from interface: IStatement
      Gets the name of this statement.
      Specified by:
      getName in interface IStatement
      Returns:
      the statement name
    • getBareName

      public String getBareName()
      Description copied from interface: IStatement
      Gets the bare name without qualifiers or arguments.
      Specified by:
      getBareName in interface IStatement
      Returns:
      the bare name
    • getStatementType

      public DbObjType getStatementType()
      Description copied from interface: IStatement
      Gets the type of this database object.
      Specified by:
      getStatementType in interface IStatement
      Returns:
      the database object type
    • getObjectReference

      public ObjectReference getObjectReference()
      Returns:
      object reference for this statement
    • getObject

      public ObjectLocation getObject()
      Returns the object location information.
      Returns:
      the object location
    • getQualifiedName

      public String getQualifiedName()
      Description copied from interface: IStatement
      Gets the fully qualified name of this statement.
      Specified by:
      getQualifiedName in interface IStatement
      Returns:
      the qualified name
    • getComment

      public String getComment()
      Description copied from interface: IStatement
      Gets the comment associated with this statement.
      Specified by:
      getComment in interface IStatement
      Returns:
      the comment, or null if no comment is set
    • setComment

      public void setComment(String comment)
      Specified by:
      setComment in interface IStatement
    • getAuthor

      public String getAuthor()
      Specified by:
      getAuthor in interface IStatement
    • 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

      public String 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

      public MetaStatement getParent()
      Description copied from interface: IStatement
      Gets the parent statement that contains this statement.
      Specified by:
      getParent in interface IStatement
      Returns:
      the parent statement, or null if this is a top-level object
    • getDatabase

      public IDatabase getDatabase()
      Description copied from interface: IStatement
      Gets the database that contains this statement.
      Specified by:
      getDatabase in interface IStatement
      Returns:
      the containing database
    • getTwin

      public IStatement getTwin(IDatabase newDb)
      Specified by:
      getTwin in interface IStatement
      Returns:
      an element in another db sharing the same name and location
    • deepCopy

      public IStatement deepCopy()
      Description copied from interface: IStatement
      Performs IStatement.shallowCopy() on this object and all its children.
      Specified by:
      deepCopy in interface IStatement
      Returns:
      a fully recursive copy of this statement.
    • shallowCopy

      public IStatement shallowCopy()
      Description copied from interface: IStatement
      Copies all object properties into a new object and leaves all its children empty.
      Specified by:
      shallowCopy in interface IStatement
      Returns:
      shallow copy of a DB object.
    • compare

      public boolean compare(IStatement statement)
      Specified by:
      compare in interface IStatement
    • addDependency

      public void addDependency(ObjectReference dependency)
      Description copied from interface: IStatement
      Adds a dependency to this statement.
      Specified by:
      addDependency in interface IStatement
      Parameters:
      dependency - the dependency to add
    • getDependencies

      public Set<ObjectReference> getDependencies()
      Specified by:
      getDependencies in interface IStatement
      Returns:
      all object dependencies
    • getPrivileges

      public Set<IPrivilege> getPrivileges()
      Description copied from interface: IStatement
      Gets an unmodifiable set of privileges for this statement.
      Specified by:
      getPrivileges in interface IStatement
      Returns:
      unmodifiable set of privileges
    • clearPrivileges

      public void clearPrivileges()
      Description copied from interface: IStatement
      Removes all privileges from this statement.
      Specified by:
      clearPrivileges in interface IStatement
    • getSQL

      public String getSQL(boolean isFormatted, ISettings settings)
      Description copied from interface: IStatement
      Gets the SQL representation of this statement with optional formatting.
      Specified by:
      getSQL in interface IStatement
      Parameters:
      isFormatted - whether to apply formatting to the SQL
      settings - the settings to use for SQL generation and formatting
      Returns:
      the SQL string representation of this statement
    • getChildren

      public Stream<? extends IStatement> getChildren()
      Description copied from interface: IStatement
      Returns all subelements of current element
      Specified by:
      getChildren in interface IStatement
    • getDescendants

      public Stream<? extends IStatement> getDescendants()
      Description copied from interface: IStatement
      Returns all subtree elements
      Specified by:
      getDescendants in interface IStatement
    • getOwner

      public String getOwner()
      Description copied from interface: IStatement
      Returns owner of the object
      Specified by:
      getOwner in interface IStatement
    • appendOwnerSQL

      public void appendOwnerSQL(SQLScript script)
      Description copied from interface: IStatement
      Appends ALTER OWNER SQL statement to the script for this database object.
      Specified by:
      appendOwnerSQL in interface IStatement
      Parameters:
      script - the SQL script to append the owner statement to
    • getDropSQL

      public void getDropSQL(SQLScript script, boolean generateExists)
      Description copied from interface: IStatement
      Generates DROP SQL for this statement.
      Specified by:
      getDropSQL in interface IStatement
      Parameters:
      script - the SQL script to append the DROP statement to
      generateExists - whether to include "IF EXISTS" in the DROP statement
    • getLocation

      public ObjectLocation getLocation()
      Description copied from interface: IStatement
      Gets the location information for this statement.
      Specified by:
      getLocation in interface IStatement
      Returns:
      the location where this statement is defined
    • isLib

      public boolean isLib()
      Specified by:
      isLib in interface IStatement
      Returns:
      true if this statement is from a library
    • getLibName

      public String getLibName()
      Description copied from interface: IStatement
      Gets the name of the library this statement comes from.
      Specified by:
      getLibName in interface IStatement
      Returns:
      the library name, or null if not from a library
    • appendAlterSQL

      public ObjectState appendAlterSQL(IStatement newCondition, SQLScript script)
      Description copied from interface: IStatement
      Fill script with object changes and return change type
      Specified by:
      appendAlterSQL in interface IStatement
      Parameters:
      newCondition - new object state
      script - script to collect changes
      Returns:
      object change type
    • getCreationSQL

      public void getCreationSQL(SQLScript script)
      Description copied from interface: IStatement
      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.
      Specified by:
      getCreationSQL in interface IStatement
      Parameters:
      script - the SQL script to append creation statements to
    • canDrop

      public boolean canDrop()
      Specified by:
      canDrop in interface IStatement
      Returns:
      true if the statement can be dropped
    • canDropBeforeCreate

      public boolean canDropBeforeCreate()
      Description copied from interface: IStatement
      Checks if this statement can be dropped before being recreated. Override in subclasses that support drop-before-create behavior.
      Specified by:
      canDropBeforeCreate in interface IStatement
      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: IStatement
      Formats string
      Specified by:
      formatSql in interface IStatement
      Parameters:
      sql - The source SQL text to format
      offset - Starting offset in the source text
      length - Length of text to format
      formatConfiguration - Formatting configuration options
      Returns:
      formatted string
    • getQuoter

      public UnaryOperator<String> getQuoter()
      Specified by:
      getQuoter in interface IStatement
      Returns:
      a function that quotes name
    • getRenameCommand

      public String getRenameCommand(String newName)
      Description copied from interface: IStatement
      Returns sql command to rename the given object.
      Specified by:
      getRenameCommand in interface IStatement
      Parameters:
      newName - the new name for given object
      Returns:
      sql command to rename the given object
    • setOwner

      public void setOwner(String owner)
      Specified by:
      setOwner in interface IStatement
    • setLibName

      public void setLibName(String libName)
      Specified by:
      setLibName in interface IStatement
    • setLocation

      public void setLocation(ObjectLocation loc)
      Specified by:
      setLocation in interface IStatement
    • hasChildren

      public boolean hasChildren()
      Specified by:
      hasChildren in interface IStatement
    • getSeparator

      public String getSeparator()
      Specified by:
      getSeparator in interface IStatement