universe.common.database
Class Index

java.lang.Object
  |
  +--universe.common.database.Index
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable
Direct Known Subclasses:
CivID, FleetID, GalaxyID, PlanetID, PlayerID, StationID, SystemID, 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.

Version:
$Id: Index.java,v 1.1 2001/07/03 04:07:52 sstarkey Exp $
Author:
Sean Starkey
See Also:
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.
 int hashCode()
          Use the index to hash these objects.
 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

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


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.