jade.wrapper
Class StateBase

java.lang.Object
  |
  +--jade.wrapper.StateBase
Direct Known Subclasses:
AgentState, PlatformState

public abstract class StateBase
extends java.lang.Object
implements State, Comparable, Serializable

Provides an abstract base class for implementations of state.

Author:
David Bell, Dick Cowan: Hewlett-Packard
See Also:
Serialized Form

Method Summary
 int compareTo(java.lang.Object object)
          Compares a given object to this state object for the purpose of collating.
 boolean equals(java.lang.Object object)
          Determines if an object is equal to this object.
 int getCode()
          Return the integer code that identifies this state.
 java.lang.String getName()
          Returns the descriptive name of the state.
 int hashCode()
          Returns the hash code for this state.
 java.lang.String toString()
          A string representation of this state.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getName

public java.lang.String getName()
Returns the descriptive name of the state.
Specified by:
getName in interface State
Returns:
The descriptive name of the state. Will never return null.

getCode

public int getCode()
Return the integer code that identifies this state.
Specified by:
getCode in interface State
Returns:
The integer code that identifies this state.

equals

public boolean equals(java.lang.Object object)
Determines if an object is equal to this object. In order for the the passed object to be equal to this one the passed object must be an instance if State and contain the same state code.
Overrides:
equals in class java.lang.Object
Parameters:
object - An object to test for equality.
Returns:
True if the object represent the same state and False otherwise.

compareTo

public int compareTo(java.lang.Object object)
Compares a given object to this state object for the purpose of collating. This method is used for the sorting of states. A positive value means the receiver (this object) is "greater than" the passed object. A negative value means the receiver is "less than" the passed object. A value of zero means the receiver and the passed object are equal to each other.
Parameters:
object - An object to compare this object to.
Returns:
The result of the comparison.

The value 1 is returned if:

  • the passed object is null (the receiver is considered "greater than" null objects)
  • the state code held by the receiver (this object) is greater than the code of the passed object

The value 0 (zero) is returned if:

  • the two state objects hold the same state code

The value -1 is returned if:

  • the passed object is not a AgentStateImpl object (the receiver is considered "less than" objects of other types)
  • the state code held by the receiver (this object) is less than the code of the passed object

    hashCode

    public int hashCode()
    Returns the hash code for this state. The hash code equals the state code.
    Overrides:
    hashCode in class java.lang.Object
    Returns:
    The state code for this state.

    toString

    public java.lang.String toString()
    A string representation of this state. The returned string is of the form StateName(StateCode).
    Specified by:
    toString in interface State
    Overrides:
    toString in class java.lang.Object
    Returns:
    A string containing the name and code for this state.