All Implemented Interfaces:
ISchema, IStatement, IStatementContainer, IHashable

public class MsSchema extends MsAbstractStatement implements ISchema
Represents a Microsoft SQL schema that contains database objects like tables, views, functions, and procedures. Provides SQL generation for schema creation and management.
  • Constructor Details

    • MsSchema

      public MsSchema(String name)
      Creates a new Microsoft SQL schema.
      Parameters:
      name - the schema name
  • Method Details

    • 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
    • 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
    • getRelations

      public Stream<IRelation> getRelations()
      Description copied from interface: ISchema
      Gets all relations (tables, views, sequences) in this schema.
      Specified by:
      getRelations in interface ISchema
      Returns:
      a stream of relations
    • getRelation

      public IRelation getRelation(String name)
      Description copied from interface: ISchema
      Gets a relation by name.
      Specified by:
      getRelation in interface ISchema
      Parameters:
      name - the relation name
      Returns:
      found relation or null if no such relation has been found
    • addChild

      public void addChild(IStatement st)
      Description copied from interface: IStatementContainer
      Adds a child statement to this container.
      Specified by:
      addChild in interface IStatementContainer
      Parameters:
      st - the child statement to add
    • getChild

      public IStatement getChild(String name, DbObjType type)
      Description copied from interface: IStatementContainer
      Gets a child statement by name and type.
      Specified by:
      getChild in interface IStatementContainer
      Parameters:
      name - the name of the child to find
      type - the type of the child to find
      Returns:
      the child statement, or null if not found
    • getChildrenByType

      public Collection<IStatement> getChildrenByType(DbObjType type)
      Description copied from interface: IStatementContainer
      get all children by type
      Specified by:
      getChildrenByType in interface IStatementContainer
      Parameters:
      type - the type of the children
      Returns:
      unmodifiable collection of child statement, or empty list
    • fillChildrenList

      public void fillChildrenList(List<Collection<? extends AbstractStatement>> l)
      Overrides:
      fillChildrenList in class AbstractStatement
    • fillDescendantsList

      public void fillDescendantsList(List<Collection<? extends AbstractStatement>> l)
      Overrides:
      fillDescendantsList in class AbstractStatement
    • getTable

      public MsTable getTable(String name)
      Finds table according to specified table name.
      Parameters:
      name - name of the table to be searched
      Returns:
      found table or null if no such table has been found
    • getSequence

      public MsSequence getSequence(String name)
      Finds sequence according to specified sequence name.
      Parameters:
      name - name of the sequence to be searched
      Returns:
      found sequence or null if no such sequence has been found
    • getFunction

      public MsAbstractCommonFunction getFunction(String signature)
      Finds function according to specified function signature.
      Parameters:
      signature - signature of the function to be searched
      Returns:
      found function or null if no such function has been found
    • getType

      public MsType getType(String name)
      Finds type according to specified type name.
      Parameters:
      name - name of the type to be searched
      Returns:
      found type or null if no such type has been found
    • getView

      public MsView getView(String name)
      Finds view according to specified view name.
      Parameters:
      name - name of the view to be searched
      Returns:
      found view or null if no such view has been found
    • getStatementContainer

      public MsAbstractStatementContainer getStatementContainer(String name)
      Gets a statement container by name.
      Specified by:
      getStatementContainer in interface ISchema
      Parameters:
      name - the name of the container to find
      Returns:
      the statement container with the given name, or null if not found
    • addFunction

      public void addFunction(MsAbstractCommonFunction function)
      Adds a function to this schema.
      Parameters:
      function - the function to add
    • addSequence

      public void addSequence(MsSequence sequence)
      Adds a sequence to this schema.
      Parameters:
      sequence - the sequence to add
    • addTable

      public void addTable(MsTable table)
      Adds a table to this schema.
      Parameters:
      table - the table to add
    • addView

      public void addView(MsView view)
      Adds a view to this schema.
      Parameters:
      view - the table to add
    • addType

      public void addType(MsType type)
      Adds a type to this schema.
      Parameters:
      type - the table to add
    • getIndexByName

      public MsIndex getIndexByName(String indexName)
      Finds an index by name across all tables and views in this schema.
      Parameters:
      indexName - the name of the index to find
      Returns:
      the index with the given name, or null if not found
    • getStatementContainers

      public Stream<MsAbstractStatementContainer> getStatementContainers()
      Gets a stream of all statement containers in this schema.
      Returns:
      a stream of statement containers
    • getFunctions

      public Collection<IFunction> getFunctions()
      Getter for functions. The list cannot be modified.
      Returns:
      functions
    • computeHash

      public void computeHash(Hasher hasher)
      Description copied from interface: IHashable
      Computes the hash of the implementing object using the provided hasher. The implementation should call appropriate put methods on the hasher for all fields that should contribute to the hash value.
      Specified by:
      computeHash in interface IHashable
      Parameters:
      hasher - the hasher instance to use for hash computation
    • compare

      public boolean compare(IStatement obj)
      Description copied from class: AbstractStatement
      This method does not account for nested child PgStatements. Shallow version of AbstractStatement.equals(Object)
      Specified by:
      compare in interface IStatement
      Overrides:
      compare in class AbstractStatement
    • compareChildren

      public boolean compareChildren(AbstractStatement obj)
      Description copied from class: AbstractStatement
      Deep part of AbstractStatement.equals(Object). Compares all object's child PgStatements for equality.
      Overrides:
      compareChildren in class AbstractStatement