net.javamud.data
Class MORegistry

java.lang.Object
  |
  +--net.javamud.data.MORegistry

public class MORegistry
extends Object

MudObject Registry

Author:
Timothy Hinchcliffe
Created On:
11 May 2002

Nested Class Summary
private  class MORegistry.MORIterator
          Iterator for MORegistry
 
Field Summary
private  Map bwdMap
          Backward Map - MudObject->Identity
private  Map fwdMap
          Forward Map - Identity->MudObject
 
Constructor Summary
MORegistry()
          Constructor for the MORegistry object
 
Method Summary
 void add(MudObject object)
          Add a MudObject to registry.
 boolean contains(MudObject object)
          Return true if registry contains the MudObject.
 boolean contains(String identity)
          Returns true if registry contains the MudObject identified by identity.
 String get(MudObject object)
          Get (registered) identity of MudObject
 MudObject get(String identity)
          Get MudObject associated with identity
 Iterator iterator()
          Returns an Iterator for this object.
 String remove(MudObject object)
          Remove object from the registry
 MudObject remove(String identity)
          Remove identity from the registry
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bwdMap

private Map bwdMap
Backward Map - MudObject->Identity


fwdMap

private Map fwdMap
Forward Map - Identity->MudObject

Constructor Detail

MORegistry

public MORegistry()
Constructor for the MORegistry object

Method Detail

get

public MudObject get(String identity)
Get MudObject associated with identity

Parameters:
identity - Which MudObject to return
Returns:
The requested MudObject or null

get

public String get(MudObject object)
Get (registered) identity of MudObject

Parameters:
object - MudObject to check
Returns:
Registered identity

add

public void add(MudObject object)
         throws DuplicateIdentityException
Add a MudObject to registry. If object is registered with a different Identity, then that registration is removed and this one added.

Parameters:
object - MudObject to add
Throws:
DuplicateIdentityException - Thrown if object.getIdentity() returns the same as the Identity registered for a different object.

contains

public boolean contains(String identity)
Returns true if registry contains the MudObject identified by identity.

Parameters:
identity - Item to search for
Returns:
If found
See Also:
Set.contains(Object)

contains

public boolean contains(MudObject object)
Return true if registry contains the MudObject.

Parameters:
object - Item to search for
Returns:
If found
See Also:
Set.contains(Object)

iterator

public Iterator iterator()
Returns an Iterator for this object. Don't mess with MORegistry while using Iterator except through Iterator functions as I'm not sure what'll happen but it's bound to be nasty.

Returns:
the Iterator

remove

public String remove(MudObject object)
Remove object from the registry

Parameters:
object - MudObject to remove
Returns:
registered identity of object

remove

public MudObject remove(String identity)
Remove identity from the registry

Parameters:
identity - Identity of MudObject to remove
Returns:
MudObject associated with identity