Class MsDatabase

All Implemented Interfaces:
IDatabase, IStatement, IStatementContainer, IHashable

public class MsDatabase extends MsAbstractStatement implements IDatabase
Represents a Microsoft SQL database with its schemas, assemblies, roles, and users. Provides functionality for managing database-level objects and their relationships.
  • Constructor Details

    • MsDatabase

      public MsDatabase()
  • Method Details

    • getStatement

      public IStatement getStatement(ObjectReference reference)
      Specified by:
      getStatement in interface IDatabase
      Parameters:
      reference - - object reference
      Returns:
      object from database by reference, or null if not found
    • clearAnalysisLaunchers

      public void clearAnalysisLaunchers()
      Clears all analysis launchers and trims the internal list to size.
      Specified by:
      clearAnalysisLaunchers in interface IDatabase
    • fillDescendantsList

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

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

      public AbstractStatement 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
    • 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
    • getAssembly

      public MsAssembly getAssembly(String name)
      Returns assembly of given name or null if the assembly has not been found.
      Parameters:
      name - assembly name
      Returns:
      found assembly or null
    • getRole

      public MsRole getRole(String name)
      Returns role of given name or null if the role has not been found.
      Parameters:
      name - role name
      Returns:
      found role or null
    • getUser

      public MsUser getUser(String name)
      Returns user of given name or null if the user has not been found.
      Parameters:
      name - user name
      Returns:
      found user or null
    • getAssemblies

      public Collection<MsAssembly> getAssemblies()
      Gets all assemblies in this database.
      Returns:
      unmodifiable collection of assemblies
    • getRoles

      public Collection<MsRole> getRoles()
      Gets all roles in this database.
      Returns:
      unmodifiable collection of roles
    • getUsers

      public Collection<MsUser> getUsers()
      Getter for users. The list cannot be modified.
      Returns:
      users
    • addAssembly

      public void addAssembly(MsAssembly assembly)
      Adds an assembly to this database.
      Parameters:
      assembly - the assembly to add
    • addRole

      public void addRole(MsRole role)
      Adds a role to this database.
      Parameters:
      role - the role to add
    • addUser

      public void addUser(MsUser user)
      Adds a user to this database.
      Parameters:
      user - the user to add
    • getSchemas

      public Collection<MsSchema> getSchemas()
      Getter for schemas. The list cannot be modified.
      Specified by:
      getSchemas in interface IDatabase
      Returns:
      schemas
    • getVersion

      public ISupportedVersion getVersion()
      Specified by:
      getVersion in interface IDatabase
      Returns:
      default database version
    • getDefaultSchema

      public MsSchema getDefaultSchema()
      Specified by:
      getDefaultSchema in interface IDatabase
    • setDefaultSchema

      public void setDefaultSchema(String defaultSchemaName)
      Specified by:
      setDefaultSchema in interface IDatabase
    • addOverride

      public void addOverride(ObjectOverride override)
      Description copied from interface: IDatabase
      Adds object override
      Specified by:
      addOverride in interface IDatabase
      Parameters:
      override - object override
    • getOverrides

      public Collection<ObjectOverride> getOverrides()
      Description copied from interface: IDatabase
      Gets the list of object overrides for this database.
      Specified by:
      getOverrides in interface IDatabase
      Returns:
      the list of overrides
    • getObjReferences

      public Map<String,Set<ObjectLocation>> getObjReferences()
      Specified by:
      getObjReferences in interface IDatabase
      Returns:
      all object references for this database
    • getAnalysisLaunchers

      public List<IAnalysisLauncher> getAnalysisLaunchers()
      Specified by:
      getAnalysisLaunchers in interface IDatabase
      Returns:
      all analysis launcher for this database
    • addAnalysisLauncher

      public void addAnalysisLauncher(IAnalysisLauncher launcher)
      Add 'analysis launcher' for deferred analyze.
      Specified by:
      addAnalysisLauncher in interface IDatabase
      Parameters:
      launcher - launcher that contains almost everything needed to analyze a statement contained in it
    • addReference

      public void addReference(String fileName, ObjectLocation loc)
      Description copied from interface: IDatabase
      Adds an object reference to the specified file.
      Specified by:
      addReference in interface IDatabase
      Parameters:
      fileName - the file name to associate with the location
      loc - the object location to add
    • getSchema

      public MsSchema getSchema(String name)
      Returns schema of given name or null if the schema has not been found. If schema name is null then default schema is returned.
      Specified by:
      getSchema in interface IDatabase
      Parameters:
      name - schema name or null which means default schema
      Returns:
      found schema or null
    • addSchema

      public void addSchema(MsSchema schema)
      Adds a schema to this database.
      Parameters:
      schema - the schema to add
    • 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
    • computeChildrenHash

      public void computeChildrenHash(Hasher hasher)
    • 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