Class FileBased

  • All Implemented Interfaces:
    adams.core.Destroyable, adams.core.GlobalInfoSupporter, adams.core.logging.LoggingLevelHandler, adams.core.logging.LoggingSupporter, adams.core.option.OptionHandler, adams.core.SizeOfHandler, Serializable

    public class FileBased
    extends AbstractBackend
    Stores the data on disk in the specified directory ("-.ser").
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_DataDir

        protected adams.core.io.PlaceholderDirectory m_DataDir
        the directory to store the data in.
    • Constructor Detail

      • FileBased

        public FileBased()
    • Method Detail

      • globalInfo

        public String globalInfo()
        Returns a string describing the object.
        Specified by:
        globalInfo in interface adams.core.GlobalInfoSupporter
        Specified by:
        globalInfo in class adams.core.option.AbstractOptionHandler
        Returns:
        a description suitable for displaying in the gui
      • defineOptions

        public void defineOptions()
        Adds options to the internal list of options.
        Specified by:
        defineOptions in interface adams.core.option.OptionHandler
        Overrides:
        defineOptions in class AbstractBackend
      • setDataDir

        public void setDataDir​(adams.core.io.PlaceholderDirectory value)
        Sets the directory to store the data in.
        Parameters:
        value - the directory
      • getDataDir

        public adams.core.io.PlaceholderDirectory getDataDir()
        Returns the directory to store the data in.
        Returns:
        the directory
      • dataDirTipText

        public String dataDirTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • doInitBackend

        protected String doInitBackend()
        Initializes the backend.
        Specified by:
        doInitBackend in class AbstractBackend
        Returns:
        null if sucessfully initialized, otherwise error message
      • doPurge

        protected void doPurge()
        Purges any expired items.
        Specified by:
        doPurge in class AbstractBackend
      • hasItem

        protected boolean hasItem​(String token)
        Checks whether the item is present.
        Specified by:
        hasItem in class AbstractBackend
        Parameters:
        token - the token to check
        Returns:
        true if available
      • getItem

        protected byte[] getItem​(String token)
        Gets the item, if present.
        Specified by:
        getItem in class AbstractBackend
        Parameters:
        token - the token to get
        Returns:
        the item, null if not available
      • addItem

        protected String addItem​(byte[] data)
        Adds the item, returns the generated token.
        Specified by:
        addItem in class AbstractBackend
        Parameters:
        data - the data to add
        Returns:
        the token, null if failed to add
      • removeItem

        protected boolean removeItem​(String token)
        Removes the data associated with the token.
        Specified by:
        removeItem in class AbstractBackend
        Parameters:
        token - the token to remove the data for
        Returns:
        true if removed