net.sourceforge.basher.impl
Class InMemoryEntityRegistry

java.lang.Object
  extended by net.sourceforge.basher.impl.InMemoryEntityRegistry
All Implemented Interfaces:
EntityRegistry
Direct Known Subclasses:
LimitedInMemoryEntityRegistry

public class InMemoryEntityRegistry
extends Object
implements EntityRegistry

Version:
1.0
Author:
Johan Lindquist

Constructor Summary
InMemoryEntityRegistry()
           
 
Method Summary
 Collection getAllRegistered(String entityIdentifier)
          Retrieves all registered entity instances for a particular entityIdentifier.
 long getNumRegistered(String entityIdentifier)
          Retrieves the number of entity instances registered for the specified entityIdentifier.
 Object getRandom(String entityIdentifier)
          Retrieves a random entity instance registered for the specified entityIdentifier.
 Collection getRandomSelection(String entityIdentifier, int size)
          Retrieves a randomly sized collection of entity instances registered for the specified entityIdentifier.
 void register(String entityIdentifier, Object entity)
          Register a certain type as having been created.
 void setLog(org.apache.commons.logging.Log logger)
           
 void setRandomizer(Randomizer randomizer)
           
 void unregister(String entityIdentifier, Object entity)
          Removes the specified entity from the registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InMemoryEntityRegistry

public InMemoryEntityRegistry()
Method Detail

setLog

public void setLog(org.apache.commons.logging.Log logger)

setRandomizer

public void setRandomizer(Randomizer randomizer)

unregister

public void unregister(String entityIdentifier,
                       Object entity)
Description copied from interface: EntityRegistry
Removes the specified entity from the registry.

Specified by:
unregister in interface EntityRegistry
Parameters:
entityIdentifier - The entity type to remove.
entity - The entity to remove

register

public void register(String entityIdentifier,
                     Object entity)
Description copied from interface: EntityRegistry
Register a certain type as having been created. The entityIdentifier is a key into a collection of entity instances being held by the EntityRegistry.

Specified by:
register in interface EntityRegistry
Parameters:
entityIdentifier - The type of the entity being registered
entity - The entity being registered

getAllRegistered

public Collection getAllRegistered(String entityIdentifier)
Description copied from interface: EntityRegistry
Retrieves all registered entity instances for a particular entityIdentifier.

Specified by:
getAllRegistered in interface EntityRegistry
Parameters:
entityIdentifier - The entity type to retrive the entity instances for
Returns:
A collection of entity.

getNumRegistered

public long getNumRegistered(String entityIdentifier)
Description copied from interface: EntityRegistry
Retrieves the number of entity instances registered for the specified entityIdentifier.

Specified by:
getNumRegistered in interface EntityRegistry
Parameters:
entityIdentifier - The entity type to count
Returns:
The number of instances registered for the specified entityIdentifier.

getRandomSelection

public Collection getRandomSelection(String entityIdentifier,
                                     int size)
Description copied from interface: EntityRegistry
Retrieves a randomly sized collection of entity instances registered for the specified entityIdentifier.

Specified by:
getRandomSelection in interface EntityRegistry
Parameters:
entityIdentifier - The entity type to generate the random selection from
size - The maximum number of entity instances in the collection.
Returns:
A collection of entity instances. The size of this collection may be less than the maxSize specified if there are less entity instances registered than is requested.

getRandom

public Object getRandom(String entityIdentifier)
Description copied from interface: EntityRegistry
Retrieves a random entity instance registered for the specified entityIdentifier.

Specified by:
getRandom in interface EntityRegistry
Parameters:
entityIdentifier - The entity type to retrieve the instance for.
Returns:
The entity instance or null if none could be found.


Copyright © 2006-2010 Basher Team. All Rights Reserved.