aim4.util
Class ArrayListRegistry<T>

java.lang.Object
  extended by aim4.util.ArrayListRegistry<T>
All Implemented Interfaces:
Registry<T>

public class ArrayListRegistry<T>
extends Object
implements Registry<T>

A registry based on array list.


Constructor Summary
ArrayListRegistry()
          Create an array list registry.
ArrayListRegistry(int initId)
          Create an array list registry.
 
Method Summary
 T get(int id)
          Retrieve an object from the registry.
 int getNewId()
          Get a new unused ID.
 boolean isIdExist(int id)
          Whether or not an object is in the registry.
 int register(T obj)
          Register an object.
 void set(int id, T obj)
          Associate an object to a given ID.
 void setNull(int id)
          Remove the object associated with a given ID from the registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayListRegistry

public ArrayListRegistry()
Create an array list registry.


ArrayListRegistry

public ArrayListRegistry(int initId)
Create an array list registry.

Parameters:
initId - the initial ID
Method Detail

register

public int register(T obj)
Description copied from interface: Registry
Register an object.

Specified by:
register in interface Registry<T>
Parameters:
obj - the object
Returns:
the ID of the object

isIdExist

public boolean isIdExist(int id)
Description copied from interface: Registry
Whether or not an object is in the registry.

Specified by:
isIdExist in interface Registry<T>
Parameters:
id - the ID of the object
Returns:
Whether or not an object is in the registry

get

public T get(int id)
Description copied from interface: Registry
Retrieve an object from the registry.

Specified by:
get in interface Registry<T>
Parameters:
id - the ID of the object
Returns:
the object

getNewId

public int getNewId()
Description copied from interface: Registry
Get a new unused ID.

Specified by:
getNewId in interface Registry<T>
Returns:
a new unused ID

set

public void set(int id,
                T obj)
Description copied from interface: Registry
Associate an object to a given ID.

Specified by:
set in interface Registry<T>
Parameters:
id - the ID
obj - the object

setNull

public void setNull(int id)
Description copied from interface: Registry
Remove the object associated with a given ID from the registry.

Specified by:
setNull in interface Registry<T>
Parameters:
id - the ID


Copyright © 2011. All Rights Reserved.