Class VarTerm

All Implemented Interfaces:
ListTerm, LogicalFormula, NumberTerm, Term, ToDOM, ToJson, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<Term>, java.lang.Iterable<Term>, java.util.Collection<Term>, java.util.List<Term>
Direct Known Subclasses:
UnnamedVar

public class VarTerm
extends LiteralImpl
implements NumberTerm, ListTerm
Represents a variable Term: like X (starts with upper case). It may have a value, after VarTerm.apply. An object of this class can be used in place of a Literal, Number, List, String, .... It behaves like a Literal, Number, .... just in case its value is a Literal, Number, ...
Author:
jomi
See Also:
Serialized Form
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
      Constant Field Values
    • logger

      private static java.util.logging.Logger logger
  • Constructor Details

    • VarTerm

      public VarTerm​(java.lang.String s)
    • VarTerm

      public VarTerm​(Atom namespace, java.lang.String functor)
    • VarTerm

      public VarTerm​(Atom namespace, Literal v)
  • Method Details

    • parseVar

      @Deprecated public static VarTerm parseVar​(java.lang.String sVar)
      Deprecated.
      prefer ASSyntax.parseVar(...)
    • capply

      public Term 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 LiteralImpl
    • clone

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

      public Literal cloneNS​(Atom newNameSpace)
      Description copied from interface: Term
      clone in another namespace
      Specified by:
      cloneNS in interface Term
      Overrides:
      cloneNS in class LiteralImpl
    • cloneLT

      public ListTerm cloneLT()
      Description copied from interface: ListTerm
      clone the list term
      Specified by:
      cloneLT in interface ListTerm
    • isVar

      public boolean isVar()
      Specified by:
      isVar in interface Term
      Overrides:
      isVar in class DefaultTerm
    • isUnnamedVar

      public boolean isUnnamedVar()
      Specified by:
      isUnnamedVar in interface Term
      Overrides:
      isUnnamedVar in class DefaultTerm
    • isGround

      public boolean isGround()
      Specified by:
      isGround in interface Term
      Overrides:
      isGround in class Pred
    • equals

      public boolean equals​(java.lang.Object t)
      Specified by:
      equals in interface java.util.Collection<Term>
      Specified by:
      equals in interface java.util.List<Term>
      Specified by:
      equals in interface Term
      Overrides:
      equals in class LiteralImpl
    • calcHashCode

      protected int calcHashCode()
      Overrides:
      calcHashCode in class LiteralImpl
    • compareTo

      public int compareTo​(Term t)
      Specified by:
      compareTo in interface java.lang.Comparable<Term>
      Overrides:
      compareTo in class Atom
    • subsumes

      public boolean subsumes​(Term t)
      Specified by:
      subsumes in interface Term
      Overrides:
      subsumes in class Structure
    • logicalConsequence

      public java.util.Iterator<Unifier> logicalConsequence​(Agent ag, Unifier un)
      Description copied from class: Literal
      logicalConsequence checks whether one particular predicate is a logical consequence of the belief base. Returns an iterator for all unifiers that are logCons.
      Specified by:
      logicalConsequence in interface LogicalFormula
      Overrides:
      logicalConsequence in class Literal
    • 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
    • addTerm

      public void addTerm​(Term t)
      Overrides:
      addTerm in class Structure
    • getArity

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

      public java.util.List<Term> getTerms()
      Description copied from class: Literal
      returns all terms of this literal
      Overrides:
      getTerms in class Structure
    • setTerms

      public Literal setTerms​(java.util.List<Term> l)
      Description copied from class: Literal
      set all terms of the literal and return this
      Overrides:
      setTerms in class Structure
    • setTerm

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

      public Literal addTerms​(java.util.List<Term> l)
      Description copied from class: Literal
      adds some terms and return this
      Overrides:
      addTerms in class Structure
    • isInternalAction

      public boolean isInternalAction()
      Specified by:
      isInternalAction in interface Term
      Overrides:
      isInternalAction in class DefaultTerm
    • isList

      public boolean isList()
      Specified by:
      isList in interface Term
      Overrides:
      isList in class DefaultTerm
    • isString

      public boolean isString()
      Specified by:
      isString in interface Term
      Overrides:
      isString in class DefaultTerm
    • isPlanBody

      public boolean isPlanBody()
      Specified by:
      isPlanBody in interface Term
      Overrides:
      isPlanBody in class DefaultTerm
    • isNumeric

      public boolean isNumeric()
      Specified by:
      isNumeric in interface Term
      Overrides:
      isNumeric in class DefaultTerm
    • isPred

      public boolean isPred()
      Specified by:
      isPred in interface Term
      Overrides:
      isPred in class Pred
    • isLiteral

      public boolean isLiteral()
      Specified by:
      isLiteral in interface Term
      Overrides:
      isLiteral in class Literal
    • isStructure

      public boolean isStructure()
      Specified by:
      isStructure in interface Term
      Overrides:
      isStructure in class Structure
    • isAtom

      public boolean isAtom()
      Specified by:
      isAtom in interface Term
      Overrides:
      isAtom in class LiteralImpl
    • isRule

      public boolean isRule()
      Specified by:
      isRule in interface Term
      Overrides:
      isRule in class DefaultTerm
    • isArithExpr

      public boolean isArithExpr()
      Specified by:
      isArithExpr in interface Term
      Overrides:
      isArithExpr in class DefaultTerm
    • isCyclicTerm

      public boolean isCyclicTerm()
      Specified by:
      isCyclicTerm in interface Term
      Overrides:
      isCyclicTerm in class DefaultTerm
    • hasVar

      public boolean hasVar​(VarTerm t, Unifier u)
      Specified by:
      hasVar in interface Term
      Overrides:
      hasVar in class Pred
    • countVars

      public void countVars​(java.util.Map<VarTerm,​java.lang.Integer> c)
      Specified by:
      countVars in interface Term
      Overrides:
      countVars in class Pred
    • canBeAddedInBB

      public boolean canBeAddedInBB()
      Description copied from class: LiteralImpl
      to be overridden by subclasses (as internal action)
      Overrides:
      canBeAddedInBB in class LiteralImpl
    • solve

      public double solve() throws NoValueException
      Description copied from interface: NumberTerm
      returns the numeric value of the term
      Specified by:
      solve in interface NumberTerm
      Throws:
      NoValueException
    • add

      public void add​(int index, Term o)
      Specified by:
      add in interface java.util.List<Term>
    • add

      public boolean add​(Term o)
      Specified by:
      add in interface java.util.Collection<Term>
      Specified by:
      add in interface java.util.List<Term>
    • addAll

      public boolean addAll​(java.util.Collection c)
      Specified by:
      addAll in interface java.util.Collection<Term>
      Specified by:
      addAll in interface java.util.List<Term>
    • addAll

      public boolean addAll​(int index, java.util.Collection c)
      Specified by:
      addAll in interface java.util.List<Term>
    • clear

      public void clear()
      Specified by:
      clear in interface java.util.Collection<Term>
      Specified by:
      clear in interface java.util.List<Term>
    • contains

      public boolean contains​(java.lang.Object o)
      Specified by:
      contains in interface java.util.Collection<Term>
      Specified by:
      contains in interface java.util.List<Term>
    • containsAll

      public boolean containsAll​(java.util.Collection c)
      Specified by:
      containsAll in interface java.util.Collection<Term>
      Specified by:
      containsAll in interface java.util.List<Term>
    • get

      public Term get​(int index)
      Specified by:
      get in interface java.util.List<Term>
    • indexOf

      public int indexOf​(java.lang.Object o)
      Specified by:
      indexOf in interface java.util.List<Term>
    • lastIndexOf

      public int lastIndexOf​(java.lang.Object o)
      Specified by:
      lastIndexOf in interface java.util.List<Term>
    • iterator

      public java.util.Iterator<Term> iterator()
      Specified by:
      iterator in interface java.util.Collection<Term>
      Specified by:
      iterator in interface java.lang.Iterable<Term>
      Specified by:
      iterator in interface java.util.List<Term>
    • listIterator

      public java.util.ListIterator<Term> listIterator()
      Specified by:
      listIterator in interface java.util.List<Term>
    • listIterator

      public java.util.ListIterator<Term> listIterator​(int index)
      Specified by:
      listIterator in interface java.util.List<Term>
    • remove

      public Term remove​(int index)
      Specified by:
      remove in interface java.util.List<Term>
    • remove

      public boolean remove​(java.lang.Object o)
      Specified by:
      remove in interface java.util.Collection<Term>
      Specified by:
      remove in interface java.util.List<Term>
    • removeAll

      public boolean removeAll​(java.util.Collection c)
      Specified by:
      removeAll in interface java.util.Collection<Term>
      Specified by:
      removeAll in interface java.util.List<Term>
    • retainAll

      public boolean retainAll​(java.util.Collection c)
      Specified by:
      retainAll in interface java.util.Collection<Term>
      Specified by:
      retainAll in interface java.util.List<Term>
    • set

      public Term set​(int index, Term o)
      Specified by:
      set in interface java.util.List<Term>
    • subList

      public java.util.List<Term> subList​(int arg0, int arg1)
      Specified by:
      subList in interface java.util.List<Term>
    • subSets

      public java.util.Iterator<java.util.List<Term>> subSets​(int k)
      Description copied from interface: ListTerm
      returns all subsets that take k elements of this list
      Specified by:
      subSets in interface ListTerm
    • toArray

      public java.lang.Object[] toArray()
      Specified by:
      toArray in interface java.util.Collection<Term>
      Specified by:
      toArray in interface java.util.List<Term>
    • toArray

      public java.lang.Object[] toArray​(java.lang.Object[] arg0)
      Specified by:
      toArray in interface java.util.Collection<Term>
      Specified by:
      toArray in interface java.util.List<Term>
    • setTerm

      public void setTerm​(Term t)
      Specified by:
      setTerm in interface ListTerm
    • setNext

      public void setNext​(Term t)
      Specified by:
      setNext in interface ListTerm
    • append

      public ListTerm append​(Term t)
      Specified by:
      append in interface ListTerm
    • insert

      public ListTerm insert​(Term t)
      Specified by:
      insert in interface ListTerm
    • concat

      public ListTerm concat​(ListTerm lt)
      Specified by:
      concat in interface ListTerm
    • reverse

      public ListTerm reverse()
      Specified by:
      reverse in interface ListTerm
    • union

      public ListTerm union​(ListTerm lt)
      Specified by:
      union in interface ListTerm
    • intersection

      public ListTerm intersection​(ListTerm lt)
      Specified by:
      intersection in interface ListTerm
    • difference

      public ListTerm difference​(ListTerm lt)
      Specified by:
      difference in interface ListTerm
    • getAsList

      public java.util.List<Term> getAsList()
      Specified by:
      getAsList in interface ListTerm
    • getLast

      public ListTerm getLast()
      Specified by:
      getLast in interface ListTerm
    • getPenultimate

      public ListTerm getPenultimate()
      Specified by:
      getPenultimate in interface ListTerm
    • removeLast

      public Term removeLast()
      Specified by:
      removeLast in interface ListTerm
    • getNext

      public ListTerm getNext()
      Specified by:
      getNext in interface ListTerm
    • getTerm

      public Term getTerm()
      Specified by:
      getTerm in interface ListTerm
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface java.util.Collection<Term>
      Specified by:
      isEmpty in interface java.util.List<Term>
    • isEnd

      public boolean isEnd()
      Specified by:
      isEnd in interface ListTerm
    • isTail

      public boolean isTail()
      Specified by:
      isTail in interface ListTerm
    • setTail

      public void setTail​(VarTerm v)
      Specified by:
      setTail in interface ListTerm
    • getTail

      public VarTerm getTail()
      Specified by:
      getTail in interface ListTerm
    • listTermIterator

      public java.util.Iterator<ListTerm> listTermIterator()
      Specified by:
      listTermIterator in interface ListTerm
    • size

      public int size()
      Specified by:
      size in interface java.util.Collection<Term>
      Specified by:
      size in interface java.util.List<Term>
    • cloneLTShallow

      public ListTerm cloneLTShallow()
      Description copied from interface: ListTerm
      make a shallow copy of the list (terms are not cloned, only the structure)
      Specified by:
      cloneLTShallow in interface ListTerm
    • 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 LiteralImpl