gumbo.visualize.data
Class DataModelMonitor

java.lang.Object
  |
  +--gumbo.visualize.data.DataModelMonitor

public class DataModelMonitor
extends java.lang.Object

Singleton (global) monitor for data models. All data models are responsible for adding and removing themselves from this monitor. Monitors data model state changes and maps clientIDs to data models.

Version:
$Revision: 1.7 $
Author:
Jon Barrilleaux (jonb@jmbaai.com) of JMB and Associates Inc.

Field Summary
static DataModelMonitor GLOBAL
           
 
Method Summary
 void addDataModelListener(DataModel target, DataModelListener listener)
          Adds a data model event listener, which will be notified anytime a change affects the target data model.
 java.util.Collection findAllDataModels(java.util.Collection clientIds, java.util.Collection retVal)
          Convenience method that finds the data models corresponding to a group of client models.
 DataModel findDataModel(java.lang.Object clientId)
          Finds the singleton data model corresponding to a given client model.
 java.util.Collection findDataModels(java.lang.Object clientId, java.util.Collection retVal)
          Finds the data models corresponding to a given client model.
 void removeDataModelListener(DataModelListener listener)
          Removes a data model event listener, for all target data models.
 void syncDataModelListener(DataModelListener listener)
          Syncs a data model event listener with the dynamic model state related to all its registered target models by sending appropriate "add" and "changed" events.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GLOBAL

public static final DataModelMonitor GLOBAL
Method Detail

findDataModel

public DataModel findDataModel(java.lang.Object clientId)
Finds the singleton data model corresponding to a given client model.

Parameters:
clientId - The client model's client ID. None if null.
Throws:
java.lang.IllegalStateException - More than one model found.

findDataModels

public java.util.Collection findDataModels(java.lang.Object clientId,
                                           java.util.Collection retVal)
Finds the data models corresponding to a given client model.

Parameters:
clientId - The client model's client ID. Null if none.
retVal - Return value object. Set of data models (DataModel). Never null. Empty if clientId is null or none are found.
Returns:
Reference to retVal. Never null.

findAllDataModels

public java.util.Collection findAllDataModels(java.util.Collection clientIds,
                                              java.util.Collection retVal)
Convenience method that finds the data models corresponding to a group of client models.

Parameters:
clientIds - The client models' client IDs (Object). Never null.
retVal - Return value object. Set of data models (DataModel). Never null. Can be clientIds.
Returns:
Reference to retVal. Never null.

addDataModelListener

public void addDataModelListener(DataModel target,
                                 DataModelListener listener)
Adds a data model event listener, which will be notified anytime a change affects the target data model. The listener order is undefined.

Parameters:
target - The target data model. Never null.
listener - The event listener. Never null. If the listener is a duplicate, the previous entry will be replaced.

removeDataModelListener

public void removeDataModelListener(DataModelListener listener)
Removes a data model event listener, for all target data models.

Parameters:
listener - The event listener. Silently ignores missing and null listeners.

syncDataModelListener

public void syncDataModelListener(DataModelListener listener)
Syncs a data model event listener with the dynamic model state related to all its registered target models by sending appropriate "add" and "changed" events. The order of targets and events is undefined.

Parameters:
listener - The event listener. Silently ignores null and missing.