Package jade.core

Class AgentState


  • public class AgentState
    extends Object
    This class represents the Life-Cycle state of an agent.
    Version:
    $Date$ $Revision$
    Author:
    Giovanni Rimassa - Universita' di Parma
    • 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​(String n)
        Set the name of this state.
        Parameters:
        n - The name to give.
      • getName

        public 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​(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 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 String toString()
        Retrieve a string representation for this agent state.
        Overrides:
        toString in class Object
        Returns:
        The state name.
      • compareTo

        public int compareTo​(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:
        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 Object
        Returns:
        An integer value, complying with the defined equality operation on AgentState instances.