Class Trigger

All Implemented Interfaces:
LogicalFormula, Term, ToDOM, ToJson, Serializable, Cloneable, Comparable<Term>

public class Trigger extends Structure implements Cloneable
Represents an AgentSpeak trigger (like +!g, +p, ...). It is composed by: an operator (+ or -); a type (, !, or ?); a literal (it extends structure to be used as a term)
See Also:
  • Constructor Details

  • Method Details

    • parseTrigger

      public static Trigger parseTrigger(String sTe)
      prefer to use ASSyntax.parseTrigger
    • getArity

      public int getArity()
      Description copied from class: Literal
      returns the number of terms of this literal
      Overrides:
      getArity in class Structure
    • getTerm

      public Term getTerm(int i)
      Description copied from class: Literal
      returns the i-th term (first term is 0)
      Overrides:
      getTerm in class Structure
    • setTerm

      public void setTerm(int i, Term t)
      Overrides:
      setTerm in class Structure
    • setTrigOp

      public void setTrigOp(Trigger.TEOperator op)
    • sameType

      public boolean sameType(Trigger e)
    • equals

      public boolean equals(Object o)
      Specified by:
      equals in interface Term
      Overrides:
      equals in class Structure
    • isAchvGoal

      public boolean isAchvGoal()
    • isFailureGoal

      public boolean isFailureGoal()
    • isGoal

      public boolean isGoal()
    • isUpdate

      public boolean isUpdate()
      returns true if the trigger is an add (+bel) or del (-bel)
    • isMetaEvent

      public boolean isMetaEvent()
    • getOperator

      public Trigger.TEOperator getOperator()
    • getType

      public Trigger.TEType getType()
    • setType

      public void setType(Trigger.TEType t)
    • isAddition

      public boolean isAddition()
    • clone

      public Trigger clone()
      Description copied from class: Structure
      make a deep copy of the terms
      Specified by:
      clone in interface Term
      Overrides:
      clone in class Structure
    • capply

      public Trigger capply(Unifier u)
      Description copied from interface: Term
      clone and applies together (and faster than clone and then apply)
      Specified by:
      capply in interface Term
      Overrides:
      capply in class Structure
    • getPredicateIndicator

      public PredicateIndicator getPredicateIndicator()
      return [+|-][!|?] super.getPredicateIndicator
      Overrides:
      getPredicateIndicator in class Literal
    • getLiteral

      public Literal getLiteral()
    • setLiteral

      public void setLiteral(Literal literal)
    • setAsTriggerTerm

      public void setAsTriggerTerm(boolean b)
    • toString

      public String toString()
      Overrides:
      toString in class Structure
    • tryToGetTrigger

      public static Trigger tryToGetTrigger(Term t) throws ParseException
      try to convert the term t into a trigger, in case t is a trigger term, a string that can be parsed to a trigger, a var with value trigger, ....
      Throws:
      ParseException
    • getAsDOM

      public Element getAsDOM(Document document)
      get as XML
      Specified by:
      getAsDOM in interface ToDOM
      Overrides:
      getAsDOM in class Structure