jason.asSyntax
Class Pred

Package class diagram package Pred
java.lang.Object
  extended by jason.asSyntax.DefaultTerm
      extended by jason.asSyntax.Literal
          extended by jason.asSyntax.Atom
              extended by jason.asSyntax.Structure
                  extended by jason.asSyntax.Pred
All Implemented Interfaces:
LogicalFormula, Term, ToDOM, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<Term>
Direct Known Subclasses:
LiteralImpl

public class Pred
extends Structure

A Pred extends a Structure with annotations, e.g.: a(1)[an1,an2].

See Also:
Serialized Form

Field Summary
 
Fields inherited from class jason.asSyntax.Structure
emptyTermArray, emptyTermList
 
Fields inherited from class jason.asSyntax.Literal
LFalse, LNeg, LPos, LTrue, predicateIndicatorCache
 
Fields inherited from class jason.asSyntax.DefaultTerm
hashCodeCache, srcInfo
 
Constructor Summary
Pred(Literal l)
           
Pred(java.lang.String functor)
           
Pred(java.lang.String functor, int termsSize)
           
 
Method Summary
 boolean addAnnot(Term t)
           
 Literal addAnnots(java.util.List<Term> l)
          adds some annots and return this
 Literal addAnnots(Term... l)
          adds some annots and return this
 void addSource(Term agName)
          adds the annotation source(agName)
 boolean apply(Unifier u)
          replaces variables by their values in the unifier, returns true if some variable was applied
 void clearAnnots()
          removes all annotations
 Term clone()
          make a deep copy of the terms
 int compareTo(Term t)
           
 void countVars(java.util.Map<VarTerm,java.lang.Integer> c)
           
static Term createSource(Term source)
           
 boolean delAnnot(Term t)
           
 boolean delAnnots(java.util.List<Term> l)
          removes all annots in this pred that are in the list l.
 boolean delSource(Term agName)
          deletes one source(agName) annotation, return true if deleted
 void delSources()
          deletes all source annotations
 boolean equals(java.lang.Object o)
           
 boolean equalsAsStructure(java.lang.Object p)
           
 ListTerm getAnnots()
          returns all annotations of the literal
 ListTerm getAnnots(java.lang.String functor)
          returns all annots with the specified functor e.g.: from annots [t(a), t(b), source(tom)] and functor "t", it returns [t(a),t(b)] in case that there is no such an annot, it returns an empty list.
 org.w3c.dom.Element getAsDOM(org.w3c.dom.Document document)
          get as XML
 ListTerm getSources()
          returns the sources of this literal as a new list.
 boolean hasAnnot()
          returns true if the pred has at least one annot
 boolean hasAnnot(Term t)
          returns true if there is some annotation t in the literal
 boolean hasSource()
          returns true if this literal has some source annotation
 boolean hasSource(Term agName)
          returns true if this literal has a "source(agName)"
 boolean hasSubsetAnnot(Literal p)
          returns true if all this predicate annots are in p's annots
 boolean hasSubsetAnnot(Literal p, Unifier u)
          Returns true if all this predicate's annots are in p's annots using the unifier u.
 boolean hasVar(VarTerm t)
           
 boolean importAnnots(Literal p)
          "import" annots from another predicate p.
 boolean isAtom()
           
 boolean isGround()
           
 boolean isPred()
           
 Literal makeVarsAnnon(Unifier un)
          replaces all variables of the term for unnamed variables (_).
static Pred parsePred(java.lang.String sPred)
           
 Literal setAnnots(ListTerm l)
           
 java.lang.String toString()
           
 java.lang.String toStringAsTerm()
           
 
Methods inherited from class jason.asSyntax.Structure
addTerm, addTerms, addTerms, calcHashCode, delTerm, getArity, getSingletonVars, getTerm, getTerms, getTermsSize, hasTerm, isStructure, makeTermsAnnon, makeVarsAnnon, parse, setTerm, setTerms, varToReplace
 
Methods inherited from class jason.asSyntax.Atom
getFunctor
 
Methods inherited from class jason.asSyntax.Literal
canBeAddedInBB, copy, forceFullLiteralImpl, getAsListOfTerms, getPredicateIndicator, getTermsArray, isLiteral, logicalConsequence, negated, newFromListOfTerms, parseLiteral, setNegated
 
Methods inherited from class jason.asSyntax.DefaultTerm
getErrorMsg, getSrcInfo, hashCode, isArithExpr, isInternalAction, isList, isNumeric, isPlanBody, isRule, isString, isUnnamedVar, isVar, resetHashCodeCache, setSrcInfo
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jason.asSyntax.Term
getSrcInfo, isArithExpr, isInternalAction, isList, isNumeric, isPlanBody, isRule, isString, isUnnamedVar, isVar, setSrcInfo
 

Constructor Detail

Pred

public Pred(java.lang.String functor)

Pred

public Pred(Literal l)

Pred

public Pred(java.lang.String functor,
            int termsSize)
Method Detail

parsePred

public static Pred parsePred(java.lang.String sPred)

