public class JIPEngine extends Object implements Serializable
JIPQuery
,
Serialized FormModifier and Type | Field and Description |
---|---|
static int |
build |
static int |
major |
static int |
minor |
static int |
revision |
Constructor and Description |
---|
JIPEngine()
Constructs a new instance of JIPEngine with default values search path, input and output stream.
|
Modifier and Type | Method and Description |
---|---|
void |
abolish(JIPTerm term)
It is equivalent to abolish/1 predicate.
|
void |
addEventListener(JIPEventListener listener)
Adds the specified JIPEventListener object
|
void |
addTraceListener(JIPTraceListener traceListener)
Adds the specified JIPTraceListener object
|
void |
asserta(JIPTerm term)
It is equivalent to asserta/1 predicate.
|
void |
assertz(JIPTerm term)
It is equivalent to assert/1 predicate.
|
void |
closeAllQueries()
Closes all pending queries
|
void |
closeQuery(int nQueryHandle)
Closes a query.
|
void |
compileFile(String strFileName)
Compile the specified file.
|
void |
consultFile(String strFileName)
Consults a file.
|
void |
consultStream(InputStream ins,
String strStreamName)
Consults a Stream.
|
protected void |
finalize()
Releases the resources used by JIProlog
Developers should not call it directly.
|
static String |
getCopyrightInfo()
Returns Copyright
|
InputStream |
getCurrentInputStream()
Gets current InputStream
|
String |
getCurrentInputStreamName()
Gets current InputStream Name
|
OutputStream |
getCurrentOutputStream()
Gets current OutputStream
|
String |
getCurrentOutputStreamName()
Gets current OutputStream Name
|
boolean |
getDebug()
gets debug flag.
|
String |
getEncoding()
Gets current encoding
|
Object |
getEnvVariable(String varName)
Gets the value of a custom environment variable.
|
Enumeration<String> |
getEnvVariableNames()
Gets the enumeration of all custom environment variable name.
|
Vector |
getEventListeners()
Gets the list of JIPEventListeners
|
boolean |
getImmediateUpdateSemantics()
Gets the update semantics
|
static String |
getInfo()
Returns JIProlog info
|
static String |
getLicenseInfo()
Returns JIProlog license info
|
String |
getSearchPath()
returns the search path of this instance of JIPEngine.
|
JIPTermParser |
getTermParser()
Returns the instance of JIPTermParser attached to this JIPEngine object
Use JIPTermParser to parse prolog terms |
boolean |
getTrace()
Returns the trace flag.
|
Vector |
getTraceListeners()
Gets the list of JIPTraceListener
|
InputStream |
getUserInputStream()
Gets user InputStream
|
OutputStream |
getUserOutputStream()
Gets user OutputStream
|
static String |
getVersion()
Returns the JIProlog version
|
boolean |
hasMoreChoicePoints(int nQueryHandle)
Returns true if the query has more choice points on backtracking.
|
boolean |
isInternal(JIPFunctor funct)
Returns true if the given functor is an internal predicate.
|
boolean |
isInternal(String strName)
Returns true if the given functor is an internal predicate.
|
boolean |
isSystem(JIPFunctor funct)
Returns true if the given functor is a system predicate.
|
boolean |
isSystem(String strName)
Returns true if the given functor is a system predicate.
|
void |
loadFile(String strFileName)
Loads a file.
|
void |
loadLibrary(String strPath)
Load an extensions library.
|
void |
loadStream(InputStream ins,
String strStreamName)
Loads a stream.
|
void |
nextSolution(int nQueryHandle)
Searches for another soution.
|
void |
notifyEvent(int nID,
JIPTerm term,
int nQueryHandle)
Notifies a JIPEvent.
|
int |
openQuery(JIPTerm jipquery)
Opens a query.
|
int |
openQuery(String strQuery)
Opens a query.
|
JIPQuery |
openSynchronousQuery(JIPTerm jipquery)
Returns a reference to a synchronous query.
|
JIPQuery |
openSynchronousQuery(String strQuery)
Returns a reference to a synchronous query.
|
void |
releaseAllResources()
Closes all pending queries and release all threads and resources.
|
Object |
removeEnvVariable(String varName)
Removes a custom environment variable.
|
void |
removeEventListener(JIPEventListener listener)
Removes the specified JIPEventListener object
|
void |
removeTraceListener(JIPTraceListener traceListener)
Removes the specified JIPTraceListener object
|
void |
reset()
Closes all pending queries, reset the prolog interpreter and clear the database
|
boolean |
retract(JIPTerm term)
It is equivalent to retract/1 predicate.
|
void |
setCurrentInputStream(InputStream ins,
String strStreamName)
Sets current InputStream
|
void |
setCurrentOutputStream(OutputStream outs,
String strStreamName)
Sets current OutputStream
|
void |
setDebug(boolean debug)
Sets debug flag.
|
void |
setEncoding(String encoding)
Sets current encoding
|
void |
setEnvVariable(String varName,
Object value)
Sets the value of a custom environment variable.
|
void |
setImmediateUpdateSemantics(boolean immediate)
Sets the update semantics
ISO Prolog specifies that a prolog system should implement 'logical update
semantics' on the internal database.
|
void |
setSearchPath(String strSearchPath)
Sets the search path of this instance of JIPEngine.
|
void |
setTrace(boolean bTrace)
Sets the trace flag.
|
void |
setUserInputStream(InputStream ins)
Sets user InputStream
|
void |
setUserOutputStream(OutputStream outs)
Sets user OutputStream
|
void |
unconsultFile(String strFileName)
Unconsults/unloads a file.
|
void |
unconsultStream(String strStreamName)
Unconsults/unloads a stream.
|
public static final int major
public static final int minor
public static final int build
public static final int revision
public JIPEngine()
public static final String getVersion()
public static final String getInfo()
public static final String getCopyrightInfo()
public static final String getLicenseInfo()
public void setImmediateUpdateSemantics(boolean immediate)
immediate
- true - immediate update semantics, false - logical update semantics (default)public boolean getImmediateUpdateSemantics()
public void setDebug(boolean debug)
public boolean getDebug()
public final boolean isSystem(String strName)
public final boolean isSystem(JIPFunctor funct)
public final boolean isInternal(String strName)
public final boolean isInternal(JIPFunctor funct)
public final void loadLibrary(String strPath) throws IOException
IOException
public void addEventListener(JIPEventListener listener)
listener
- JIPEventListener object to addJIPEventListener
public void removeEventListener(JIPEventListener listener)
listener
- JIPEventListener object to removeJIPEventListener
public Vector getEventListeners()
JIPEventListener
public void addTraceListener(JIPTraceListener traceListener)
traceListener
- JIPTraceListener object to addJIPTraceListener
public void removeTraceListener(JIPTraceListener traceListener)
traceListener
- JIPTraceListener object to removeJIPTraceListener
public Vector getTraceListeners()
JIPTraceListener
public final void setSearchPath(String strSearchPath) throws IOException
strSearchPath
- Search pathIOException
getSearchPath()
public final String getSearchPath()
setSearchPath(java.lang.String)
public final void setTrace(boolean bTrace)
bTrace
- Trace flaggetTrace()
public final boolean getTrace()
setTrace(boolean)
public final void setUserOutputStream(OutputStream outs)
outs
- the user output stream to set.getUserOutputStream()
public final OutputStream getUserOutputStream()
setUserOutputStream(java.io.OutputStream)
public final void setUserInputStream(InputStream ins)
ins
- the user input stream to setgetUserInputStream()
public final InputStream getUserInputStream()
setUserInputStream(java.io.InputStream)
public final OutputStream getCurrentOutputStream()
setCurrentOutputStream(java.io.OutputStream, java.lang.String)
public final void setCurrentOutputStream(OutputStream outs, String strStreamName)
outs
- the current output stream to setgetUserOutputStream()
public final void setCurrentInputStream(InputStream ins, String strStreamName)
ins
- the current input stream to setstrStreamName
- the name of the input streamgetUserInputStream()
public final InputStream getCurrentInputStream()
setCurrentInputStream(java.io.InputStream, java.lang.String)
public final String getCurrentInputStreamName()
public final String getCurrentOutputStreamName()
public final String getEncoding()
public final void setEncoding(String encoding)
encoding
- the encodingpublic void reset()
public void releaseAllResources()
public final void consultFile(String strFileName) throws JIPSyntaxErrorException, IOException
strFileName
- the name of the file to consult. It can refer to: com.ugos.jiprolog.engine.JIPSyntaxErrorException,
- java.io.IOExceptionJIPSyntaxErrorException
IOException
loadFile(java.lang.String)
,
setSearchPath(java.lang.String)
public final void consultStream(InputStream ins, String strStreamName) throws JIPSyntaxErrorException
ins
- is the stream to consultstrStreamName
- is the symbolic name of the streamcom.ugos.jiprolog.engine.JIPSyntaxErrorException,
- java.io.IOExceptionJIPSyntaxErrorException
loadStream(java.io.InputStream, java.lang.String)
,
setSearchPath(java.lang.String)
public final void unconsultFile(String strFileName)
strFileName
- the name of the file to unconsult.loadFile(java.lang.String)
,
consultFile(java.lang.String)
public final void unconsultStream(String strStreamName)
strStreamName
- the name of the stream to unconsult.loadStream(java.io.InputStream, java.lang.String)
,
consultStream(java.io.InputStream, java.lang.String)
public final void compileFile(String strFileName) throws JIPSyntaxErrorException
strFileName
- the name of the file to compile. It can refer to: com.ugos.jiprolog.engine.JIPSyntaxErrorException,
- java.io.IOExceptionJIPSyntaxErrorException
loadFile(java.lang.String)
,
setSearchPath(java.lang.String)
public final void loadFile(String strFileName) throws IOException
strFileName
- the name of the file to load. It can refer to: IOException
consultFile(java.lang.String)
,
setSearchPath(java.lang.String)
public final void loadStream(InputStream ins, String strStreamName) throws IOException
ins
- the inpustream to loadstrStreamName
- the name of the file to load. It can refer to: IOException
loadFile(java.lang.String)
,
setSearchPath(java.lang.String)
public final void asserta(JIPTerm term)
term
- the term to assert.public final boolean retract(JIPTerm term)
term
- the term to retract.public final void assertz(JIPTerm term)
term
- the term to assert.public final void abolish(JIPTerm term)
term
- the term to abolish.public JIPQuery openSynchronousQuery(String strQuery) throws JIPSyntaxErrorException
strQuery
- Query as a text stringJIPSyntaxErrorException
JIPQuery
,
openQuery(String)
public JIPQuery openSynchronousQuery(JIPTerm jipquery)
jipquery
- Query to openJIPQuery
,
openQuery(JIPTerm)
public int openQuery(String strQuery) throws JIPSyntaxErrorException
strQuery
- Query as a text stringJIPSyntaxErrorException
nextSolution(int)
,
closeQuery(int)
,
JIPEventListener.openNotified(com.ugos.jiprolog.engine.JIPEvent)
public int openQuery(JIPTerm jipquery)
jipquery
- Query as a JIPTermJIPTermParser.parseTerm(java.lang.String)
,
nextSolution(int)
,
closeQuery(int)
,
JIPEventListener
public void nextSolution(int nQueryHandle)
nQueryHandle
- the handle of the queryopenQuery(JIPTerm)
,
closeQuery(int)
,
JIPEventListener
public void closeQuery(int nQueryHandle)
nQueryHandle
- the handle of the query to closenextSolution(int)
,
closeQuery(int)
,
JIPEventListener.closeNotified(com.ugos.jiprolog.engine.JIPEvent)
public boolean hasMoreChoicePoints(int nQueryHandle)
nQueryHandle
- the handle of the queryopenQuery(JIPTerm)
,
nextSolution(int)
,
closeQuery(int)
public void closeAllQueries()
openQuery(JIPTerm)
,
nextSolution(int)
,
closeQuery(int)
public void setEnvVariable(String varName, Object value)
varName
- the name of the variablevalue
- the value of the variablegetEnvVariable(java.lang.String)
,
removeEnvVariable(java.lang.String)
public Object getEnvVariable(String varName)
varName
- the name of the variablesetEnvVariable(java.lang.String, java.lang.Object)
,
removeEnvVariable(java.lang.String)
public final Object removeEnvVariable(String varName)
varName
- the name of the variable to removesetEnvVariable(java.lang.String, java.lang.Object)
,
getEnvVariable(java.lang.String)
public Enumeration<String> getEnvVariableNames()
public final void notifyEvent(int nID, JIPTerm term, int nQueryHandle)
nID
- the ID of the event to notifyterm
- the term attached to the eventnQueryHandle
- the handle of the query which notifies the eventJIPEvent
,
JIPTraceEvent
public final JIPTermParser getTermParser()
JIPTermParser