Class AbstractDataContainer

    • 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.
      • 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.
    • 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.
    • Constructor Detail

      • AbstractDataContainer

        public AbstractDataContainer()
        Initializes the container with no data.
      • AbstractDataContainer

        public AbstractDataContainer​(weka.core.Instances data)
        Initializes the container with just the data.
        Parameters:
        data - the data to use
    • Method Detail

      • setData

        public void setData​(weka.core.Instances value)
        Sets the data.
        Specified by:
        setData in interface DataContainer
        Parameters:
        value - the data to use
      • getData

        public weka.core.Instances getData()
        Returns the actual underlying data.
        Specified by:
        getData in interface DataContainer
        Returns:
        the data
      • getID

        public int getID()
        Returns the container ID.
        Specified by:
        getID in interface DataContainer
        Returns:
        the ID
      • isModified

        public boolean isModified()
        Checks whether the data has been modified.
        Specified by:
        isModified in interface DataContainer
        Returns:
        true if modified
      • setModified

        public void setModified​(boolean value)
        Sets whether the data has been modified.
        Specified by:
        setModified in interface DataContainer
        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 interface DataContainer
        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 interface adams.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 interface adams.gui.core.UndoHandler
        Returns:
        the undo manager
      • isUndoSupported

        public boolean isUndoSupported()
        Returns whether an Undo manager is currently available.
        Specified by:
        isUndoSupported in interface adams.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 interface adams.gui.event.UndoListener
        Parameters:
        e - the trigger event
      • undo

        public void undo()
        Performs an undo if possible.
        Specified by:
        undo in interface adams.gui.core.UndoHandlerWithQuickAccess
      • redo

        public void redo()
        Performs a redo if possible.
        Specified by:
        redo in interface adams.gui.core.UndoHandlerWithQuickAccess
      • addUndoPoint

        public void addUndoPoint​(String comment)
        Adds an undo point with the given comment.
        Specified by:
        addUndoPoint in interface adams.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 interface DataContainer
        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 use
        t - the exception
        Returns:
        the generated error message
      • equals

        public boolean equals​(Object obj)
        Checks whether the specified object is the same.
        Overrides:
        equals in class Object
        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.
        Overrides:
        toString in class Object
        Returns:
        the description
      • cleanUp

        public void cleanUp()
        Cleans up data structures, frees up memory.
        Specified by:
        cleanUp in interface adams.core.CleanUpHandler
      • nextID

        protected static int nextID()
        Returns the next container ID.
        Returns:
        the next ID