net.sourceforge.basher
Interface EntityRegistry

All Known Implementing Classes:
InMemoryEntityRegistry, LimitedInMemoryEntityRegistry

public interface EntityRegistry

Simple registry where tasks may store objects to be used during runtime. Warning: This is currenly backed by an in-memory store, which means that heavy use of this may cause a degradation in performance over time.

Version:
1.0
Author:
Johan Lindquist

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 maxSize)
          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 unregister(String entityIdentifier, Object entity)
          Removes the specified entity from the registry.
 

Method Detail

register

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

Parameters:
entityIdentifier - The type of the entity being registered
entity - The entity being registered

getAllRegistered

Collection getAllRegistered(String entityIdentifier)
Retrieves all registered entity instances for a particular entityIdentifier.

Parameters:
entityIdentifier - The entity type to retrive the entity instances for
Returns:
A collection of entity.

getNumRegistered

long getNumRegistered(String entityIdentifier)
Retrieves the number of entity instances registered for the specified entityIdentifier.

Parameters:
entityIdentifier - The entity type to count
Returns:
The number of instances registered for the specified entityIdentifier.

getRandomSelection

Collection getRandomSelection(String entityIdentifier,
                              int maxSize)
Retrieves a randomly sized collection of entity instances registered for the specified entityIdentifier.

Parameters:
entityIdentifier - The entity type to generate the random selection from
maxSize - 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

Object getRandom(String entityIdentifier)
Retrieves a random entity instance registered for the specified entityIdentifier.

Parameters:
entityIdentifier - The entity type to retrieve the instance for.
Returns:
The entity instance or null if none could be found.

unregister

void unregister(String entityIdentifier,
                Object entity)
Removes the specified entity from the registry.

Parameters:
entityIdentifier - The entity type to remove.
entity - The entity to remove


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