org.gjt.universe
Class Index

java.lang.Object
  |
  +--org.gjt.universe.Index
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable
Direct Known Subclasses:
CivID, CostID, FleetID, GalaxyID, KnowledgeID, ModuleDesignID, ModuleID, PlanetID, PlayerID, ShipDesignID, ShipID, StationID, SystemID, TechID, WormholeID

public abstract class Index
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

This is the base class for all ID classes. All ID classes are used to access objects in the database.

Author:
Sean Starkey
See Also:
DBList, Serialized Form

Field Summary
private  int value
          The value of the ID.
 
Constructor Summary
protected Index(int in)
          Used to create the Index object.
 
Method Summary
 boolean equals(java.lang.Object obj)
          This method compares two Index objects.
 int get()
          Returns the ID of this object.
 DisplayNode getDisplayNodeChildren(CivID AID)
          Returns a DisplayNode that represents the children of this object.
 DisplayNodeColor getDisplayNodeColor(CivID AID)
          Returns the color surrounding the image in the tree.
 java.lang.String getDisplayNodeImage()
          Returns the Image used in the display tree
abstract  java.lang.String getDisplayNodeMessage()
          Returns the message displayed in the tree for this Index.
abstract  DBItem getItem()
          Returns the object from the database that this index is pointing.
 int hashCode()
          Use the index to hash these objects.
(package private)  void increment()
          Increments the ID of this object.
protected  void set(int in)
          Sets the ID of this object.
 java.lang.String toString()
          The String equivalent is just the ID number.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

value

private int value
The value of the ID.

Constructor Detail

Index

protected Index(int in)
Used to create the Index object. A unique ID should be used for each object (of the same type.)

Parameters:
in - ID for this object
Method Detail

get

public int get()
Returns the ID of this object.

Returns:
The ID.

set

protected void set(int in)
Sets the ID of this object.

Parameters:
in - The ID

increment

void increment()
Increments the ID of this object. Useful in database classes that are keeping track of the next ID that can be allocated.


getItem

public abstract DBItem getItem()
Returns the object from the database that this index is pointing.


getDisplayNodeChildren

public DisplayNode getDisplayNodeChildren(CivID AID)
Returns a DisplayNode that represents the children of this object.

Parameters:
AID - The "viewer" of this tree.
See Also:
GUIDisplayTreeJFC

getDisplayNodeMessage

public abstract java.lang.String getDisplayNodeMessage()
Returns the message displayed in the tree for this Index.

See Also:
GUIDisplayTreeJFC

getDisplayNodeImage

public java.lang.String getDisplayNodeImage()
Returns the Image used in the display tree

See Also:
GUIDisplayTreeJFC

getDisplayNodeColor

public DisplayNodeColor getDisplayNodeColor(CivID AID)
Returns the color surrounding the image in the tree.

Parameters:
AID - The viewer of this tree.
See Also:
GUIDisplayTreeJFC

equals

public boolean equals(java.lang.Object obj)
This method compares two Index objects. It is important to realize that two Index of the same type with the same ID are equal. Two Index objects of different types with the same ID are not equal.

Overrides:
equals in class java.lang.Object
Parameters:
obj - Object to compare.
Returns:
Are these objects the same?

hashCode

public int hashCode()
Use the index to hash these objects. Makes sense since each ID is unique...

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
The String equivalent is just the ID number.

Overrides:
toString in class java.lang.Object


Copyright © 2001 Universe Dev Team All Rights Reserved.