public abstract class Term extends Object
Constructor and Description |
---|
Term() |
Modifier and Type | Method and Description |
---|---|
abstract void |
accept(TermVisitor termVisitor)
Accepts a Jpc term visitor.
|
Term |
arg(int i)
Returns the ith argument (if any) of this Term.
|
int |
arity()
Returns the arity (i.e., number of arguments) of this Term.
|
ListTerm |
asList()
Returns a list representation of this term.
|
protected boolean |
basicIsList() |
protected abstract void |
basicRead(TermContentHandler contentHandler,
com.google.common.base.Function<Term,Term> termExpander) |
boolean |
canUnify(Term term) |
Term |
changeVariablesNames(Map<String,String> map)
Replace all the variable names according to the map parameter
|
Term |
compile() |
Term |
compile(boolean preserveVarNames) |
Term |
compile(boolean preserveVarNames,
Environment env) |
Term |
compile(Environment env) |
Term |
compileAndUnify(Term term) |
Map<String,Term> |
compileAndUnifyVars(Term term) |
List<Term> |
getArgs()
Returns the arguments list of this term.
|
List<AbstractVar> |
getNamedVariables()
Returns a list with all the named variables (i.e., all variables but "_")
|
List<String> |
getNamedVariablesNames()
Returns a list with all the named variables names (i.e., all variables but "_")
|
List<String> |
getNonUnderscoreVariableNames() |
List<AbstractVar> |
getNonUnderscoreVariables() |
List<String> |
getVariableNames() |
List<AbstractVar> |
getVariables() |
boolean |
hasFunctor(boolean nameTermObject,
int arity) |
boolean |
hasFunctor(double nameTermObject,
int arity) |
abstract boolean |
hasFunctor(Functor functor)
Whether this term has a given functor.
|
boolean |
hasFunctor(long nameTermObject,
int arity) |
boolean |
hasFunctor(String nameTermObject,
int arity) |
boolean |
hasVariable(String variableName)
whether the term has a variable with a given id
|
abstract boolean |
isGround() |
boolean |
isHilog() |
boolean |
isList()
whether this Term is a list
|
int |
listLength()
the length of this list, iff it is one, else an exception is thrown
|
abstract Term |
preCompile(Environment env) |
Term |
prepareForFrame()
Method only required for internal usage of the JPC Prolog engine.
|
abstract Term |
prepareForFrame(Environment env) |
Term |
prepareForQuery() |
abstract Term |
prepareForQuery(Environment env) |
void |
read(TermContentHandler contentHandler) |
void |
read(TermContentHandler contentHandler,
com.google.common.base.Function<Term,Term> termExpander) |
Term |
replaceVariables(Map<String,? extends Term> map)
Returns a term with all the occurrences of the variables in the parameter map replaced with its associated value (converted to a term)
|
Term |
resolveBindings() |
static boolean |
termEquals(List<? extends Term> list1,
List<? extends Term> list2) |
boolean |
termEquals(Term t)
Test if this object is equivalent to the term representation of the object sent as parameter
This is not testing for equality in a mathematical sense, for example:
'new Variable("_").equals(new Variable("_"))'
is false, since both the receiver and the arguments are anonymous variables, not the same variable.
|
Term |
termExpansion(com.google.common.base.Function<Term,Term> termExpander) |
abstract String |
toEscapedString() |
static <T extends Term> |
toEscapedString(List<T> terms)
Converts a list of Terms to a String.
|
static <T extends Term> |
toEscapedString(T... terms)
Converts an array of Terms to its escaped String representation.
|
String |
toString()
Reads the contents of this term (i.e., generates events) to a content handler
|
abstract String |
toString(OperatorsContext operatorsContext) |
void |
unify(Term term) |
Term |
unifyAndBind(Term term) |
Map<String,Term> |
varBindings() |
public boolean isHilog()
public Term arg(int i)
public List<Term> getArgs()
public int arity()
public abstract boolean hasFunctor(Functor functor)
functor
- the functor of this term.public boolean hasFunctor(String nameTermObject, int arity)
public boolean hasFunctor(boolean nameTermObject, int arity)
public boolean hasFunctor(double nameTermObject, int arity)
public boolean hasFunctor(long nameTermObject, int arity)
public final boolean isList()
protected boolean basicIsList()
public ListTerm asList()
public int listLength()
LException
public abstract boolean isGround()
public Term replaceVariables(Map<String,? extends Term> map)
map
- maps variable names to values.public Term changeVariablesNames(Map<String,String> map)
map
- maps variable names to new namespublic boolean hasVariable(String variableName)
variableName
- the variable id that is queriedpublic List<AbstractVar> getVariables()
public List<String> getVariableNames()
public List<AbstractVar> getNonUnderscoreVariables()
public List<String> getNonUnderscoreVariableNames()
public List<AbstractVar> getNamedVariables()
public List<String> getNamedVariablesNames()
public abstract void accept(TermVisitor termVisitor)
termVisitor
- the accepted visitorpublic void read(TermContentHandler contentHandler)
public void read(TermContentHandler contentHandler, com.google.common.base.Function<Term,Term> termExpander)
protected abstract void basicRead(TermContentHandler contentHandler, com.google.common.base.Function<Term,Term> termExpander)
public boolean termEquals(Term t)
termAdaptable
- public static boolean termEquals(List<? extends Term> list1, List<? extends Term> list2)
list1
- a list of Termslist2
- another list of Termspublic String toString()
public abstract String toEscapedString()
public abstract String toString(OperatorsContext operatorsContext)
public static <T extends Term> String toEscapedString(T... terms)
terms
- an array of Terms to convertpublic static <T extends Term> String toEscapedString(List<T> terms)
terms
- public final boolean canUnify(Term term)
term
- a compiled termUncompiledTermException
- if this term or the receiver are not compiled and there are unbound variables.public final Map<String,Term> compileAndUnifyVars(Term term)
term
- a term.public final Term compileAndUnify(Term term)
term
- a term.public void unify(Term term)
term
- UncompiledTermException
- if this term or the receiver are not compiled and there are unbound variables.NonUnifiableException
- if this term is not unifiable with the receiver.public final Term resolveBindings()
public final Term unifyAndBind(Term term)
term
- a bindable term.public final Map<String,Term> varBindings()
public final Term compile()
public final Term compile(boolean preserveVarNames)
public final Term compile(Environment env)
public final Term compile(boolean preserveVarNames, Environment env)
public abstract Term preCompile(Environment env)
public final Term prepareForQuery()
public abstract Term prepareForQuery(Environment env)
public final Term prepareForFrame()
public abstract Term prepareForFrame(Environment env)
Copyright © 2014. All rights reserved.