org.gjt.universe
Class SystemList

java.lang.Object
  |
  +--org.gjt.universe.SystemList

public final class SystemList
extends java.lang.Object


Field Summary
private static DBList DB
           
 
Constructor Summary
private SystemList()
           
 
Method Summary
(package private) static void add(SystemBase obj)
          This method adds a new system to the master list.
static java.util.Enumeration elements()
          This method returns and enumeration of the system list.
static SystemBase get(SystemID idx)
          This method returns the star system with the given ID.
static SystemBase getRandomSystem()
          This method returns a star system randomly selected from the list.
static SystemID getRandomSystemID()
          This method returns the ID of a star system randomly selected from the list.
static VectorSystemID getRandomSystemIDs(int n)
          This method returns a list of distinct IDs of a star system randomly selected from the list.
(package private) static void readObject(java.io.ObjectInputStream in)
          This method adds the star systems stored in the given stream (via an earlier call to writeObject) to the master list.
static int size()
          This method returns the number of star systems currently in the master list.
(package private) static void writeObject(java.io.ObjectOutputStream out)
          This method appends the current contents of the system list to the given output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DB

private static DBList DB
Constructor Detail

SystemList

private SystemList()
Method Detail

add

static void add(SystemBase obj)
This method adds a new system to the master list. This is normally only done during the galaxy creation phase of game start-up and is handled automatically by the designated constructor of the SystemBase class.

Parameters:
obj - The new star system to be added to the master list.

get

public static SystemBase get(SystemID idx)
This method returns the star system with the given ID.

Parameters:
idx - The unique ID of the desired star system.

size

public static int size()
This method returns the number of star systems currently in the master list.


writeObject

static void writeObject(java.io.ObjectOutputStream out)
                 throws java.io.IOException
This method appends the current contents of the system list to the given output stream. This method is used to persistently store the list of star systems when saving a game.

Parameters:
out - The output stream to which a copy of the current system list is to be written.
java.io.IOException

readObject

static void readObject(java.io.ObjectInputStream in)
                throws java.io.IOException,
                       java.lang.ClassNotFoundException
This method adds the star systems stored in the given stream (via an earlier call to writeObject) to the master list. This is typically done when restoring a saved game.

java.io.IOException
java.lang.ClassNotFoundException

elements

public static java.util.Enumeration elements()
This method returns and enumeration of the system list. No particular order is guaranteed.


getRandomSystemID

public static SystemID getRandomSystemID()
This method returns the ID of a star system randomly selected from the list. This method is slightly more efficient than getRandomSystem() and, therefore, should be used when only an ID, and not the actual system object, is needed.

See Also:
getRandomSystem

getRandomSystem

public static SystemBase getRandomSystem()
This method returns a star system randomly selected from the list. This method is implemented by calling getRandomSystemID and then looking up the desired system.

See Also:
getRandomSystemID

getRandomSystemIDs

public static VectorSystemID getRandomSystemIDs(int n)
This method returns a list of distinct IDs of a star system randomly selected from the list.

Parameters:
n - The number distinct system IDs desired.
See Also:
getRandomSystemID


Copyright © 2001 Universe Dev Team All Rights Reserved.