de.lmu.ifi.dbs.elki.database
Class DatabaseEventManager

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.database.DatabaseEventManager

public class DatabaseEventManager
extends Object


Field Summary
private  boolean accumulateDataStoreEvents
          Indicates whether DataStoreEvents should be accumulated and fired as one event on demand.
private  DataStoreEvent.Type currentDataStoreEventType
          The type of the current DataStoreEvent to be accumulated.
private  HashSetModifiableDBIDs dataStoreObjects
          The objects that were changed in the current DataStoreEvent.
private  EventListenerList listenerList
          Holds the listener.
 
Constructor Summary
DatabaseEventManager()
           
 
Method Summary
 void accumulateDataStoreEvents()
          Collects successive insertion, deletion or update events.
 void addListener(DataStoreListener l)
          Adds a DataStoreListener for a DataStoreEvent posted after the content of the database changes.
 void addListener(ResultListener l)
          Adds a ResultListener to be notified on new results.
 void fireObjectInserted(DBID insertion)
          Convenience method, calls fireObjectChanged(insertion, DataStoreEvent.Type.INSERT).
protected  void fireObjectRemoved(DBID deletion)
          Convenience method, calls fireObjectChanged(deletion, DataStoreEvent.Type.DELETE).
private  void fireObjectsChanged(DBIDs objects, DataStoreEvent.Type type)
          Handles a DataStoreEvent with the specified type.
 void fireObjectsInserted(DBIDs insertions)
          Convenience method, calls fireObjectsChanged(insertions, DataStoreEvent.Type.INSERT).
protected  void fireObjectsRemoved(DBIDs deletions)
          Convenience method, calls fireObjectsChanged(deletions, DataStoreEvent.Type.DELETE).
 void fireObjectsUpdated(DBIDs updates)
          Convenience method, calls fireObjectsChanged(updates, DataStoreEvent.Type.UPDATE).
 void fireResultAdded(Result r, Result parent)
          Informs all registered ResultListener that a new result was added.
 void fireResultRemoved(Result r, Result parent)
          Informs all registered ResultListener that a new result has been removed.
 void flushDataStoreEvents()
          Fires all collected insertion, deletion or update events as one DataStoreEvent, i.e. notifies all registered DataStoreListener how the content of the database has been changed since accumulateDataStoreEvents() was called.
 void removeListener(DataStoreListener l)
          Removes a DataStoreListener previously added with addListener(DataStoreListener).
 void removeListener(ResultListener l)
          Removes a ResultListener previously added with addListener(ResultListener).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listenerList

private EventListenerList listenerList
Holds the listener.


accumulateDataStoreEvents

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


currentDataStoreEventType

private DataStoreEvent.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

accumulateDataStoreEvents

public void accumulateDataStoreEvents()
Collects successive insertion, deletion or update events. The accumulated event will be fired when flushDataStoreEvents() is called or a different event type occurs.

See Also:
flushDataStoreEvents(), DataStoreEvent

flushDataStoreEvents

public void flushDataStoreEvents()
Fires all collected insertion, deletion or update events as one DataStoreEvent, i.e. notifies all registered DataStoreListener how the content of the database has been changed since accumulateDataStoreEvents() was called.

See Also:
accumulateDataStoreEvents, DataStoreListener, DataStoreEvent

addListener

public void addListener(DataStoreListener l)
Adds a DataStoreListener for a DataStoreEvent posted after the content of the database changes.

Parameters:
l - the listener to add
See Also:
removeListener(DataStoreListener), DataStoreListener, DataStoreEvent

removeListener

public void removeListener(DataStoreListener l)
Removes a DataStoreListener previously added with addListener(DataStoreListener).

Parameters:
l - the listener to remove
See Also:
addListener(DataStoreListener), DataStoreListener, DataStoreEvent

addListener

public void addListener(ResultListener l)
Adds a ResultListener to be notified on new results.

Parameters:
l - the listener to add
See Also:
removeListener(ResultListener), ResultListener, Result

removeListener

public void removeListener(ResultListener l)
Removes a ResultListener previously added with addListener(ResultListener).

Parameters:
l - the listener to remove
See Also:
addListener(ResultListener), ResultListener, Result

fireObjectsInserted

public void fireObjectsInserted(DBIDs insertions)
Convenience method, calls fireObjectsChanged(insertions, DataStoreEvent.Type.INSERT).

Parameters:
insertions - the objects that have been inserted
See Also:
fireObjectsChanged(de.lmu.ifi.dbs.elki.database.ids.DBIDs, de.lmu.ifi.dbs.elki.database.datastore.DataStoreEvent.Type), DataStoreEvent.Type.INSERT

fireObjectInserted

public void fireObjectInserted(DBID insertion)
Convenience method, calls fireObjectChanged(insertion, DataStoreEvent.Type.INSERT).

Parameters:
insertion - the object that has been inserted
See Also:
fireObjectsChanged(de.lmu.ifi.dbs.elki.database.ids.DBIDs, de.lmu.ifi.dbs.elki.database.datastore.DataStoreEvent.Type), DataStoreEvent.Type.INSERT

fireObjectsUpdated

public void fireObjectsUpdated(DBIDs updates)
Convenience method, calls fireObjectsChanged(updates, DataStoreEvent.Type.UPDATE).

Parameters:
updates - the objects that have been updated
See Also:
fireObjectsChanged(de.lmu.ifi.dbs.elki.database.ids.DBIDs, de.lmu.ifi.dbs.elki.database.datastore.DataStoreEvent.Type), DataStoreEvent.Type.UPDATE

fireObjectsRemoved

protected void fireObjectsRemoved(DBIDs deletions)
Convenience method, calls fireObjectsChanged(deletions, DataStoreEvent.Type.DELETE).

Parameters:
deletions - the objects that have been removed
See Also:
fireObjectsChanged(de.lmu.ifi.dbs.elki.database.ids.DBIDs, de.lmu.ifi.dbs.elki.database.datastore.DataStoreEvent.Type), DataStoreEvent.Type.DELETE

fireObjectRemoved

protected void fireObjectRemoved(DBID deletion)
Convenience method, calls fireObjectChanged(deletion, DataStoreEvent.Type.DELETE).

Parameters:
deletion - the object that has been removed
See Also:
fireObjectsChanged(de.lmu.ifi.dbs.elki.database.ids.DBIDs, de.lmu.ifi.dbs.elki.database.datastore.DataStoreEvent.Type), DataStoreEvent.Type.DELETE

fireObjectsChanged

private void fireObjectsChanged(DBIDs objects,
                                DataStoreEvent.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

fireResultAdded

public void fireResultAdded(Result r,
                            Result 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(Result r,
                              Result 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

Release 0.4.0 (2011-09-20_1324)