org.haphazard.util
Class IDServer

java.lang.Object
  extended byorg.haphazard.util.IDServer

public class IDServer
extends java.lang.Object

Controls and keeps track of all known ids of the world.


Method Summary
 void assign(long id, java.lang.Object object)
          Assigns an id to an object for easy retrieval of objects
 void clear()
          Clears the ID structure
 long create()
          Creates a new id.
 void create(GraphicalObject object)
          Creates and assigns an id to a graphical object
 java.lang.Object get(long id)
          Gets an object that has been assigned an id.
static IDServer getInstance()
          Gets the single instance of the ID server
 void remove(long id)
          Removes a certain id from the server
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static IDServer getInstance()
Gets the single instance of the ID server

Returns:
The singleton instance of the ID server

assign

public void assign(long id,
                   java.lang.Object object)
Assigns an id to an object for easy retrieval of objects

Parameters:
id - The ID to assign
object - The object that should be assigned to the id

get

public java.lang.Object get(long id)
Gets an object that has been assigned an id.

Parameters:
id - The id to find
Returns:
The object, null if none exists

remove

public void remove(long id)
Removes a certain id from the server

Parameters:
id - The id to remove

create

public long create()
Creates a new id.

Returns:
A unique id to use

create

public void create(GraphicalObject object)
Creates and assigns an id to a graphical object

Parameters:
object - The object to assign an id to

clear

public void clear()
Clears the ID structure