Class Trigger

All Implemented Interfaces:
LogicalFormula, Term, ToDOM, ToJson, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<Term>

public class Trigger
extends Structure
implements java.lang.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:
Serialized Form
  • Field Details

  • Constructor Details

  • Method Details

    • parseTrigger

      public static Trigger parseTrigger​(java.lang.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​(java.lang.Object o)
      Specified by:
      equals in interface Term
      Overrides:
      equals in class Structure
    • isAchvGoal

      public boolean isAchvGoal()
    • 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()
    • 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 java.lang.String toString()
      Overrides:
      toString in class Structure
    • tryToGetTrigger

      public static Trigger tryToGetTrigger​(Term t) throws jason.asSyntax.parser.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:
      jason.asSyntax.parser.ParseException
    • getAsDOM

      public org.w3c.dom.Element getAsDOM​(org.w3c.dom.Document document)
      get as XML
      Specified by:
      getAsDOM in interface ToDOM
      Overrides:
      getAsDOM in class Structure