jigcell.compare.impl
Class Blackboard

java.lang.Object
  extended by jigcell.compare.impl.Blackboard

public final class Blackboard
extends java.lang.Object

A wrapper for the Comparator backend that supports a blackboard style interface.

This code is licensed under the DARPA BioCOMP Open Source License. See LICENSE for more details.

Author:
Nicholas Allen

Field Summary
private  Compare compare
          Wrapped Comparator
private  java.lang.String name
          Name of the current namespace, or null if the current namespace is not a top-level namespace
private  java.util.Map namespace
          Current working namespace
 
Constructor Summary
  Blackboard(Compare compare)
          Creates a new blackboard wrapper.
private Blackboard(Compare compare, java.util.Map namespace, java.lang.String name)
          Creates a new blackboard wrapper.
 
Method Summary
 boolean addData(java.lang.String name, java.lang.Object value)
          Adds a data item to the blackboard.
 void addListener(java.beans.PropertyChangeListener listener)
          Adds a listener to the blackboard.
 void addListener(java.lang.String property, java.beans.PropertyChangeListener listener)
          Adds a listener to the blackboard for a specific property.
 Blackboard addNamespace(java.lang.String name)
          Adds a namespace to the blackboard.
 java.lang.Object getData(java.lang.String name)
          Retrieves a data item from the blackboard.
 Blackboard getNamespace(java.lang.String name)
          Retrieves a namespace from the blackboard.
 void notify(java.lang.String name)
          Notifies other blackboard users about a resource change.
 boolean remove(java.lang.String name)
          Removes a data item or namespace from the blackboard.
 void removeListener(java.beans.PropertyChangeListener listener)
          Removes a listener to the blackboard.
 void removeListener(java.lang.String property, java.beans.PropertyChangeListener listener)
          Removes a listener to the blackboard for a specific property.
 java.util.List scan()
          Returns all of the data items and namespaces in this namespace as a list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

compare

private final Compare compare
Wrapped Comparator


namespace

private final java.util.Map namespace
Current working namespace


name

private final java.lang.String name
Name of the current namespace, or null if the current namespace is not a top-level namespace

Constructor Detail

Blackboard

public Blackboard(Compare compare)
Creates a new blackboard wrapper.

Parameters:
compare - Comparator to wrap

Blackboard

private Blackboard(Compare compare,
                   java.util.Map namespace,
                   java.lang.String name)
Creates a new blackboard wrapper.

Parameters:
compare - Comparator to wrap
namespace - Sub-blackboard view
name - Name of the sub-blackboard, or null if the sub-blackboard is not a top-level namespace
Method Detail

addData

public boolean addData(java.lang.String name,
                       java.lang.Object value)
Adds a data item to the blackboard. Returns whether the item was successfully added. If the addition was not successful, another entity with that name already exists.

Parameters:
name - Data identifier
value - Data value

addListener

public void addListener(java.beans.PropertyChangeListener listener)
Adds a listener to the blackboard. The listener will receive all notifications for the top-level blackboard even if this is a sub-blackboard.

Parameters:
listener - Listener

addListener

public void addListener(java.lang.String property,
                        java.beans.PropertyChangeListener listener)
Adds a listener to the blackboard for a specific property. The listener will receive all notifications for that property for the top-level blackboard even if this is a sub-blackboard.

Parameters:
property - Property
listener - Listener

addNamespace

public Blackboard addNamespace(java.lang.String name)
Adds a namespace to the blackboard. Returns the namespace as an independent sub-blackboard if successfully added. If the addition was not successful, another entity with that name already exists.

Parameters:
name - Namespace name

getData

public java.lang.Object getData(java.lang.String name)
Retrieves a data item from the blackboard. A namespace can be retrieved as a data item, and appears as a map. If there is no item with the given name, null is returned.

Parameters:
name - Data identifier

getNamespace

public Blackboard getNamespace(java.lang.String name)
Retrieves a namespace from the blackboard. The namespace appears as an independent sub-blackboard. If there is no namespace with the given name, null is returned.

Parameters:
name - Namespace name

notify

public void notify(java.lang.String name)
Notifies other blackboard users about a resource change.

Parameters:
name - Resource name

remove

public boolean remove(java.lang.String name)
Removes a data item or namespace from the blackboard. Returns whether there was an entity to remove.

Parameters:
name - Name

removeListener

public void removeListener(java.beans.PropertyChangeListener listener)
Removes a listener to the blackboard. The listener will not receive any notifications from the top-level blackboard even if this is a sub-blackboard.

Parameters:
listener - Listener

removeListener

public void removeListener(java.lang.String property,
                           java.beans.PropertyChangeListener listener)
Removes a listener to the blackboard for a specific property. The listener will not receive any notifications for that property for the top-level blackboard even if this is a sub-blackboard.

Parameters:
property - Property
listener - Listener

scan

public java.util.List scan()
Returns all of the data items and namespaces in this namespace as a list. The list creation is atomic.