Class AbstractDataContainer
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.gui.tools.wekainvestigator.data.AbstractDataContainer
-
- All Implemented Interfaces:
adams.core.CleanUpHandler
,adams.core.logging.LoggingSupporter
,adams.core.SizeOfHandler
,adams.gui.core.UndoHandler
,adams.gui.core.UndoHandlerWithQuickAccess
,adams.gui.event.UndoListener
,DataContainer
,Serializable
,Comparable<DataContainer>
,EventListener
- Direct Known Subclasses:
DatabaseContainer
,DataGeneratorContainer
,FileContainer
,MemoryContainer
,SpreadSheetContainer
,TextDirectoryLoaderContainer
public abstract class AbstractDataContainer extends adams.core.logging.LoggingObject implements DataContainer, adams.gui.event.UndoListener
Ancestor for data containers.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected weka.core.Instances
m_Data
the underlying data.protected int
m_ID
the ID of the container.protected static int
m_IDCounter
the ID counter.protected Date
m_LastUpdated
the timestamp the data was last updated.protected boolean
m_Modified
whether the data has been modified.protected adams.gui.core.Undo
m_Undo
the undo manager.
-
Constructor Summary
Constructors Constructor Description AbstractDataContainer()
Initializes the container with no data.AbstractDataContainer(weka.core.Instances data)
Initializes the container with just the data.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addUndoPoint(String comment)
Adds an undo point with the given comment.protected void
applyUndoData(Serializable[] data)
Restores the data from the undo point.void
cleanUp()
Cleans up data structures, frees up memory.int
compareTo(DataContainer o)
Compares this container with the specified one.protected abstract String
doReload()
Reloads the data.boolean
equals(Object obj)
Checks whether the specified object is the same.weka.core.Instances
getData()
Returns the actual underlying data.int
getID()
Returns the container ID.adams.gui.core.Undo
getUndo()
Returns the current undo manager.protected Serializable[]
getUndoData()
Returns the data to store in the undo.protected String
handleException(String msg, Throwable t)
Logs the error and returns a compiled error string.boolean
isModified()
Checks whether the data has been modified.boolean
isUndoSupported()
Returns whether an Undo manager is currently available.Date
lastUpdated()
Returns the timestamp the data was last updated.protected static int
nextID()
Returns the next container ID.void
redo()
Performs a redo if possible.String
reload()
Reloads the data.void
setData(weka.core.Instances value)
Sets the data.void
setModified(boolean value)
Sets whether the data has been modified.void
setUndo(adams.gui.core.Undo value)
Sets the undo manager to use, can be null if no undo-support wanted.String
toString()
Returns a short description of the container.void
undo()
Performs an undo if possible.void
undoOccurred(adams.gui.event.UndoEvent e)
An undo event, like add or remove, has occurred.-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.gui.tools.wekainvestigator.data.DataContainer
canReload, getSource
-
-
-
-
Field Detail
-
m_IDCounter
protected static int m_IDCounter
the ID counter.
-
m_ID
protected int m_ID
the ID of the container.
-
m_Data
protected weka.core.Instances m_Data
the underlying data.
-
m_Modified
protected boolean m_Modified
whether the data has been modified.
-
m_Undo
protected transient adams.gui.core.Undo m_Undo
the undo manager.
-
m_LastUpdated
protected Date m_LastUpdated
the timestamp the data was last updated.
-
-
Method Detail
-
setData
public void setData(weka.core.Instances value)
Sets the data.- Specified by:
setData
in interfaceDataContainer
- Parameters:
value
- the data to use
-
getData
public weka.core.Instances getData()
Returns the actual underlying data.- Specified by:
getData
in interfaceDataContainer
- Returns:
- the data
-
getID
public int getID()
Returns the container ID.- Specified by:
getID
in interfaceDataContainer
- Returns:
- the ID
-
isModified
public boolean isModified()
Checks whether the data has been modified.- Specified by:
isModified
in interfaceDataContainer
- Returns:
- true if modified
-
setModified
public void setModified(boolean value)
Sets whether the data has been modified.- Specified by:
setModified
in interfaceDataContainer
- Parameters:
value
- true if modified
-
doReload
protected abstract String doReload()
Reloads the data.- Returns:
- null if successfully reloaded, otherwise error message
-
reload
public String reload()
Reloads the data.- Specified by:
reload
in interfaceDataContainer
- Returns:
- null if successfully reloaded, otherwise error message
-
setUndo
public void setUndo(adams.gui.core.Undo value)
Sets the undo manager to use, can be null if no undo-support wanted.- Specified by:
setUndo
in interfaceadams.gui.core.UndoHandler
- Parameters:
value
- the undo manager to use
-
getUndo
public adams.gui.core.Undo getUndo()
Returns the current undo manager.- Specified by:
getUndo
in interfaceadams.gui.core.UndoHandler
- Returns:
- the undo manager
-
isUndoSupported
public boolean isUndoSupported()
Returns whether an Undo manager is currently available.- Specified by:
isUndoSupported
in interfaceadams.gui.core.UndoHandler
- Returns:
- true if an undo manager is set
-
undoOccurred
public void undoOccurred(adams.gui.event.UndoEvent e)
An undo event, like add or remove, has occurred.- Specified by:
undoOccurred
in interfaceadams.gui.event.UndoListener
- Parameters:
e
- the trigger event
-
undo
public void undo()
Performs an undo if possible.- Specified by:
undo
in interfaceadams.gui.core.UndoHandlerWithQuickAccess
-
redo
public void redo()
Performs a redo if possible.- Specified by:
redo
in interfaceadams.gui.core.UndoHandlerWithQuickAccess
-
addUndoPoint
public void addUndoPoint(String comment)
Adds an undo point with the given comment.- Specified by:
addUndoPoint
in interfaceadams.gui.core.UndoHandlerWithQuickAccess
- Parameters:
comment
- the comment for the undo point
-
getUndoData
protected Serializable[] getUndoData()
Returns the data to store in the undo.- Returns:
- the undo point
-
applyUndoData
protected void applyUndoData(Serializable[] data)
Restores the data from the undo point.- Parameters:
data
- the undo point
-
lastUpdated
public Date lastUpdated()
Returns the timestamp the data was last updated.- Specified by:
lastUpdated
in interfaceDataContainer
- Returns:
- the timestamp
-
handleException
protected String handleException(String msg, Throwable t)
Logs the error and returns a compiled error string.- Parameters:
msg
- the message to uset
- the exception- Returns:
- the generated error message
-
compareTo
public int compareTo(DataContainer o)
Compares this container with the specified one.- Specified by:
compareTo
in interfaceComparable<DataContainer>
- Parameters:
o
- the container to compare with- Returns:
- less than, equal to or greater than 0 if the container's
DataContainer.getSource()
andgetID()
is smaller, equal to or greater then the provided one
-
equals
public boolean equals(Object obj)
Checks whether the specified object is the same.- Overrides:
equals
in classObject
- Parameters:
obj
- the object to check- Returns:
- true if the same, i.e., the same
DataContainer.getSource()
- See Also:
getID()
-
toString
public String toString()
Returns a short description of the container.
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUp
in interfaceadams.core.CleanUpHandler
-
nextID
protected static int nextID()
Returns the next container ID.- Returns:
- the next ID
-
-