Class AbstractDAO

java.lang.Object
com.helger.dao.AbstractDAO
All Implemented Interfaces:
com.helger.commons.log.IHasConditionalLogger, IAutoSaveAware, IDAO
Direct Known Subclasses:
AbstractSimpleDAO, AbstractWALDAO

@ThreadSafe public abstract class AbstractDAO extends Object implements IDAO, com.helger.commons.log.IHasConditionalLogger
Base implementation of IDAO
Author:
Philip Helger
  • Field Details

    • DEFAULT_AUTO_SAVE_ENABLED

      public static final boolean DEFAULT_AUTO_SAVE_ENABLED
      By default auto-save is enabled
      See Also:
    • FILENAME_EXTENSION_PREV

      public static final String FILENAME_EXTENSION_PREV
      The default extension for an old file that was not yet deleted. Mainly used in the WAL DAO
      See Also:
    • FILENAME_EXTENSION_NEW

      public static final String FILENAME_EXTENSION_NEW
      The default extension for a file that is newly created. Mainly used in the WAL DAO
      See Also:
    • RW_LOCK

      protected static final com.helger.commons.concurrent.SimpleReadWriteLock RW_LOCK
    • CONDLOG

      protected static final com.helger.commons.log.ConditionalLogger CONDLOG
    • m_aRWLock

      protected final com.helger.commons.concurrent.SimpleReadWriteLock m_aRWLock
  • Constructor Details

    • AbstractDAO

      protected AbstractDAO()
  • Method Details

    • isSilentMode

      public static boolean isSilentMode()
      Returns:
      true if logging is disabled, false if it is enabled.
      Since:
      9.2.0
    • setSilentMode

      public static boolean setSilentMode(boolean bSilentMode)
      Enable or disable certain regular log messages.
      Parameters:
      bSilentMode - true to disable logging, false to enable logging
      Returns:
      The previous value of the silent mode.
      Since:
      9.2.0
    • exceptionHandlersRead

      @Nonnull @ReturnsMutableObject public static final com.helger.commons.callback.CallbackList<IDAOReadExceptionCallback> exceptionHandlersRead()
      Returns:
      The static mutable exception handler list that is invoked for read exceptions. Never null. The list applies to ALL DAOs since it is static.
    • exceptionHandlersWrite

      @Nonnull @ReturnsMutableObject public static final com.helger.commons.callback.CallbackList<IDAOWriteExceptionCallback> exceptionHandlersWrite()
      Returns:
      The static mutable exception handler list that is invoked for write exceptions. Never null. The list applies to ALL DAOs since it is static.
    • internalIsAutoSaveEnabled

      @MustBeLocked(READ) protected final boolean internalIsAutoSaveEnabled()
      Returns:
      true if auto save is enabled, false otherwise.
    • isAutoSaveEnabled

      public final boolean isAutoSaveEnabled()
      Specified by:
      isAutoSaveEnabled in interface IAutoSaveAware
      Returns:
      true if auto save is enabled, false otherwise.
    • internalSetPendingChanges

      @MustBeLocked(WRITE) public final void internalSetPendingChanges(boolean bPendingChanges)
    • internalHasPendingChanges

      @MustBeLocked(READ) public final boolean internalHasPendingChanges()
      Returns:
      true if unsaved changes are present
    • hasPendingChanges

      public final boolean hasPendingChanges()
      Specified by:
      hasPendingChanges in interface IDAO
      Returns:
      true if unsaved changes are present
    • beginWithoutAutoSave

      public final void beginWithoutAutoSave()
      Description copied from interface: IAutoSaveAware
      Start doing something without auto save.
      Specified by:
      beginWithoutAutoSave in interface IAutoSaveAware
    • endWithoutAutoSave

      public final void endWithoutAutoSave()
      Description copied from interface: IAutoSaveAware
      End doing something without auto save. It must be ensure that each call to IAutoSaveAware.beginWithoutAutoSave() is always correctly ended with a call to this method.
      Specified by:
      endWithoutAutoSave in interface IAutoSaveAware
    • checkFileAccess

      protected static void checkFileAccess(@Nonnull File aFile, @Nonnull IDAO.EMode eMode) throws DAOException
      Check the access to the passed file using the specified mode. If the access is not provided, a DAOException is thrown. If everything is good, this method returns without a comment.
      Parameters:
      aFile - The file to check. May not be null.
      eMode - The access mode. May not be null.
      Throws:
      DAOException - If the requested access mode cannot be provided.
    • toString

      public String toString()
      Overrides:
      toString in class Object