isPred

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

isAtom

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

isGround

public boolean isGround()
Specified by:
isGround in interface Term
Overrides:
isGround in class Structure

apply

public boolean apply(Unifier u)
Description copied from interface: Term
replaces variables by their values in the unifier, returns true if some variable was applied

Specified by:
apply in interface Term
Overrides:
apply in class Structure

setAnnots

public Literal setAnnots(ListTerm l)
Overrides:
setAnnots in class Literal

addAnnot

public boolean addAnnot(Term t)
Overrides:
addAnnot in class Literal

addAnnots

public Literal addAnnots(java.util.List<Term> l)
Description copied from class: Literal
adds some annots and return this

Overrides:
addAnnots in class Literal

addAnnots

public Literal addAnnots(Term... l)
Description copied from class: Literal
adds some annots and return this

Overrides:
addAnnots in class Literal

delAnnot

public boolean delAnnot(Term t)
Overrides:
delAnnot in class Literal

clearAnnots

public void clearAnnots()
Description copied from class: Literal
removes all annotations

Overrides:
clearAnnots in class Literal

getAnnots

public ListTerm getAnnots()
Description copied from class: Literal
returns all annotations of the literal

Overrides:
getAnnots in class Literal

hasAnnot

public boolean hasAnnot(Term t)
Description copied from class: Literal
returns true if there is some annotation t in the literal

Overrides:
hasAnnot in class Literal

hasAnnot

public boolean hasAnnot()
Description copied from class: Literal
returns true if the pred has at least one annot

Overrides:
hasAnnot in class Literal

hasVar

public boolean hasVar(VarTerm t)
Specified by:
hasVar in interface Term
Overrides:
hasVar in class Structure

countVars

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

importAnnots

public boolean importAnnots(Literal p)
Description copied from class: Literal
"import" annots from another predicate p. p will be changed to contain only the annots actually imported (for Event), for example: p = b[a,b] this = b[b,c] after import, p = b[a] It is used to generate event <+b[a]>.

Overrides:
importAnnots in class Literal
Returns:
true if some annot was imported.

delAnnots

public boolean delAnnots(java.util.List<Term> l)
Description copied from class: Literal
removes all annots in this pred that are in the list l.

Overrides:
delAnnots in class Literal
Returns:
true if some annot was removed.

getAnnots

public ListTerm getAnnots(java.lang.String functor)
Description copied from class: Literal
returns all annots with the specified functor e.g.: from annots [t(a), t(b), source(tom)] and functor "t", it returns [t(a),t(b)] in case that there is no such an annot, it returns an empty list.

Overrides:
getAnnots in class Literal

hasSubsetAnnot

public boolean hasSubsetAnnot(Literal p)
Description copied from class: Literal
returns true if all this predicate annots are in p's annots

Overrides:
hasSubsetAnnot in class Literal

hasSubsetAnnot

public boolean hasSubsetAnnot(Literal p,
                              Unifier u)
Description copied from class: Literal
Returns true if all this predicate's annots are in p's annots using the unifier u. if p annots has a Tail, p annots's Tail will receive this predicate's annots, e.g.: this[a,b,c] = p[x,y,b|T] unifies and T is [a,c] (this will be a subset if p has a and c in its annots). if this annots has a tail, the Tail will receive all necessary term to be a subset, e.g.: this[b|T] = p[x,y,b] unifies and T is [x,y] (this will be a subset if T is [x,y].

Overrides:
hasSubsetAnnot in class Literal

addSource

public void addSource(Term agName)
Description copied from class: Literal
adds the annotation source(agName)

Overrides:
addSource in class Literal

delSource

public boolean delSource(Term agName)
Description copied from class: Literal
deletes one source(agName) annotation, return true if deleted

Overrides:
delSource in class Literal

createSource

public static Term createSource(Term source)

getSources

public ListTerm getSources()
Description copied from class: Literal
returns the sources of this literal as a new list. e.g.: from annots [source(a), source(b)], it returns [a,b]

Overrides:
getSources in class Literal

delSources

public void delSources()
Description copied from class: Literal
deletes all source annotations

Overrides:
delSources in class Literal

hasSource

public boolean hasSource()
Description copied from class: Literal
returns true if this literal has some source annotation

Overrides:
hasSource in class Literal

hasSource

public boolean hasSource(Term agName)
Description copied from class: Literal
returns true if this literal has a "source(agName)"

Overrides:
hasSource in class Literal

makeVarsAnnon

public Literal makeVarsAnnon(Unifier un)
Description copied from class: Literal
replaces all variables of the term for unnamed variables (_).

Overrides:
makeVarsAnnon in class Structure
Parameters:
un - is the unifier that contains the map of replacements

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface Term
Overrides:
equals in class Structure

equalsAsStructure

public boolean equalsAsStructure(java.lang.Object p)
Overrides:
equalsAsStructure in class Literal

compareTo

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

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 Structure

toStringAsTerm

public java.lang.String toStringAsTerm()

toString

public java.lang.String toString()
Overrides:
toString in class Structure

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