Package jason.asSyntax
Class Structure
java.lang.Object
jason.asSyntax.DefaultTerm
jason.asSyntax.Literal
jason.asSyntax.Atom
jason.asSyntax.Structure
- All Implemented Interfaces:
LogicalFormula
,Term
,ToDOM
,ToJson
,java.io.Serializable
,java.lang.Cloneable
,java.lang.Comparable<Term>
- Direct Known Subclasses:
ArithFunctionTerm
,BinaryStructure
,InternalActionLiteral
,ListTermImpl
,Plan
,PlanBodyImpl
,Pred
,Trigger
public class Structure extends Atom
Represents a structure: a functor with n arguments,
e.g.: val(10,x(3)).
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from class jason.asSyntax.Literal
Literal.FalseLiteral, Literal.TrueLiteral
-
Field Summary
Fields Modifier and Type Field Description protected static Term[]
emptyTermArray
protected static java.util.List<Term>
emptyTermList
private static java.util.logging.Logger
logger
private static long
serialVersionUID
private java.util.List<Term>
terms
private static boolean
useShortUnnamedVars
Fields inherited from class jason.asSyntax.Literal
DefaultNS, LFalse, LNeg, LPos, LTrue, predicateIndicatorCache
Fields inherited from class jason.asSyntax.DefaultTerm
hashCodeCache, srcInfo
-
Constructor Summary
Constructors Modifier Constructor Description Structure(Atom namespace, Literal l)
Structure(Atom namespace, java.lang.String functor)
Structure(Literal l)
protected
Structure(Literal l, Unifier u)
Structure(java.lang.String functor)
Structure(java.lang.String functor, int termsSize)
Create a structure with a defined number of terms. -
Method Summary
Modifier and Type Method Description void
addTerm(Term t)
Literal
addTerms(Term... ts)
adds some terms and return thisLiteral
addTerms(java.util.List<Term> l)
adds some terms and return thisprotected int
calcHashCode()
Term
capply(Unifier u)
clone and applies together (and faster than clone and then apply)Term
clone()
make a deep copy of the termsLiteral
cloneNS(Atom newnamespace)
clone in another namespacevoid
countVars(java.util.Map<VarTerm,java.lang.Integer> c)
void
delTerm(int index)
boolean
equals(java.lang.Object t)
int
getArity()
returns the number of terms of this literalorg.w3c.dom.Element
getAsDOM(org.w3c.dom.Document document)
get as XMLjava.util.List<VarTerm>
getSingletonVars()
returns all singleton vars (that appears once) in this literalTerm
getTerm(int i)
returns the i-th term (first term is 0)java.util.List<Term>
getTerms()
returns all terms of this literalint
getTermsSize()
Deprecated.use getArityboolean
hasTerm()
returns true if this literal has some termboolean
hasVar(VarTerm t, Unifier u)
boolean
isAtom()
boolean
isGround()
boolean
isStructure()
boolean
isUnary()
void
makeTermsAnnon()
replaces all terms by unnamed variables (_).Literal
makeVarsAnnon()
replaces all variables by unnamed variables (_).Literal
makeVarsAnnon(Unifier un)
replaces all variables of the term for unnamed variables (_).static Structure
parse(java.lang.String sTerm)
void
setTerm(int i, Term t)
Literal
setTerms(java.util.List<Term> l)
set all terms of the literal and return thisboolean
subsumes(Term t)
java.lang.String
toString()
VarTerm
varToReplace(Term t, Unifier un)
Methods inherited from class jason.asSyntax.Atom
compareTo, getFunctor, getNS
Methods inherited from class jason.asSyntax.Literal
addAnnot, addAnnots, addAnnots, addSource, addSourceInfoAsAnnots, canBeAddedInBB, clearAnnots, copy, delAnnot, delAnnots, delAnnots, delSource, delSources, equalsAsStructure, forceFullLiteralImpl, getAnnot, getAnnots, getAnnots, getAsJson, getAsListOfTerms, getPredicateIndicator, getSources, getTermsArray, hasAnnot, hasAnnot, hasSource, hasSource, hasSubsetAnnot, hasSubsetAnnot, importAnnots, isLiteral, logicalConsequence, negated, newFromListOfTerms, newFunctor, noSource, parseLiteral, setAnnots, setNegated, subjectToBUF
Methods inherited from class jason.asSyntax.DefaultTerm
getCyclicVar, getErrorMsg, getSrcInfo, hashCode, isArithExpr, isCyclicTerm, isInternalAction, isList, isMap, isNumeric, isPlanBody, isPred, isRule, isSet, 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
getCyclicVar, getSrcInfo, isArithExpr, isCyclicTerm, isInternalAction, isList, isMap, isNumeric, isPlanBody, isPred, isRule, isSet, isString, isUnnamedVar, isVar, setSrcInfo
Methods inherited from interface jason.util.ToJson
getAsJsonStr
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
- Constant Field Values
-
logger
private static java.util.logging.Logger logger -
emptyTermList
-
emptyTermArray
-
terms
-
useShortUnnamedVars
private static final boolean useShortUnnamedVars
-
-
Constructor Details
-
Structure
public Structure(java.lang.String functor) -
Structure
-
Structure
-
Structure
-
Structure
-
Structure
public Structure(java.lang.String functor, int termsSize)Create a structure with a defined number of terms. It is used by list term, plan body, ... to not create the array list for terms.
-
-
Method Details
-
parse
-
calcHashCode
protected int calcHashCode()- Overrides:
calcHashCode
in classAtom
-
equals
public boolean equals(java.lang.Object t) -
subsumes
- Specified by:
subsumes
in interfaceTerm
- Overrides:
subsumes
in classDefaultTerm
-
capply
Description copied from interface:Term
clone and applies together (and faster than clone and then apply) -
clone
make a deep copy of the terms -
cloneNS
Description copied from interface:Term
clone in another namespace -
addTerm
-
delTerm
public void delTerm(int index) -
addTerms
Description copied from class:Literal
adds some terms and return this -
addTerms
Description copied from class:Literal
adds some terms and return this -
setTerms
Description copied from class:Literal
set all terms of the literal and return this -
setTerm
-
getTerm
Description copied from class:Literal
returns the i-th term (first term is 0) -
getArity
public int getArity()Description copied from class:Literal
returns the number of terms of this literal -
getTermsSize
@Deprecated public int getTermsSize()Deprecated.use getArity -
getTerms
Description copied from class:Literal
returns all terms of this literal -
hasTerm
public boolean hasTerm()Description copied from class:Literal
returns true if this literal has some term -
isStructure
public boolean isStructure()- Specified by:
isStructure
in interfaceTerm
- Overrides:
isStructure
in classDefaultTerm
-
isAtom
public boolean isAtom() -
isGround
public boolean isGround()- Specified by:
isGround
in interfaceTerm
- Overrides:
isGround
in classDefaultTerm
-
isUnary
public boolean isUnary() -
makeVarsAnnon
Description copied from class:Literal
replaces all variables by unnamed variables (_).- Overrides:
makeVarsAnnon
in classLiteral
-
makeVarsAnnon
Description copied from class:Literal
replaces all variables of the term for unnamed variables (_).- Overrides:
makeVarsAnnon
in classLiteral
- Parameters:
un
- is the unifier that contains the map of replacements
-
varToReplace
-
makeTermsAnnon
public void makeTermsAnnon()Description copied from class:Literal
replaces all terms by unnamed variables (_).- Overrides:
makeTermsAnnon
in classLiteral
-
hasVar
- Specified by:
hasVar
in interfaceTerm
- Overrides:
hasVar
in classDefaultTerm
-
getSingletonVars
Description copied from class:Literal
returns all singleton vars (that appears once) in this literal- Overrides:
getSingletonVars
in classLiteral
-
countVars
- Specified by:
countVars
in interfaceTerm
- Overrides:
countVars
in classDefaultTerm
-
toString
public java.lang.String toString() -
getAsDOM
public org.w3c.dom.Element getAsDOM(org.w3c.dom.Document document)get as XML
-