Package adams.flow.rest.dex.backend
Class FileBased
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.rest.dex.backend.AbstractBackend
-
- adams.flow.rest.dex.backend.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FileBased.DataContainer
Wraps the actual data item with the expiry timestamp.
-
Field Summary
Fields Modifier and Type Field Description protected adams.core.io.PlaceholderDirectory
m_DataDir
the directory to store the data in.protected Map<String,FileBased.DataContainer>
m_Storage
the available data items.-
Fields inherited from class adams.flow.rest.dex.backend.AbstractBackend
m_Initialized, m_SequentialTokens, m_TimeToLive
-
-
Constructor Summary
Constructors Constructor Description FileBased()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
addItem(byte[] data)
Adds the item, returns the generated token.String
dataDirTipText()
Returns the tip text for this property.void
defineOptions()
Adds options to the internal list of options.protected void
doClear()
Removes all items.protected String
doInitBackend()
Initializes the backend.protected void
doPurge()
Purges any expired items.adams.core.io.PlaceholderDirectory
getDataDir()
Returns the directory to store the data in.protected byte[]
getItem(String token)
Gets the item, if present.String
globalInfo()
Returns a string describing the object.protected boolean
hasItem(String token)
Checks whether the item is present.protected boolean
removeItem(String token)
Removes the data associated with the token.void
setDataDir(adams.core.io.PlaceholderDirectory value)
Sets the directory to store the data in.-
Methods inherited from class adams.flow.rest.dex.backend.AbstractBackend
add, clear, get, getSequentialTokens, getTimeToLive, has, initBackend, nextToken, purge, remove, reset, sequentialTokensTipText, setSequentialTokens, setTimeToLive, timeToLiveTipText
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_DataDir
protected adams.core.io.PlaceholderDirectory m_DataDir
the directory to store the data in.
-
m_Storage
protected Map<String,FileBased.DataContainer> m_Storage
the available data items.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceadams.core.GlobalInfoSupporter
- Specified by:
globalInfo
in classadams.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 interfaceadams.core.option.OptionHandler
- Overrides:
defineOptions
in classAbstractBackend
-
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 classAbstractBackend
- Returns:
- null if sucessfully initialized, otherwise error message
-
doClear
protected void doClear()
Removes all items.- Specified by:
doClear
in classAbstractBackend
-
doPurge
protected void doPurge()
Purges any expired items.- Specified by:
doPurge
in classAbstractBackend
-
hasItem
protected boolean hasItem(String token)
Checks whether the item is present.- Specified by:
hasItem
in classAbstractBackend
- 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 classAbstractBackend
- 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 classAbstractBackend
- 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 classAbstractBackend
- Parameters:
token
- the token to remove the data for- Returns:
- true if removed
-
-