Package adams.db

Class FacadeManager<T extends AbstractTableFacade>

  • Type Parameters:
    T - the type of facade this manager is for
    All Implemented Interfaces:
    Serializable

    public class FacadeManager<T extends AbstractTableFacade>
    extends Object
    implements Serializable
    Manages the database URL/facade relations.
    Version:
    $Revision: 5952 $
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_FacadeName

        protected String m_FacadeName
        the facade this manager is for.
      • m_DatabaseManager

        protected DatabaseManager m_DatabaseManager
        the database manager to use for default connection.
    • Constructor Detail

      • FacadeManager

        public FacadeManager​(String facadeName,
                             DatabaseManager manager)
        Initializes the manager.
        Parameters:
        facadeName - the name of the facade this manager is for
        manager - the database manager to obtain the default database connection from
    • Method Detail

      • getFacadeName

        public String getFacadeName()
        Returns the name of the facade this manager is handling.
        Returns:
        the facade name
      • hasDatabaseManager

        public boolean hasDatabaseManager()
        Checks whether a database manager is available.
        Returns:
        true if a database manager is available
      • getDatabaseManager

        public DatabaseManager getDatabaseManager()
        Returns the database manager in use.
        Returns:
        the database manager
      • createURL

        protected String createURL​(AbstractDatabaseConnection dbcon)
        Generates a URL that includes the user name.
        Parameters:
        dbcon - the database connection
        Returns:
        the complete URL
      • has

        public boolean has​(AbstractDatabaseConnection dbcon)
        Checks whether a facade object for the specified database connection is available.
        Parameters:
        dbcon - the connection to check
        Returns:
        true if a facade object is available
      • get

        public T get​(AbstractDatabaseConnection dbcon)
        Gets the facade object for the specified database connection.
        Parameters:
        dbcon - the connection to get the facade for
        Returns:
        the facade object if available, otherwise null
      • add

        public T add​(AbstractDatabaseConnection dbcon,
                     T facade)
        Adds the facade object for the specified database connection.
        Parameters:
        dbcon - the connection to add the facade for
        facade - the facade object to add
        Returns:
        the previous facade, null if no previous one stored
      • iterator

        public Iterator<T> iterator()
        Returns an iterator over all facades.
        Returns:
        the iterator
      • toString

        public String toString()
        Returns a short string representation of the manager.
        Overrides:
        toString in class Object
        Returns:
        the string representation