Class AbstractDataContainer
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.gui.tools.wekainvestigator.data.AbstractDataContainer
-
- All Implemented Interfaces:
CleanUpHandler,LoggingSupporter,SizeOfHandler,UndoHandler,UndoHandlerWithQuickAccess,UndoListener,DataContainer,Serializable,Comparable<DataContainer>,EventListener
- Direct Known Subclasses:
DatabaseContainer,DataGeneratorContainer,FileContainer,MemoryContainer,SpreadSheetContainer,TextDirectoryLoaderContainer
public abstract class AbstractDataContainer extends LoggingObject implements DataContainer, 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.Instancesm_Datathe underlying data.protected intm_IDthe ID of the container.protected static intm_IDCounterthe ID counter.protected Datem_LastUpdatedthe timestamp the data was last updated.protected booleanm_Modifiedwhether the data has been modified.protected Undom_Undothe undo manager.-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
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 voidaddUndoPoint(String comment)Adds an undo point with the given comment.protected voidapplyUndoData(Serializable[] data)Restores the data from the undo point.voidcleanUp()Cleans up data structures, frees up memory.intcompareTo(DataContainer o)Compares this container with the specified one.protected abstract StringdoReload()Reloads the data.booleanequals(Object obj)Checks whether the specified object is the same.weka.core.InstancesgetData()Returns the actual underlying data.intgetID()Returns the container ID.UndogetUndo()Returns the current undo manager.protected Serializable[]getUndoData()Returns the data to store in the undo.protected StringhandleException(String msg, Throwable t)Logs the error and returns a compiled error string.booleanisModified()Checks whether the data has been modified.booleanisUndoSupported()Returns whether an Undo manager is currently available.DatelastUpdated()Returns the timestamp the data was last updated.protected static intnextID()Returns the next container ID.voidredo()Performs a redo if possible.Stringreload()Reloads the data.voidsetData(weka.core.Instances value)Sets the data.voidsetModified(boolean value)Sets whether the data has been modified.voidsetUndo(Undo value)Sets the undo manager to use, can be null if no undo-support wanted.StringtoString()Returns a short description of the container.voidundo()Performs an undo if possible.voidundoOccurred(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 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:
setDatain interfaceDataContainer- Parameters:
value- the data to use
-
getData
public weka.core.Instances getData()
Returns the actual underlying data.- Specified by:
getDatain interfaceDataContainer- Returns:
- the data
-
getID
public int getID()
Returns the container ID.- Specified by:
getIDin interfaceDataContainer- Returns:
- the ID
-
isModified
public boolean isModified()
Checks whether the data has been modified.- Specified by:
isModifiedin interfaceDataContainer- Returns:
- true if modified
-
setModified
public void setModified(boolean value)
Sets whether the data has been modified.- Specified by:
setModifiedin 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:
reloadin interfaceDataContainer- Returns:
- null if successfully reloaded, otherwise error message
-
setUndo
public void setUndo(Undo value)
Sets the undo manager to use, can be null if no undo-support wanted.- Specified by:
setUndoin interfaceUndoHandler- Parameters:
value- the undo manager to use
-
getUndo
public Undo getUndo()
Returns the current undo manager.- Specified by:
getUndoin interfaceUndoHandler- Returns:
- the undo manager
-
isUndoSupported
public boolean isUndoSupported()
Returns whether an Undo manager is currently available.- Specified by:
isUndoSupportedin interfaceUndoHandler- Returns:
- true if an undo manager is set
-
undoOccurred
public void undoOccurred(UndoEvent e)
An undo event, like add or remove, has occurred.- Specified by:
undoOccurredin interfaceUndoListener- Parameters:
e- the trigger event
-
undo
public void undo()
Performs an undo if possible.- Specified by:
undoin interfaceUndoHandlerWithQuickAccess
-
redo
public void redo()
Performs a redo if possible.- Specified by:
redoin interfaceUndoHandlerWithQuickAccess
-
addUndoPoint
public void addUndoPoint(String comment)
Adds an undo point with the given comment.- Specified by:
addUndoPointin interfaceUndoHandlerWithQuickAccess- 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:
lastUpdatedin 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:
compareToin 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:
equalsin 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:
cleanUpin interfaceCleanUpHandler
-
nextID
protected static int nextID()
Returns the next container ID.- Returns:
- the next ID
-
-