public abstract class AbstractEngine extends Object implements PrologEngine
PrologEngine
.Modifier and Type | Class and Description |
---|---|
protected class |
AbstractEngine.PrologProgramIterator |
Modifier and Type | Field and Description |
---|---|
protected PrologProvider |
provider |
Modifier | Constructor and Description |
---|---|
protected |
AbstractEngine(PrologProvider provider) |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(PrologTerm goal)
Check if the given goal array have solution using the resolution engine
mechanism.
|
boolean |
contains(PrologTerm goal,
PrologTerm... goals)
Check if the given goal array have solution using the resolution engine
mechanism.
|
boolean |
contains(String goal)
Parse the string creating internal prolog clause and returning true if the
given goal have solution using the resolution engine mechanism.
|
Set<PrologIndicator> |
currentPredicates()
Predicate set defined in the wrapped prolog engine.
|
boolean |
equals(Object object) |
protected <K> K |
fromTerm(PrologTerm term,
Class<K> to) |
protected <K> K |
fromTerm(PrologTerm head,
PrologTerm[] body,
Class<K> to) |
PrologLogger |
getLogger()
Get the prolog system logger instance to report any errors or exceptions
|
String |
getOSArch()
Return the host operating system architecture.
|
String |
getOSName()
Return the host operating system name.
|
String |
getOSVersion()
Return the host operating system version.
|
Set<PrologClause> |
getProgramClauses()
Make and return a copy of the clause set present in the current engine.
|
Map<String,List<PrologClause>> |
getProgramMap()
Make and return a copy of the clause map present in the current engine.
|
PrologProvider |
getProvider()
Get a Prolog provider instance hold in the current engine.
|
int |
hashCode() |
boolean |
isProgramEmpty()
Check if the program in main memory is empty returning true if the clause
number in the program is 0 and false in otherwise.
|
Map<String,PrologTerm> |
match(PrologTerm t1,
PrologTerm t2)
Match to other term returning list of substitutions.
|
io.github.prolobjectlink.prolog.DefaultClauseBuilder |
newClauseBuilder()
Create a new clause builder instance to build prolog clauses
programmatically.
|
io.github.prolobjectlink.prolog.DefaultQueryBuilder |
newQueryBuilder()
Create a new query builder instance to build prolog goal programmatically.
|
void |
persist(Writer writer)
Write the prolog clauses in program present in the current engine using the
given driver.
|
List<Map<String,PrologTerm>> |
queryAll(PrologTerm goal) |
List<Map<String,PrologTerm>> |
queryAll(PrologTerm goal,
PrologTerm... goals)
Create a new prolog query and return the list of prolog terms that conform
the solution set for the current query.
|
List<Map<String,PrologTerm>> |
queryAll(String goal)
Create a new prolog query and return the list of prolog terms that conform
the solution set for the current query.
|
List<Map<String,PrologTerm>> |
queryN(int n,
PrologTerm term) |
List<Map<String,PrologTerm>> |
queryN(int n,
PrologTerm term,
PrologTerm... terms)
Create a new prolog query and return the list of (N) prolog terms that
conform the solution set for the current query.
|
List<Map<String,PrologTerm>> |
queryN(int n,
String goal)
Create a new prolog query and return the list of (N) prolog terms that
conform the solution set for the current query.
|
Map<String,PrologTerm> |
queryOne(PrologTerm goal) |
Map<String,PrologTerm> |
queryOne(PrologTerm goal,
PrologTerm... goals)
Create a new prolog query and return the prolog terms that conform the
solution set for the current query.
|
Map<String,PrologTerm> |
queryOne(String goal)
Create a new prolog query and return the prolog terms that conform the
solution set for the current query.
|
protected String |
removeQuoted(String functor) |
boolean |
runOnLinux()
Check if the host operating system name refer to Linux OS.
|
boolean |
runOnOSX()
Check if the host operating system name refer to OsX.
|
boolean |
runOnWindows()
Check if the host operating system name refer to Windows OS.
|
String |
toString() |
protected <K extends PrologTerm> |
toTerm(Object o,
Class<K> from) |
protected <K extends PrologTerm,V> |
toTermMapArray(Map<String,V>[] map,
Class<K> from) |
boolean |
unify(PrologTerm t1,
PrologTerm t2)
Check that two terms (x and y) unify.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
abolish, asserta, asserta, asserta, assertz, assertz, assertz, clause, clause, clause, consult, consult, currentOperator, currentOperators, currentPredicate, dispose, getBuiltIns, getLicense, getName, getPredicates, getProgram, getProgramSize, getVendor, getVersion, include, include, operator, persist, query, query, query, query, retract, retract, retract, verify
forEach, iterator, spliterator
protected final PrologProvider provider
protected AbstractEngine(PrologProvider provider)
public final PrologProvider getProvider()
PrologEngine
getProvider
in interface PrologEngine
public final void persist(Writer writer)
PrologEngine
persist
in interface PrologEngine
writer
- writer for write prolog clauses in the program.public final boolean unify(PrologTerm t1, PrologTerm t2)
PrologEngine
unify
in interface PrologEngine
t1
- the term to unify.t2
- the term to unify.public Map<String,PrologTerm> match(PrologTerm t1, PrologTerm t2)
PrologEngine
match
in interface PrologEngine
t1
- the term to unify.t2
- the term to unify.public final boolean contains(String goal)
PrologEngine
query(goal).hasSolution()
contains
in interface PrologEngine
goal
- goal to be queriedpublic final boolean contains(PrologTerm goal)
PrologEngine
query(goal).hasSolution()
contains
in interface PrologEngine
goal
- goal to be checkedpublic final boolean contains(PrologTerm goal, PrologTerm... goals)
PrologEngine
query(goal).hasSolution()
contains
in interface PrologEngine
goal
- goal to be checkedgoals
- goals array with the rest of conjunctive goals term (can be
empty)public final Map<String,PrologTerm> queryOne(String goal)
PrologEngine
List<Map<String, PrologTerm>> m = engine.queryAll("parent(X, Y)");
queryOne
in interface PrologEngine
goal
- string query with prolog format.public final Map<String,PrologTerm> queryOne(PrologTerm goal)
queryOne
in interface PrologEngine
public final Map<String,PrologTerm> queryOne(PrologTerm goal, PrologTerm... goals)
PrologEngine
PrologVariable x = provider.newVariable("X", 0); PrologVariable y = provider.newVariable("Y", 1); Map<String, PrologTerm> m = engine.queryOne(provider.newStructure("parent", x, y));
queryOne
in interface PrologEngine
goal
- prolog term to be querygoals
- prolog term array to be query.public final List<Map<String,PrologTerm>> queryN(int n, String goal)
PrologEngine
queryN
in interface PrologEngine
n
- query result instance numbergoal
- string with prolog syntax to be querypublic final List<Map<String,PrologTerm>> queryN(int n, PrologTerm term)
queryN
in interface PrologEngine
public final List<Map<String,PrologTerm>> queryN(int n, PrologTerm term, PrologTerm... terms)
PrologEngine
PrologVariable x = provider.newVariable("X", 0); PrologVariable y = provider.newVariable("Y", 1); List<Map<String, PrologTerm>> m = engine.queryN(5, provider.newStructure("parent", x, y));
queryN
in interface PrologEngine
n
- query result instance numberterm
- prolog term to be queryterms
- prolog term array to be query.public final List<Map<String,PrologTerm>> queryAll(String goal)
PrologEngine
queryAll
in interface PrologEngine
goal
- string with prolog syntax to be querypublic final List<Map<String,PrologTerm>> queryAll(PrologTerm goal)
queryAll
in interface PrologEngine
public final List<Map<String,PrologTerm>> queryAll(PrologTerm goal, PrologTerm... goals)
PrologEngine
PrologVariable x = provider.newVariable("X", 0); PrologVariable y = provider.newVariable("Y", 1); List<Map<String, PrologTerm>> m = engine.queryAll(provider.newStructure("parent", x, y));
queryAll
in interface PrologEngine
goal
- prolog term to be querygoals
- prolog term array to be query.public final Map<String,List<PrologClause>> getProgramMap()
PrologEngine
getProgramMap
in interface PrologEngine
public final Set<PrologClause> getProgramClauses()
PrologEngine
getProgramClauses
in interface PrologEngine
public final boolean isProgramEmpty()
PrologEngine
PrologEngine.isProgramEmpty()
will be defined like
PrologEngine#getProgramSize()==0;
.isProgramEmpty
in interface PrologEngine
public final Set<PrologIndicator> currentPredicates()
PrologEngine
Set<PrologIndicator> cp = new HashSet<PrologIndicator>(); cp.addAll(getPredicates()); cp.addAll(getBuiltIns());
currentPredicates
in interface PrologEngine
public final io.github.prolobjectlink.prolog.DefaultQueryBuilder newQueryBuilder()
PrologEngine
newQueryBuilder
in interface PrologEngine
public final io.github.prolobjectlink.prolog.DefaultClauseBuilder newClauseBuilder()
PrologEngine
newClauseBuilder
in interface PrologEngine
public final boolean runOnOSX()
PrologEngine
runOnOSX
in interface PrologEngine
public final boolean runOnWindows()
PrologEngine
runOnWindows
in interface PrologEngine
public final boolean runOnLinux()
PrologEngine
runOnLinux
in interface PrologEngine
public final String getOSName()
PrologEngine
System.getProperty("os.name");
.getOSName
in interface PrologEngine
public final String getOSVersion()
PrologEngine
System.getProperty("os.version");
.getOSVersion
in interface PrologEngine
public final String getOSArch()
PrologEngine
System.getProperty("os.arch");
.getOSArch
in interface PrologEngine
public final PrologLogger getLogger()
PrologEngine
getLogger
in interface PrologEngine
protected final <K extends PrologTerm> K toTerm(Object o, Class<K> from)
protected final <K extends PrologTerm,V> Map<String,PrologTerm>[] toTermMapArray(Map<String,V>[] map, Class<K> from)
protected final <K> K fromTerm(PrologTerm term, Class<K> to)
protected final <K> K fromTerm(PrologTerm head, PrologTerm[] body, Class<K> to)
Copyright © 2020–2024 Prolobjectlink Project. All rights reserved.