rafa
Class NameRegistry

java.lang.Object
  extended by rafa.NameRegistry
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.util.EventListener

public class NameRegistry
extends java.lang.Object
implements java.beans.PropertyChangeListener

Very simple registry of named objects.

Author:
rafa

Method Summary
 void clear()
          Cleans the register up.
 Named get(java.lang.String name)
           
 java.util.Collection<Named> getAll()
          Retrieves all of the registered objects.
 java.util.Collection<Named> getAll(java.lang.Class<?> aClass)
          Retrieves all the registered objects of a given class.
 java.util.Collection<java.lang.String> getAllNames(java.lang.Class<?> aClass)
          Retrieves all of the names for registered objects of a given class.
static NameRegistry getInstance()
          This class is a singleton.
 void propertyChange(java.beans.PropertyChangeEvent evt)
          Updates the registry table with added/modified/removed names.
 Named remove(java.lang.String name)
          Removes a name from the register.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static NameRegistry getInstance()
This class is a singleton.

Returns:
the only instance of this class.

getAll

public java.util.Collection<Named> getAll()
Retrieves all of the registered objects.

Returns:
all of the registered objects.

getAll

public java.util.Collection<Named> getAll(java.lang.Class<?> aClass)
Retrieves all the registered objects of a given class.

Parameters:
aClass - the Class used as selector.
Returns:
a collection of named, registered objects of that class.

getAllNames

public java.util.Collection<java.lang.String> getAllNames(java.lang.Class<?> aClass)
Retrieves all of the names for registered objects of a given class.

Parameters:
aClass - the Class used as selector.
Returns:
a collection of names of registered objects of that class.

get

public Named get(java.lang.String name)

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Updates the registry table with added/modified/removed names.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
evt -
Throws:
ExistingNameException - if a new/changing name is already registered.

remove

public Named remove(java.lang.String name)
Removes a name from the register.

Parameters:
name - the removed name.
Returns:
the unregistered object.

clear

public void clear()
Cleans the register up.



Copyright © 2008-2009. All Rights Reserved.