jade.core
Class AgentState

java.lang.Object
  extended by jade.core.AgentState

public class AgentState
extends java.lang.Object

This class represents the Life-Cycle state of an agent.

Version:
$Date: 2004-08-20 12:14:20 +0200 (ven, 20 ago 2004) $ $Revision: 5282 $
Author:
Giovanni Rimassa - Universita' di Parma

Constructor Summary
AgentState()
          Default constructor.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares two agent states.
 boolean equals(java.lang.Object o)
          Equality operations between agent states.
static AgentState[] getAllInstances()
          Access the whole prototypes array.
static AgentState getInstance(int value)
          Static access method to retrieve a prototype object for an agent life-cycle state.
 java.lang.String getName()
          Retrieve the name of this state.
 int getValue()
          Retrieve the numeric value of this state, in agreement with the AP_XXX constants defined in the Agent class.
 int hashCode()
          Calculate an hash code for this agent state.
 void setName(java.lang.String n)
          Set the name of this state.
 void setValue(int v)
          Set the numeric value of this state, in agreement with the AP_XXX constants defined in the Agent class.
 java.lang.String toString()
          Retrieve a string representation for this agent state.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AgentState

public AgentState()
Default constructor. A default constructor is necessary for this class because it is used in the jade-introspection ontology. Application code should use the static access method getInstance(), however.

Method Detail

getInstance

public static AgentState getInstance(int value)
Static access method to retrieve a prototype object for an agent life-cycle state.

Parameters:
value - One of the AP_XXX constants defined in the Agent class.
Returns:
A prototype object for the requested state.

getAllInstances

public static AgentState[] getAllInstances()
Access the whole prototypes array.

Returns:
All the defined prototype objects for the life-cycle states.

setName

public void setName(java.lang.String n)
Set the name of this state.

Parameters:
n - The name to give.

getName

public java.lang.String getName()
Retrieve the name of this state.

Returns:
The state name.

setValue

public void setValue(int v)
Set the numeric value of this state, in agreement with the AP_XXX constants defined in the Agent class.

Parameters:
v - The numeric value for this state.

getValue

public int getValue()
Retrieve the numeric value of this state, in agreement with the AP_XXX constants defined in the Agent class.

Returns:
The numeric value set for this state.

equals

public boolean equals(java.lang.Object o)
Equality operations between agent states. The equality operation is defined as equality by state name (case insensitive string comparison is used).

Overrides:
equals in class java.lang.Object
Parameters:
o - The right-hand side of the equality.
Returns:
If the current object and the parameter are equal (according to the criterion above), this method returns true, otherwise it returns false.

toString

public java.lang.String toString()
Retrieve a string representation for this agent state.

Overrides:
toString in class java.lang.Object
Returns:
The state name.

compareTo

public int compareTo(java.lang.Object o)
Compares two agent states. A lexicographical, case insensitive comparison on state name is used.

Parameters:
o - The object to compare the current object to.
Returns:
An integer value, -1, 0 or 1 depending upon whether the current object is lesser, equal or greater than the given parameter.
Throws:
java.lang.ClassCastException - If the given parameter is not an instance of AgentState.

hashCode

public int hashCode()
Calculate an hash code for this agent state.

Overrides:
hashCode in class java.lang.Object
Returns:
An integer value, complying with the defined equality operation on AgentState instances.