Class Event

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public class Event
    extends java.lang.Object
    implements java.lang.Cloneable, java.io.Serializable
    Represents an external event that happened in the virtual world
    Author:
    Joao Dias
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String _action  
      protected java.util.ArrayList<Parameter> _parameters  
      protected short _status  
      protected java.lang.String _subject  
      protected java.lang.String _target  
      protected long _time  
      protected short _type  
    • Constructor Summary

      Constructors 
      Constructor Description
      Event​(java.lang.String subject)
      Creates a new Event
      Event​(java.lang.String subject, java.lang.String action, java.lang.String target)
      Creates a new Event
      Event​(java.lang.String subject, java.lang.String action, java.lang.String target, short type, short status)
      Creates a new event
      Event​(java.lang.String subject, java.lang.String action, java.lang.String target, short type, short status, java.lang.Long time)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void AddParameter​(Parameter param)
      Adds a Parameter to the event (usually arguments or parameters of the action)
      Event ApplyPerspective​(java.lang.String agentName)  
      java.lang.Object clone()
      Creates a new copy of the Event
      boolean equals​(java.lang.Object obj)
      Compares the event against a given object
      java.util.ArrayList<Substitution> GenerateBindings()
      Generates a List of bindings that associate the Variables [Subject], [Action],[Target],[P1],[P2],...
      java.lang.String GetAction()
      Gets the event's action
      java.util.ArrayList<Parameter> GetParameters()
      Gets the event's parameters (usually arguments or parameters of the action)
      short GetStatus()
      Gets the event's status (activation, success, failure for goal and success, failure for action)
      java.lang.String GetSubject()
      Gets the event's subject (Who performed the action)
      java.lang.String GetTarget()
      Meiyii 07/01/10 Gets the event's target (what is the target of the event's action)
      long GetTime()
      Gets the event's time
      short GetType()
      Meiyii 07/01/10 Gets the event's type (whether goal or action)
      void MakeGround​(java.util.ArrayList<Substitution> substitutions)
      Applies a set of substitutions to the object, grounding it.
      static boolean MatchEvent​(Event matchRule, Event eventPerception)
      Receives two events and sees if they match.
      static Event ParseEvent​(java.lang.String subject, java.lang.String action, java.lang.String target, java.lang.String parameters)
      Parses an event
      Event RemovePerspective​(java.lang.String agentName)  
      void SetAction​(java.lang.String action)
      Sets the event's action (what happened)
      void SetStatus​(short status)
      Meiyii 07/01/10 Sets the event's status (activation, success, failure for goal and success, failure for action)
      void SetSubject​(java.lang.String subject)
      Sets the event's subject (who performed the action)
      void SetTarget​(java.lang.String target)
      Sets the event's target (what is the target of the event's action)
      void SetType​(short type)
      Meiyii 07/01/10 Sets the event's type (goal or action)
      Name toName()
      Converts the event to a Name
      Name toStepName()
      Converts the event into the equivalent of a step's name
      java.lang.String toString()
      Converts the event to a String
      • Methods inherited from class java.lang.Object

        finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • _action

        protected java.lang.String _action
      • _parameters

        protected java.util.ArrayList<Parameter> _parameters
      • _subject

        protected java.lang.String _subject
      • _target

        protected java.lang.String _target
      • _time

        protected long _time
      • _status

        protected short _status
      • _type

        protected short _type
    • Constructor Detail

      • Event

        public Event​(java.lang.String subject)
        Creates a new Event
        Parameters:
        subject - - the subject of the event (who performed the action)
      • Event

        public Event​(java.lang.String subject,
                     java.lang.String action,
                     java.lang.String target)
        Creates a new Event
        Parameters:
        subject - - the subject of the event (who performed the action)
        action - - the action specified by the event
        target - - the target of the action
      • Event

        public Event​(java.lang.String subject,
                     java.lang.String action,
                     java.lang.String target,
                     short type,
                     short status)
        Creates a new event
        Parameters:
        subject - - the subject of the event (who performed the action)
        action - - the action specified by the event
        target - - the target of the action
        type - - the type of event
        status - - the status of the goal/action
      • Event

        public Event​(java.lang.String subject,
                     java.lang.String action,
                     java.lang.String target,
                     short type,
                     short status,
                     java.lang.Long time)
    • Method Detail

      • MatchEvent

        public static boolean MatchEvent​(Event matchRule,
                                         Event eventPerception)
        Receives two events and sees if they match. Two events match if they refer to the same subject, action, target and parameters
        Parameters:
        matchRule - - left Event to be matched
        eventPerception - - right Event to be matched
        Returns:
        true if the events match, false otherwise
      • ApplyPerspective

        public Event ApplyPerspective​(java.lang.String agentName)
      • RemovePerspective

        public Event RemovePerspective​(java.lang.String agentName)
      • ParseEvent

        public static Event ParseEvent​(java.lang.String subject,
                                       java.lang.String action,
                                       java.lang.String target,
                                       java.lang.String parameters)
        Parses an event
        Parameters:
        subject -
        action -
        target -
        parameters -
        Returns:
        the parsed Event
      • AddParameter

        public void AddParameter​(Parameter param)
        Adds a Parameter to the event (usually arguments or parameters of the action)
        Parameters:
        param - - the Parameter to add
        See Also:
        Parameter
      • GetAction

        public java.lang.String GetAction()
        Gets the event's action
        Returns:
        the event's action
      • GetParameters

        public java.util.ArrayList<Parameter> GetParameters()
        Gets the event's parameters (usually arguments or parameters of the action)
        Returns:
        an ArrayList with all the parameters
        See Also:
        Parameter
      • GetSubject

        public java.lang.String GetSubject()
        Gets the event's subject (Who performed the action)
        Returns:
        the event's subject
      • GetTarget

        public java.lang.String GetTarget()
        Meiyii 07/01/10 Gets the event's target (what is the target of the event's action)
        Returns:
        the event's target
      • GetType

        public short GetType()
        Meiyii 07/01/10 Gets the event's type (whether goal or action)
        Returns:
        the event's type
      • GetStatus

        public short GetStatus()
        Gets the event's status (activation, success, failure for goal and success, failure for action)
        Returns:
        the event's status
      • GetTime

        public long GetTime()
        Gets the event's time
        Returns:
        the event's time
      • SetAction

        public void SetAction​(java.lang.String action)
        Sets the event's action (what happened)
        Parameters:
        action - - the action to store in the event
      • SetSubject

        public void SetSubject​(java.lang.String subject)
        Sets the event's subject (who performed the action)
        Parameters:
        subject - - the subject to store in the event
      • SetStatus

        public void SetStatus​(short status)
        Meiyii 07/01/10 Sets the event's status (activation, success, failure for goal and success, failure for action)
        Parameters:
        status - - the status of the event
      • SetType

        public void SetType​(short type)
        Meiyii 07/01/10 Sets the event's type (goal or action)
        Parameters:
        type - - the type of the event
      • SetTarget

        public void SetTarget​(java.lang.String target)
        Sets the event's target (what is the target of the event's action)
        Parameters:
        target - - the target to store in the event
      • equals

        public boolean equals​(java.lang.Object obj)
        Compares the event against a given object
        Overrides:
        equals in class java.lang.Object
        Returns:
        true if the received object equals the event, false otherwise
      • clone

        public java.lang.Object clone()
        Creates a new copy of the Event
        Overrides:
        clone in class java.lang.Object
        Returns:
        a new Event equal to the cloned Event
      • MakeGround

        public void MakeGround​(java.util.ArrayList<Substitution> substitutions)
        Applies a set of substitutions to the object, grounding it. Only considers substitutions that start with [Subject],[Target], [Action],[P1],[P2], etc... Example: Applying the substitution "[Subject]/John" in the event, will replace the events subject with John Attention, this method modifies the original object.
        Parameters:
        substitutions - - A list of substitutions of the type "[Variable]/value"
        See Also:
        Substitution
      • GenerateBindings

        public java.util.ArrayList<Substitution> GenerateBindings()
        Generates a List of bindings that associate the Variables [Subject], [Action],[Target],[P1],[P2],... respectively to the event's subject, action, target and parameters
        Returns:
        the mentioned list of substitutions
      • toName

        public Name toName()
        Converts the event to a Name
        Returns:
        the converted Name
        See Also:
        Name
      • toStepName

        public Name toStepName()
        Converts the event into the equivalent of a step's name
        Returns:
        a Name that corresponds to a Step's description
      • toString

        public java.lang.String toString()
        Converts the event to a String
        Overrides:
        toString in class java.lang.Object
        Returns:
        the converted String