Class InMemory

  • 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 InMemory
    extends AbstractBackend
    Simply stores the uploaded data in memory, with no persistence.
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Constructor Detail

      • InMemory

        public InMemory()
    • 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
      • 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