discovery.model
Class IDGenerator

java.lang.Object
  extended by discovery.model.IDGenerator

public class IDGenerator
extends java.lang.Object

This class is responsible for generating unique ID numbers for components, connections and narratives. It contains three static methods, each of which return the next available integer that can be used as a unique ID for either a component, connection or narrative. The use of static methods means that no IDGenerator object needs to be instantiated by the class using the IDGenerator. The methods in this class are called by the constructor of components, connections and narratives when they are being newly created.


Constructor Summary
IDGenerator()
           
 
Method Summary
static int generateComponentID()
          This method returns a unique integer ID number for a component model object.
static int generateConnectionID()
          This method returns a unique integer ID number for a connection model object.
static int generateNarrativeID()
          This method returns a unique integer ID number for a Narrative object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IDGenerator

public IDGenerator()
Method Detail

generateComponentID

public static int generateComponentID()
This method returns a unique integer ID number for a component model object. It should only be called by the constructor of a class implementing the ComponentModel interface. The method reads the integer in the file 'componentID.dat', increments that integer, returns the new integer number and saves the new integer number to the file.

Returns:
a unique integer ID number for a component

generateConnectionID

public static int generateConnectionID()
This method returns a unique integer ID number for a connection model object. It should only be called by the constructor of a ConnectionModel object. The method reads the integer in the file 'connectionID.dat', increments that integer, returns the new integer number and saves the new integer number to the file.

Returns:
a unique integer ID number for a connection

generateNarrativeID

public static int generateNarrativeID()
This method returns a unique integer ID number for a Narrative object. It should only be called by the constructor of a Narrative object. The method reads the integer in the file 'narrativeID.dat', increments that integer, returns the new integer number and saves the new integer number to the file.

Returns:
a unique integer ID number for a component