public abstract class AbstractProvider extends Object implements PrologProvider
PrologProvider
Modifier and Type | Field and Description |
---|---|
protected PrologConverter<?> |
converter |
Constructor and Description |
---|
AbstractProvider(PrologConverter<?> converter) |
Modifier and Type | Method and Description |
---|---|
<T extends PrologTerm> |
cast(PrologTerm term)
Casts a PrologTerm to the class or interface represented by this
Class object. |
protected <T extends PrologTerm> |
cast(PrologTerm term,
Class<T> type)
Casts a PrologTerm to the class or interface represented by this
Class object. |
boolean |
equals(Object object) |
<K> K |
fromTerm(PrologTerm term,
Class<K> to)
Create a native rule representation term from given head and body and cast
this native term to some specific given class.
|
<K> K |
fromTerm(PrologTerm head,
PrologTerm[] body,
Class<K> to)
Create a native rule representation term from given head and body and cast
this native term to some specific given class.
|
<K> K[] |
fromTermArray(PrologTerm[] terms,
Class<K[]> to)
Create a native term array representation from given Prolog term array and
cast this native term array to some specific given array class.
|
PrologConverter<?> |
getConverter()
Get a prolog converter instance to map the abstract prolog data types to
under-laying prolog implementations data types.
|
String |
getName()
Name of the wrapped engine.
|
io.github.prolobjectlink.prolog.PrologParser |
getParser()
Get a prolog parser instance to parser the strings with prolog syntax.
|
String |
getVersion()
Version of the wrapped engine.
|
int |
hashCode() |
boolean |
isCompliant()
True if wrapped engine implement ISO Prolog and false in other case
|
PrologDouble |
newDouble()
Create a prolog double number instance with 0.0 value.
|
PrologFloat |
newFloat()
Create a prolog float number instance with 0.0 value.
|
PrologInteger |
newInteger()
Create a prolog integer number instance with 0 value.
|
PrologList |
newList(Object head)
Create a prolog list with one object item.
|
PrologList |
newList(Object[] arguments)
Create a prolog list from java objects arguments array and the tail item is
an empty list.
|
PrologList |
newList(Object[] arguments,
Object tail)
Create a prolog list from java objects arguments array and the tail item is
the given java object.
|
PrologList |
newList(Object head,
Object tail)
Create a prolog list with two java objects items [head | tail].
|
PrologList |
newList(PrologTerm head)
Create a prolog list with one term item.
|
PrologLong |
newLong()
Create a prolog long number instance with 0 value.
|
PrologTerm |
newStructure(Object left,
String operator,
Object right)
Create a prolog structure that represent an expression defined by your left
and right operands separated by infix operator.
|
PrologTerm |
newStructure(String functor,
Object... arguments)
Create a prolog structure with the functor (structure name) and java objects
arguments array.
|
PrologClause |
parseClause(String stringClause)
Parse the string with Prolog syntax and create an equivalent Prolog clause
instance.
|
PrologList |
parseList(String stringList)
Parse the string with Prolog syntax and create an equivalent Prolog list term
instance.
|
Set<PrologClause> |
parseProgram(File in)
Parse the Prolog text contained at specific file and return a Prolog clause
set found in the file.
|
Set<PrologClause> |
parseProgram(String file)
Parse the Prolog text contained at specific file path and return a Prolog
clause set found in the file.
|
PrologStructure |
parseStructure(String stringStructure)
Parse the string with Prolog syntax and create an equivalent Prolog structure
term instance.
|
PrologTerm |
parseTerm(String term)
Parse the string with Prolog syntax and create an equivalent Prolog term
instance.
|
PrologTerm[] |
parseTerms(String stringTerms)
Parse the comma separate terms in the given string with prolog syntax and
return an array of terms formed by the comma separate terms.
|
protected String |
removeQuoted(String functor) |
abstract String |
toString() |
<K extends PrologTerm> |
toTerm(Object o,
Class<K> from)
Create an equivalent Prolog term using the given native term representation
and cast this Prolog term to some specific given class.
|
<K extends PrologTerm> |
toTermArray(Object[] os,
Class<K[]> from)
Create an equivalent Prolog terms array using the given native terms array
representation and cast this Prolog term array to some specific array
component class.
|
<K extends PrologTerm,V> |
toTermMap(Map<String,V> map,
Class<K> from)
Create an equivalent Prolog terms map using the given native terms map
representation and cast every Prolog term to some specific given class.
|
<K extends PrologTerm,V> |
toTermMapArray(Map<String,V>[] map,
Class<K> from)
Create an equivalent Prolog terms map array using the given native terms map
array representation and cast every Prolog term to some specific given class.
|
<K extends PrologTerm> |
toTermMatrix(Object[][] oss,
Class<K[][]> from)
Create an equivalent Prolog terms matrix using the given native terms matrix
representation and cast every Prolog terms matrix to some specific matrix
component class.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
falseReference, getJavaConverter, getLogger, newAtom, newDouble, newEngine, newEngine, newEntry, newEntry, newFloat, newInteger, newList, newList, newList, newList, newLong, newMap, newMap, newMap, newReference, newStructure, newStructure, newVariable, newVariable, nullReference, prologCut, prologEmpty, prologFail, prologFalse, prologInclude, prologNil, prologTrue, trueReference, voidReference
protected final PrologConverter<?> converter
public AbstractProvider(PrologConverter<?> converter)
public final boolean isCompliant()
PrologProvider
isCompliant
in interface PrologProvider
public final PrologList parseList(String stringList)
stringList
- prolog term in string format.public final PrologClause parseClause(String stringClause)
stringClause
- prolog clause in string format.public final PrologStructure parseStructure(String stringStructure)
stringStructure
- prolog term in string format.public final Set<PrologClause> parseProgram(String file)
file
- file path to be parsed.public final Set<PrologClause> parseProgram(File in)
in
- file to be parsed.public final PrologFloat newFloat()
PrologProvider
newFloat
in interface PrologProvider
public final PrologDouble newDouble()
PrologProvider
newDouble
in interface PrologProvider
public final PrologInteger newInteger()
PrologProvider
newInteger
in interface PrologProvider
public final PrologLong newLong()
PrologProvider
newLong
in interface PrologProvider
public final PrologList newList(PrologTerm head)
PrologProvider
newList
in interface PrologProvider
head
- term item to be include in the prolog listpublic final PrologList newList(Object head)
PrologProvider
newList
in interface PrologProvider
head
- object item to be include in the prolog listpublic final PrologList newList(Object[] arguments)
PrologProvider
newList
in interface PrologProvider
arguments
- java objects arguments array.public final PrologList newList(Object head, Object tail)
PrologProvider
newList
in interface PrologProvider
head
- object item to be include like head in the prolog list.tail
- object item to be include like tail in the prolog list.public final PrologList newList(Object[] arguments, Object tail)
PrologProvider
newList
in interface PrologProvider
arguments
- java objects arguments array.tail
- java object to be the tail item.public final PrologTerm newStructure(String functor, Object... arguments)
PrologProvider
PrologStructure parent = provider.newStructure("parent", "tom", "bob"); System.out.println(parent);
newStructure
in interface PrologProvider
functor
- structure name.arguments
- java objects arguments array.public final PrologTerm newStructure(Object left, String operator, Object right)
PrologProvider
PrologVariable x = provider.newVariable("X", 0); PrologDouble pi = provider.newDouble(Math.PI); PrologStructure plusExp = provider.newStructure(x, "+", pi); System.out.println(plusExp);
newStructure
in interface PrologProvider
left
- left hand operandoperator
- infix operandright
- right hand operandprotected final <T extends PrologTerm> T cast(PrologTerm term, Class<T> type)
Class
object.term
- the object to be casttype
- the class or interface to be castedClassCastException
- if the object is not null and is not assignable to
the type T.public final <T extends PrologTerm> T cast(PrologTerm term)
PrologProvider
Class
object.cast
in interface PrologProvider
term
- the object to be castpublic final <K extends PrologTerm> K toTerm(Object o, Class<K> from)
K
- generic type that extends from PrologTerm
o
- native term representation to be convertedfrom
- class to be cast the result Prolog termpublic final <K extends PrologTerm> K[] toTermArray(Object[] os, Class<K[]> from)
K
- generic type that extends from PrologTerm
os
- native terms array representation to be convertedfrom
- class to be cast the result Prolog termpublic final <K extends PrologTerm> K[][] toTermMatrix(Object[][] oss, Class<K[][]> from)
K
- generic type that extends from PrologTerm
oss
- native terms matrix representation to be convertedfrom
- class to be cast the result Prolog termpublic final <K extends PrologTerm,V> Map<String,PrologTerm> toTermMap(Map<String,V> map, Class<K> from)
K
- generic type that extends from PrologTerm
V
- generic type that extends from Object
representing a
native prolog term.map
- native terms map representation to be convertedfrom
- class to be cast the result Prolog termpublic final <K extends PrologTerm,V> Map<String,PrologTerm>[] toTermMapArray(Map<String,V>[] map, Class<K> from)
K
- generic type that extends from PrologTerm
V
- generic type that extends from Object
representing a
native prolog term.map
- native terms map array to be converted in Prolog terms map array.from
- class to be cast the result Prolog termpublic final PrologConverter<?> getConverter()
PrologProvider
getConverter
in interface PrologProvider
public final <K> K fromTerm(PrologTerm term, Class<K> to)
K
- generic type that represent native prolog typeterm
- Prolog term to be converted to native term.to
- class to be cast the result native termpublic final <K> K[] fromTermArray(PrologTerm[] terms, Class<K[]> to)
K
- generic type that represent native prolog typeterms
- Prolog term array to be converted to native array.to
- class to be cast the result native termpublic final <K> K fromTerm(PrologTerm head, PrologTerm[] body, Class<K> to)
K
- generic type that represent native prolog typehead
- rule headbody
- rule bodyto
- class to be cast the result native termpublic final io.github.prolobjectlink.prolog.PrologParser getParser()
PrologProvider
getParser
in interface PrologProvider
public final String getVersion()
PrologProvider
getVersion
in interface PrologProvider
public final String getName()
PrologProvider
getName
in interface PrologProvider
public PrologTerm parseTerm(String term)
term
- prolog term in string format.public PrologTerm[] parseTerms(String stringTerms)
stringTerms
- comma separate terms with prolog syntaxCopyright © 2020–2024 Prolobjectlink Project. All rights reserved.