public class DatabaseEventManager extends Object
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
DatabaseEventManager() |
Modifier and Type | Method and Description |
---|---|
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) . |
private EventListenerList listenerList
private boolean accumulateDataStoreEvents
private DataStoreEvent.Type currentDataStoreEventType
private HashSetModifiableDBIDs dataStoreObjects
public void accumulateDataStoreEvents()
flushDataStoreEvents()
is called or a
different event type occurs.flushDataStoreEvents()
,
DataStoreEvent
public void flushDataStoreEvents()
accumulateDataStoreEvents()
was called.public void addListener(DataStoreListener l)
DataStoreListener
for a DataStoreEvent
posted after the content of the database changes.l
- the listener to addremoveListener(DataStoreListener)
,
DataStoreListener
,
DataStoreEvent
public void removeListener(DataStoreListener l)
DataStoreListener
previously added with
addListener(DataStoreListener)
.l
- the listener to removeaddListener(DataStoreListener)
,
DataStoreListener
,
DataStoreEvent
public void addListener(ResultListener l)
ResultListener
to be notified on new results.l
- the listener to addremoveListener(ResultListener)
,
ResultListener
,
Result
public void removeListener(ResultListener l)
ResultListener
previously added with
addListener(ResultListener)
.l
- the listener to removeaddListener(ResultListener)
,
ResultListener
,
Result
public void fireObjectsInserted(DBIDs insertions)
fireObjectsChanged(insertions,
DataStoreEvent.Type.INSERT)
.insertions
- the objects that have been insertedfireObjectsChanged(de.lmu.ifi.dbs.elki.database.ids.DBIDs, de.lmu.ifi.dbs.elki.database.datastore.DataStoreEvent.Type)
,
DataStoreEvent.Type.INSERT
public void fireObjectInserted(DBID insertion)
fireObjectChanged(insertion,
DataStoreEvent.Type.INSERT)
.insertion
- the object that has been insertedfireObjectsChanged(de.lmu.ifi.dbs.elki.database.ids.DBIDs, de.lmu.ifi.dbs.elki.database.datastore.DataStoreEvent.Type)
,
DataStoreEvent.Type.INSERT
public void fireObjectsUpdated(DBIDs updates)
fireObjectsChanged(updates,
DataStoreEvent.Type.UPDATE)
.updates
- the objects that have been updatedfireObjectsChanged(de.lmu.ifi.dbs.elki.database.ids.DBIDs, de.lmu.ifi.dbs.elki.database.datastore.DataStoreEvent.Type)
,
DataStoreEvent.Type.UPDATE
protected void fireObjectsRemoved(DBIDs deletions)
fireObjectsChanged(deletions,
DataStoreEvent.Type.DELETE)
.deletions
- the objects that have been removedfireObjectsChanged(de.lmu.ifi.dbs.elki.database.ids.DBIDs, de.lmu.ifi.dbs.elki.database.datastore.DataStoreEvent.Type)
,
DataStoreEvent.Type.DELETE
protected void fireObjectRemoved(DBID deletion)
fireObjectChanged(deletion,
DataStoreEvent.Type.DELETE)
.deletion
- the object that has been removedfireObjectsChanged(de.lmu.ifi.dbs.elki.database.ids.DBIDs, de.lmu.ifi.dbs.elki.database.datastore.DataStoreEvent.Type)
,
DataStoreEvent.Type.DELETE
private void fireObjectsChanged(DBIDs objects, DataStoreEvent.Type type)
accumulateDataStoreEvents
is set, otherwise all registered
DataStoreListener
will be notified immediately that the
content of the database has been changed.objects
- the objects that have been changed, i.e. inserted, deleted
or updatedpublic void fireResultAdded(Result r, Result parent)
ResultListener
that a new result was
added.r
- New child result addedparent
- Parent result that was added to