|
||||||||||
| PREV CLASS NEXT CLASS | NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
The KnowledgeBase interface publishes the API for a knowledge base created from a KnowledgeBaseFactory.
| Method Summary | |
boolean |
clear()
Return the KnowledgeBase to the state after initialize. |
void |
defineFunction(java.lang.String name,
EclipseFunction function)
Extends the Inference engine with a user-defined fuinction |
void |
deleteKnowledgeBase()
Deletes a knowledge base, causing exceptions if used again |
void |
deleteWorkingMemory(WorkingMemory workingMemory)
Deletes a working memory, causing exceptions if used again. |
boolean |
echoing()
Indicates whether information is being echoed to a file. |
Relation |
findRelation(java.lang.String name)
Find the Relation with the specified name
Each call to this function must be accompanied with a corresponding call to KnowledgeBaseObject.release(). |
Ruleset |
findRuleset(java.lang.String name)
Find the Ruleset with the specified name or null if no such ruleset exists. |
Template |
findTemplate(java.lang.String name)
Find the Template with the specified name or null if no such template exists. |
void |
flushEcho()
Flushes any echo |
java.lang.String |
getName()
Gets the name of the knowledgebase |
int |
getNumberOfArguments(java.lang.String name)
Get the number of arguments for the named function. |
java.lang.Object |
getObject()
Returns the object that was associated with the knowledge base |
RulesetIterator |
getRulesets()
|
void |
loadBatchFile(WorkingMemory workingMemory,
java.lang.String filename)
This function extecutes batch commands read from the specified file |
void |
loadBinary(java.io.InputStream stream)
Load a binary ruleset file (which invalidates the prior ruleset object and all of its agendas and their rules.) |
void |
loadBinaryFile(java.lang.String filename)
Load a binary ruleset file (which invalidates the prior ruleset object and all of its agendas and their rules.) |
void |
loadConfigurationFile(java.lang.String deploymentFilename,
long updateGranularity,
ConfigurationListener listener)
This method causes the running knowledge base to load and optionally track Eclipse (.clp or .bin) files specified in a deployment file (e.g., Deployment.xml). |
void |
loadConfigurationURL(java.net.URL deploymentURL,
long updateGranularity,
ConfigurationListener listener)
This method causes the running knowledge base to load and optionally track Eclipse (.clp or .bin) files specified in a deployment file (e.g., Deployment.xml). |
void |
loadFromDocumentElement(org.w3c.dom.Element documentElement)
This method causes the running knowledge base to load Eclipse (.clp or .bin) files specified in a deployment file (e.g., Deployment.xml) or an HRML file. |
void |
loadFromStream(java.io.InputStream inputStream)
This method causes the running knowledge base to load Eclipse (.clp or .bin) files specified in a deployment file (e.g., Deployment.xml) or an HRML file. |
void |
loadHRMLfile(java.lang.String filename)
Loads a file containing HRML and builds the corresponding relations, templates, deffacts, rulesets, agendas, and rules in the knowledge base. |
void |
loadHRMLfromReader(java.lang.String systemId,
java.io.Reader reader)
Loads HRML from a reader and builds the corresponding relations, templates, deffacts, rulesets, agendas, and rules in the knowledge base. |
void |
loadText(java.lang.String text)
Loads a string containing defrelation, deftemplate, deffacts, defruleset, and defrule constructs and builds the corresponding relations, templates, deffacts, rulesets, agendas, and rules in the knowledge base. |
void |
loadTextFile(java.lang.String filename)
Loads a file containing defrelation, deftemplate, deffacts, defruleset, and defrule constructs and builds the corresponding relations, templates, deffacts, rulesets, agendas, and rules in the knowledge base. |
WorkingMemory |
newWorkingMemory()
Create a new WorkingMemory in this KnowledgeBase. |
WorkingMemory |
newWorkingMemory(java.lang.Object object)
Create a new WorkingMemory in this KnowledgeBase. |
void |
setClassLoader(java.lang.ClassLoader classLoader)
Specifies and caches a reference to the ClassLoader on the KnowledgeBase. |
void |
setErrorListener(ErrorListener listener)
Add a listener for warning messages |
void |
setExecutionListener(ExecutionListener listener)
Add a listener for execute messages |
void |
setName(java.lang.String name)
Sets the name of the knowledgebase |
void |
setObject(java.lang.Object object)
Sets the object that was associated with the knowledge base |
void |
startEcho(java.lang.String fileName)
Causes all stream output directed to the standard knowledge base streams to be echoed to a file. |
void |
startEcho(java.lang.String fileName,
int nMinutes,
int nKiloBytes)
Causes all stream output directed to the standard knowledge base streams to be echoed to a file. |
void |
startEcho(java.io.Writer writer)
Captures all Eclipse output, trace and error messages in the given Writer |
void |
stopEcho()
Terminates the echoing of Eclipse output and closes the file or Writer. |
| Method Detail |
public java.lang.Object getObject()
throws EclipseException
EclipseException
public void setObject(java.lang.Object object)
throws EclipseException
object - the object to be associated with the knowledge base
EclipseException
public boolean clear()
throws EclipseException
EclipseException
public boolean echoing()
throws EclipseException
EclipseException
public Relation findRelation(java.lang.String name)
throws EclipseException
Relation with the specified name
Each call to this function must be accompanied with a corresponding call to KnowledgeBaseObject.release().
name - the name of the relation to find
EclipseException - if there is an internal errorKnowledgeBaseObject.release()
public RulesetIterator getRulesets()
throws EclipseException
EclipseException
public Ruleset findRuleset(java.lang.String name)
throws EclipseException
Ruleset with the specified name or null if no such ruleset exists.
Each call to this function must be accompanied with a corresponding call to KnowledgeBaseObject.release() or Ruleset.excise()
name - the name of the ruleset to find
EclipseException - if there is an internal errorKnowledgeBaseObject.release(),
Ruleset.excise()
public Template findTemplate(java.lang.String name)
throws EclipseException
Template with the specified name or null if no such template exists.
Each call to this function must be accompanied with a corresponding call to KnowledgeBaseObject.release().
name - the name of the template to find
EclipseException - if there is an internal errorKnowledgeBaseObject.release()
public int getNumberOfArguments(java.lang.String name)
throws EclipseException
name - the name of the function to get the number of arguments for
EclipseException - if there is an internal error
public void loadBatchFile(WorkingMemory workingMemory,
java.lang.String filename)
throws EclipseException
workingMemory - the working memroy to use to process the batch commandsfilename - the filename to load
EclipseException - if this method is not supported
EclipseException - if unable to open the file
public void loadBinary(java.io.InputStream stream)
throws EclipseException
stream - a InputStream
EclipseException - if the stream could not be loaded.DevelopmentKnowledgeBase.saveAsBinaryFile(Ruleset,String,boolean)
public void loadBinaryFile(java.lang.String filename)
throws EclipseException
filename -
EclipseException - if the file could not be loaded.
public void loadConfigurationFile(java.lang.String deploymentFilename,
long updateGranularity,
ConfigurationListener listener)
throws EclipseException
A typical user will call loadApplication once with the second parameter equal to, say, 300 so that the configuration is automatically checked for updates during calls to newWorkingMemory, but no more often than every 5 minutes (= 300 seconds). A value of zero for the second parameter indicates that a check for updates should be performed during each call to newWorkingMemory. A negative value for the second parameter indicates that no automatic checks should be performed. (The application can still make explicit calls to loadConfigurationFile() to force a check for updates.)
Working memories must not be running when new logic files are loaded into a knowledgebase.
Consequently, this method, newWorkingMemory() and
WorkingMemory.reset() are all synchronized on the same kb object,
so no new working memories will be created or reset during reloads.
However, already existing working memories might be running before a reload.
Furthermore, if model-level constructs would be modified by loading a configuration,
then clear will be called, destroying any facts stored in existing working memories.
To handle these possibilities, whenever
(re)loading is required, the reload
The third (optional) parameter is the name
of a class that implements the processUpdate method of the
ConfigurationListener interface. If the third parameter (ConfigurationListener)
is non-null, then before (re)loading a configuration, the processUpdate
method of the listener will be called to give the application a chance to react to and possibly prevent the
reload. If the processUpdate method returns false, no update is performed until possibly
the next automatic check for updates. (Even if processUpdate returns true, the reload will
not occur if working memories still exist; see below.)
ProcessUpdate's parameter indicates whether reloading the configuration
would cause Eclipse to be cleared. (See the documentation for the ConfigurationListener class
for full details about the ProcessUpdate method.)
The ProcessUpdate method can takes any actions that might
be needed to save data in case of a clear; this might be necessary for working memories that have finished
running but that contain facts that are still needed.
The user's processUpdate might need to call deleteWorkingMemory(WorkingMemory) to destroy
working memories.
deploymentFilename - The name of the XML file containing the application's deployment definition.updateGranularity - The number of seconds since the last update after which to check for
updates to the configuration during resets of working memory. A value less than zero indicates that
the application should never check for updates.listener - ConfigurationListener, or null (if reloads should just wait until working memories finish running)
EclipseException - if unable to load applicationConfigurationListener.processUpdate(int)
public void loadConfigurationURL(java.net.URL deploymentURL,
long updateGranularity,
ConfigurationListener listener)
throws EclipseException
deploymentURL - The URL of the XML file containing the application's deployment definition.updateGranularity - The number of seconds since the last update after which to check for
updates to the configuration during resets of working memory. A value less than zero indicates that
the application should never check for updates.listener - ConfigurationListener, or null (if reloads should just wait until working memories finish running)
EclipseException - if unable to load applicationloadConfigurationFile(String,long,ConfigurationListener),
ConfigurationListener.processUpdate(int)
public void loadFromStream(java.io.InputStream inputStream)
throws EclipseException
inputStream - a stream to read the deployment file or HRML file from. It it is a deployment file,
it must be self-contained, and not refer to external files.
EclipseException
public void loadFromDocumentElement(org.w3c.dom.Element documentElement)
throws EclipseException
documentElement - an org.w3c.dom.Element containing the deployment or the HRML file.
EclipseException
public void loadText(java.lang.String text)
throws EclipseException
text - the string containing the definition
EclipseException - if the constructs could not be added to the knowledge base.
EclipseException - if the constructs contains defrelation or deftemplate without a development knowledge base.
public void loadTextFile(java.lang.String filename)
throws EclipseException
filename - the file to load
EclipseException - if the file could not be opened.
EclipseException - if the file contains errors.
EclipseException - if the file contains defrelation or deftemplate without a development knowledge base.
public void loadHRMLfile(java.lang.String filename)
throws EclipseException
filename - the file to load
EclipseException - if the file could not be opened.
EclipseException - if the file contains errors.
EclipseException - if the file contains defrelation or deftemplate without a development knowledge base.
public void loadHRMLfromReader(java.lang.String systemId,
java.io.Reader reader)
throws EclipseException
systemId - the identifier for the XMLreader - the source for the XML
EclipseException - if the file could not be opened.
EclipseException - if the file contains errors.
EclipseException - if the file contains defrelation or deftemplate without a development knowledge base.
public WorkingMemory newWorkingMemory(java.lang.Object object)
throws EclipseException
object - the object to associate with the owkring memory, may be null
EclipseException - if creation failsnewWorkingMemory(),
WorkingMemory.getObject(),
WorkingMemory.setObject(Object)
public WorkingMemory newWorkingMemory()
throws EclipseException
EclipseException - if creation failsnewWorkingMemory(Object),
WorkingMemory.getObject(),
WorkingMemory.setObject(Object)
public void deleteWorkingMemory(WorkingMemory workingMemory)
throws EclipseException
workingMemory - to be deleted
EclipseException
public void startEcho(java.lang.String fileName,
int nMinutes,
int nKiloBytes)
throws EclipseException
If the nMinutes
If nMinutes is less than or equal to zero, then there is no time limit on the dribble file, otherwise the file is closed when the file exceeds the specified size and a new file is opened.
If a time or size limit has been imposed, then current time in CCYYMMDDhhmmss format is appended to the base of the file name before it is opened
fileName - the file name to which information should be echoednMinutes - the number of minutes to wait before closing the dribble file, where 0 means no limitnKiloBytes - the maximim size of the dribble file in kiloBytes, where 0 means no limit
EclipseException
public void startEcho(java.lang.String fileName)
throws EclipseException
fileName - the file name to which information should be echoed
EclipseException
public void startEcho(java.io.Writer writer)
throws EclipseException
Writer
writer - the Writer to write the output to
EclipseException
public void flushEcho()
throws EclipseException
EclipseException
public void stopEcho()
throws EclipseException
Writer.
If echoing() returns false, then this method has no effect. This method throws a RuntimeException (rather than
than an EclipseException) if the file is open but cannot be closed (so that catch clauses needn't catch them).
EclispeException - if unable to stop echoing
EclipseException
public void setErrorListener(ErrorListener listener)
throws EclipseException
listener - an ErrorListener
EclipseException - if the knowledge base has been deleted
public void setExecutionListener(ExecutionListener listener)
throws EclipseException
listener - an ExecutionListener
EclipseException - if teh knowledge base has been deleted
java.lang.NullPointerException - if listener is null
public void setClassLoader(java.lang.ClassLoader classLoader)
throws EclipseException
classLoader - the ClassLoader to be used by the KnowledgeBase.
EclipseException - if the KnowledgeBase has been deleted
EclipseException - if an error occurred
public java.lang.String getName()
throws EclipseException
EclipseException - if an error occured
public void setName(java.lang.String name)
throws EclipseException
name - the name to set to
EclipseException - if an error occured
public void defineFunction(java.lang.String name,
EclipseFunction function)
throws EclipseException
name - the name of the function as it will appear in the Eclipse languagefunction - the Java function that implements the function
EclipseExcpetion - if an error occurred
EclipseException
public void deleteKnowledgeBase()
throws EclipseException
EclipseException
|
||||||||||
| PREV CLASS NEXT CLASS | NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||