Package elki.database

Class DatabaseEventManager


  • public class DatabaseEventManager
    extends java.lang.Object
    Class to manage database events such as insertions and removals.
    Since:
    0.4.0
    Author:
    Elke Achtert
    • Field Detail

      • dataListenerList

        private java.util.List<DataStoreListener> dataListenerList
        Holds the listeners for data store changes
      • resultListenerList

        private java.util.List<ResultListener> resultListenerList
        Holds the listeners for result changes.
      • accumulateDataStoreEvents

        private boolean accumulateDataStoreEvents
        Indicates whether DataStoreEvents should be accumulated and fired as one event on demand.
      • currentDataStoreEventType

        private DatabaseEventManager.Type currentDataStoreEventType
        The type of the current DataStoreEvent to be accumulated.
      • dataStoreObjects

        private HashSetModifiableDBIDs dataStoreObjects
        The objects that were changed in the current DataStoreEvent.
    • Constructor Detail

      • DatabaseEventManager

        public DatabaseEventManager()
    • Method Detail

      • fireObjectsInserted

        public void fireObjectsInserted​(DBIDs insertions)
        Event when new objects are inserted.
        Parameters:
        insertions - the objects that have been inserted
      • fireObjectInserted

        public void fireObjectInserted​(DBIDRef insertion)
        Event when a new object was inserted.
        Parameters:
        insertion - the object that was inserted
      • fireObjectsUpdated

        public void fireObjectsUpdated​(DBIDs updates)
        Event when objects have changed / were updated.
        Parameters:
        updates - the objects that have been updated
      • fireObjectsUpdated

        public void fireObjectsUpdated​(DBIDRef update)
        Event when an object was changed / updated.
        Parameters:
        update - the object that was updated
      • fireObjectsRemoved

        protected void fireObjectsRemoved​(DBIDs deletions)
        Event when objects were removed / deleted.
        Parameters:
        deletions - the objects that have been removed
      • fireObjectRemoved

        protected void fireObjectRemoved​(DBIDRef deletion)
        Event when an objects was removed / deleted.
        Parameters:
        deletion - the object that has was removed
      • fireObjectsChanged

        private void fireObjectsChanged​(DBIDs objects,
                                        DatabaseEventManager.Type type)
        Handles a DataStoreEvent with the specified type. If the current event type is not equal to the specified type, the events accumulated up to now will be fired first. The new event will be aggregated and fired on demand if accumulateDataStoreEvents is set, otherwise all registered DataStoreListener will be notified immediately that the content of the database has been changed.
        Parameters:
        objects - the objects that have been changed, i.e. inserted, deleted or updated
      • fireObjectChanged

        private void fireObjectChanged​(DBIDRef object,
                                       DatabaseEventManager.Type type)
        Handles a DataStoreEvent with the specified type. If the current event type is not equal to the specified type, the events accumulated up to now will be fired first. The new event will be aggregated and fired on demand if accumulateDataStoreEvents is set, otherwise all registered DataStoreListener will be notified immediately that the content of the database has been changed.
        Parameters:
        object - the object that has been changed, i.e. inserted, deleted or updated
      • fireResultAdded

        public void fireResultAdded​(java.lang.Object r,
                                    java.lang.Object parent)
        Informs all registered ResultListener that a new result was added.
        Parameters:
        r - New child result added
        parent - Parent result that was added to
      • fireResultRemoved

        public void fireResultRemoved​(java.lang.Object r,
                                      java.lang.Object parent)
        Informs all registered ResultListener that a new result has been removed.
        Parameters:
        r - result that has been removed
        parent - Parent result that has been removed