ABLE 2.0.0 07/02/2003 10:25:01

com.ibm.able.rules
Class AbleRuleSet

java.lang.Object
  |
  +--com.ibm.able.AbleObject
        |
        +--com.ibm.able.rules.AbleRuleSet
All Implemented Interfaces:
AbleBean, AbleDataBufferManager, AbleDataContext, AbleEventListener, AbleEventListenerManager, AbleEventQueueManager, AbleEventQueueProcessor, AblePropertyChangeManager, AbleSerializable, AbleUserDefinedFunctionManager, java.io.Serializable

public class AbleRuleSet
extends AbleObject
implements AbleUserDefinedFunctionManager, AbleDataContext, java.io.Serializable

This class defines an AbleRuleSet bean which is the run-time representation of an Able Rule Language ruleset.

A ruleset object is a collection of variables, rules, and optional user-defined functions, all of which can be used by one or Able inference engines to solve problems. Input data can be read from, and solution data can be written to, standard Able program buffers, thus allowing a ruleset to be embedded in, or connected to, other Able objects.

There are several ways in which to instantiate a ruleset object. One way is to use a text editor, such as the Able ruleset customizer, to write a rule program in the Able rule language and then save that program to disk. Later on, a ruleset bean can instantiate itself from that source rule file.

  AbleRuleSet rs = new AbleRuleSet("test"); // construct the ruleset bean
  rs.parseFromARL("test.arl") ;      // compile the ruleset text file
  rs.init() ;                               // initialize the bean 
 

Another way is similar to the first, but involves writing the rules in XML according to the Able rule XML Schema.

  AbleRuleSet rs = new AbleRuleSet("test"); // construct the ruleset bean
  rs.parseFromXML("test.arml") ;      // compile the ruleset XML file
  rs.init() ;                               // initialize the bean 
 

Yet another way is to create a ruleset entirely programmatically by using the ruleset's APIs to dynamically create variables, clauses, and rules as necessary.

Once a ruleset has been successfully instantiated, through any means, the ruleset can be saved in serialized form for later use.

See Also:
Serialized Form

Field Summary
protected  java.lang.Object altInputBuffer
          "altInputBuffer" is initialized to null, but can be used by other objects to provide input data to this bean's process() synchronous method via an AbleEvent with "process" as the action string and an Object[] as the argument Object.
static int DEBUG_CLAUSE
          Debug type; Stop before each clause.
static int DEBUG_INFERENCE_CYCLE
          Debug type; Stop at each inference cycle.
static int DEBUG_OFF
          Debug type; No inference engine debugging.
static int DEBUG_RULE
          Debug type; Stop before each rule.
static int DEBUG_RULEBLOCK
          Debug type; Stop before entering each ruleblock.
static int DEBUG_USER_BREAKPOINT
          Debug type; Stop at user breakpoints only..
static java.lang.String defaultName
          Value assigned to name by default.
static java.lang.String FileNameUntitled
          FileName: Default file name for an "untitled" ruleset, no matter what type.
static java.lang.String FileTypeARLSerial
          FileType: ARL RuleSet/SERialized ruleset object files.
static java.lang.String FileTypeARLSource
          FileType: ARL RuleSet source rule language files.
static java.lang.String FileTypeARLXml
          FileType: ARL RuleSet/XML source document files.
static java.lang.String InferenceEngineBackward
          Inference method: BackwardChain.
static java.lang.String InferenceEngineDefault
          Inference Engine.
static java.lang.String InferenceEngineForward
          Inference engine: Forward.
static java.lang.String InferenceEngineFuzzy
          Inference Engine: Fuzzy
static java.lang.String InferenceEngineMutEx
          Inference Engine: MutEx.
static java.lang.String InferenceEnginePatternMatch
          Inference method: PatternMatch.
static java.lang.String InferenceEnginePatternMatchRete
          Inference method: PatternMatchRete.
static java.lang.String InferenceEnginePredicate
          Inference Engine: Predicate.
static java.lang.String InferenceEngineScript
          Inference Engine: Script.
static java.lang.String InferenceEngineUnknown
          Inference engine: Unknown.
protected  java.util.Vector myAntClauses
           
protected  AbleARLParser myARLParser
           
protected  AbleARLTreeNode myARLTree
           
protected  java.util.Vector myAstClauses
           
protected  java.lang.Object myBaseTraceHandler
           
protected  long myBaseTraceLvl
           
protected  java.util.Hashtable myBuiltInDataTypes
           
protected  java.util.HashSet myBuiltInPredicates
           
protected  java.util.Hashtable myBuiltInUdfs
           
protected  java.beans.PropertyChangeSupport myChgSupport
          This change support object is used differently than the "chgSupport" object found in the AbleObject super class.
protected  java.util.Vector myCnsClauses
           
protected  AbleInferenceEngine myCurrentInferenceEngine
           
protected  AbleRuleBlock myCurrentRuleBlock
           
protected  int myDebugLevel
          The debug level : 0 = off > 0 = on
protected  java.util.Hashtable myDeclaredDataTypes
           
protected  java.util.Vector myDeclaredDataTypesOrder
           
protected  java.util.Vector myDeclaredInnerClassesOrder
           
protected  java.util.Hashtable myDeclaredPredicates
           
protected  java.util.Vector myDeclaredPredicatesOrder
           
protected  java.util.Vector myDeclaredUdfLibs
           
protected  java.util.Hashtable myDeclaredUdfs
           
protected  java.util.Vector myDeclaredVarsIn
           
protected  java.util.Vector myDeclaredVarsOut
           
protected  java.util.Hashtable myEngineList
           
protected  java.lang.String myEngineType
           
protected  java.lang.String myErrorName
           
protected  java.util.Hashtable myExpressions
           
protected  java.util.BitSet myFbCurrent
           
protected  java.util.BitSet myFbInitial
           
protected  java.util.HashMap myFieldGetMethods
           
protected  java.util.Hashtable myFieldList
           
protected  java.util.HashMap myFieldSetMethods
           
protected  java.util.Hashtable myFloatLiterals
           
protected  java.util.Hashtable myGlobalTypedVariableFields
           
protected  java.lang.String myGoalVariableName
          The goal variable is used by backward chaining inference engines only.
protected  java.util.Hashtable myImportedUdfs
           
protected  AbleInferenceContext myInferenceContext
          This object holds the current state of the active inference engine This data is maintained by the inference engine and formatted using toString() for display when exceptions occur during inferencing.
protected  java.util.Stack myInferenceContextStack
          This object is a stack of AbleInferenceContext objects.
protected  java.lang.Object myInferTraceHandler
           
protected  long myInferTraceLvl
           
protected  java.util.Hashtable myInnerClassDefs
           
protected  java.util.Hashtable myInnerClasses
           
protected  java.util.Hashtable myIntegerLiterals
           
protected  java.lang.String myIsExReason
           
protected  java.util.Hashtable myLocalTypedVariableFields
           
protected  java.util.Hashtable myLocalVars
           
protected  java.util.Hashtable myLongLiterals
           
protected  java.util.Hashtable myNumericLiterals
           
protected  boolean myParserInErrorState
           
protected  java.lang.Object myParseTraceHandler
           
protected  long myParseTraceLvl
           
protected  AblePredicateQuery myPredicateQuery
          The predicate query is used by the predicate inference engine only.
protected  java.util.Hashtable myPredicateSymbols
           
protected  java.util.ResourceBundle myResourceBundle
           
protected  java.lang.String myResourceBundleName
           
protected  java.util.Hashtable myRuleBlocks
           
protected  java.util.Vector myRuleBlocksOrder
           
protected  int myRuleId
           
protected  java.util.HashSet myRuleLabels
           
protected  java.util.Hashtable myRuleList
           
protected  java.util.Hashtable myRuleTemplateList
           
protected  java.util.Hashtable myRuntimeUdfs
           
protected  java.io.File mySrcFile
          The file object containing the source language statements of this ruleset.
protected  java.lang.String mySrcFileName
          The name of the file containing the source language statements of this ruleset.
protected  java.util.Hashtable myStringLiterals
           
protected  boolean myTemplateFlag
          A flag that indicates whether this ruleset is a template ruleset.
protected  java.util.Vector myTypedVariableFieldsList
           
protected  java.util.Vector myVarBuiltInList
           
protected  AbleTypedVariable myVarEvent
           
protected  AbleTypedVariable myVarException
           
protected  AbleBuiltInVariable myVarFunctionList
           
protected  int myVarId
           
protected  AbleArrayVariable myVarInputBuffer
           
protected  java.util.Hashtable myVarList
           
protected  AbleBuiltInVariable myVarNull
           
protected  java.util.Vector myVarOrder
           
protected  AbleArrayVariable myVarOutputBuffer
           
protected  AbleBuiltInVariable myVarParent
           
protected  AbleBuiltInVariable myVarThis
           
protected  AbleBuiltInVariable myVarVariableList
           
protected  AbleTypedVariable myVarWm
           
protected  AbleWorkingMemory myWorkingMemory
           
protected  java.lang.String myXmlFileName
          The name of the file containing the XML document of this ruleset.
static int TokenTypeIsBoolean
          Token type; the parsed string represents a boolean value, either "true" or "false".
static int TokenTypeIsCallName
          Token type; the parsed string represents the name of a user-defined function.
static int TokenTypeIsChar
          Token type; the parsed string represents a character literal value
static int TokenTypeIsDouble
          Token type; the parsed string represents a double literal.
static int TokenTypeIsFloat
          Token type; the parsed string represents a Float value
static int TokenTypeIsInteger
          Token type; the parsed string represents an integer value
static int TokenTypeIsLong
          Token type; the parsed string represents a Long value
static int TokenTypeIsName
          Token type; the parsed string represents the name of a variable.
static int TokenTypeIsNewObject
          Token type; the parsed string represents a new Object value
static int TokenTypeIsPredicate
          Token type; the parsed string represents a Predicate value
static int TokenTypeIsSetName
          Token type; the parsed string represents the name of a fuzzy set.
static int TokenTypeIsString
          Token type; the parsed string represents either the name of a variable or a string literal.
static int TokenTypeIsTimeStamp
          Token type; the parsed string represents a time stamp literal value
static int TokenTypeIsUnknown
          Token type; unknown.
static int TokenTypeIsVarFldPair
          Token type; the parsed string represents the name of a variable with a field name.
static int TokenTypeIsVarInxPair
          Token type; the parsed string represents the name of an array variable with an index expression.
static int TokenTypeIsVarMthPair
          Token type; the parsed string represents the name of a variable with a method name.
 
Fields inherited from class com.ibm.able.AbleObject
changed, chgSupport, comment, dataFlowEnabled, destBufferConnections, eventQueue, fileName, inputBuffer, listeners, logger, name, outputBuffer, parent, propertyConnectionMgr, sourceBufferConnections, state, stateChgSupport, trace
 
Constructor Summary
AbleRuleSet()
           
AbleRuleSet(java.lang.String theName)
          Create a new ruleset, using the specified trace objects.
 
Method Summary
 void addBreakpoint(AbleRuleBreakpoint theBreakpoint)
          Add the breakpoint at the specified location
protected  void addIsExReason(java.lang.String theIsExReason)
          Yeah, it's a weird name, but it's due to historical reasons!
protected  AbleVariable addLocalOrGlobalVariable(java.lang.String theVariableName, java.lang.String theVariableType)
           
 AbleVariable addLocalVariable(java.lang.String theVariableName, java.lang.String theVariableType)
          Create and add a local variable to the ruleset
 void addRule(AbleRuleBlock theRuleBlock, AbleRule theRule)
          Add an Able rule to the specified rule block.
 void addRuleBlock(java.lang.String theRuleBlockName, java.lang.String theReturnType)
          Specify the name of the current rule block under parse.
 AbleRule addRuleFromTemplate(AbleRuleTemplate theTemplate)
          Add a new rule using the template and its bound template variable values
 AbleRule addRuleFromTemplate(java.lang.String theTemplateName, java.lang.Object[] theTemplateVarValues)
          Add a new rule using the template name and associated template variable values
 void addRuleSetChangeListener(java.beans.PropertyChangeListener theListener)
          Add a property change listener to the ruleset.
 void addUserDefinedFunction(AbleUserDefinedFunction theUserDefinedFunction)
          Add a specific user-defined function to the master list of user-defined functions.
 void addVariable(AbleVariable theVariable)
          Add a variable to the ruleset.
 void addVariableToInputSequence(java.lang.String theVariableName)
          Specify that a variable is to be added to the input sequence.
 void addVariableToOutputSequence(java.lang.String theVariableName)
          Specify that a variable is to be added to the output sequence.
 java.lang.String arlString()
          Return a formal able rule language (ARL) string with Java-like syntax.
protected  java.lang.String arlStringDclInnerClasses()
           
protected  java.lang.String arlStringDclPredicates()
           
protected  java.lang.String arlStringHeader()
           
protected  java.lang.String arlStringImports()
           
protected  java.lang.String arlStringInputVariables()
           
protected  java.lang.String arlStringLibraries()
           
protected  java.lang.String arlStringOutputVariables()
           
protected  java.lang.String arlStringRules()
           
protected  java.lang.String arlStringTrailer()
           
protected  java.lang.String arlStringUdfs()
           
protected  java.lang.String arlStringVariables()
           
 void checkTimePeriodPreConditions(java.util.Calendar theCurrentTime)
          Evaluate each rule in every ruleblock against the time period preconditions.
 void clear()
          Clear the ruleset of all variables and rules, clear out the trace logs, set the ruleset name to the empty string (""), and set all ruleset options (alphacut, correlation method, and so on) to default values.
protected  void clearLocalVarList()
           
 boolean containsUserDefinedFunction(java.lang.String theUserDefinedFunctionName, int theArity)
          Determine whether the master list of user-defined functions contains a user-defined function with the specified name and arity.
protected static java.util.Vector convertToConjunctiveNormalForm(AbleExpression theExpr, AbleRuleSet theRuleSet)
          Convert an Expression into conjunctive normal form a list of AbleAntecedentClauses (which may contain Expressions)
static java.lang.String Copyright()
          Determine the copyright of this class.
 AbleRd createArrayExpressionLiteral(java.lang.String theArrayVarName, AbleRd theIndexExpr)
          Create an AbleArrayVariableExpression object (AbleRd) which represents an Array variable with an index expression.
 AbleRd createCallLiteral(java.lang.String theCallName, java.util.Vector theCallParms)
          Create an AbleCallLiteral (AbleRd) object which represents a function call with arguments.
 void createFuzzySet(AbleFuzzyVariable theFuzzyVariable, java.lang.String theSetName, java.lang.String theSetType, java.util.Vector theArgs, double theAlphaCut, boolean isComplement)
          Create a FuzzySet of the specified type and add it to a FuzzyVariable.
 AbleRd createFuzzySetLiteral(java.lang.String theRuleToken, AbleRd theFuzzyVar, java.lang.String theHedges)
          Create an AbleFuzzySet literal (AbleRd) object.
 AbleRd createLiteral(int theRuleTokenType, java.lang.String theRuleToken)
          Create an AbleRd object literal suitable for use in an AbleExpression, and AbleClause or an AbleRule.
 AbleRd createNewObjectLiteral(java.lang.String theDataType, java.util.Vector theCallParms, java.lang.String theFieldOrMethodName, AbleRd theIndexExpr)
          Create an AbleRd object suitable for use on the right-hand side of an AbleClause.
 AbleRd createRdObject(int theRuleTokenType, java.lang.String theRuleToken, java.util.Vector theCallParms, AbleRd theFuzzyVar, java.lang.String theHedges, java.lang.String theFieldOrMethodName, AbleRd theIndexExpr)
          Create an AbleRd object suitable for use in AbleRules.
protected  AbleRule createRuleFromTemplate(AbleRuleTemplate theTemplate, boolean theReplacementMode)
          Create a new rule (or replace an existing one) using the rule template and its bound template variable values
 AbleRuleSet createRuleSetFromTemplate(AbleRuleSetTemplate theTemplate)
          Create a new ruleset from a template using the template and its bound template variable values
 AbleRd createTimeStampLit(java.lang.String theRuleToken)
          Given a string representation of a timestamp (date/time) create a TimeStampLiteral from it
 AbleRd createVariableFieldLiteral(java.lang.String theRuleToken, java.lang.String theFieldName)
          Create an AbleTypedVariableField object which represents a data member (field) of the object contained by an AbleTypedVariable.
 AbleRd createVariableMethodLiteral(java.lang.String theRuleToken, java.util.Vector theCallParms, java.lang.String theMethodName)
          Create an AbleTypedVariableMethodLiteral object, which represents a method call with arguments on an AbleTypedVariable.
 void dataChanged()
          Signal all registered listeners that this bean's internal state has changed by sending a synchronous event to all registered listeners via the AbleObject.dataChanged(java.lang.Object) with this ruleset as the changed object.
 void declareEngineType(java.lang.String theEngineType, java.lang.String theEngineClassName)
          Declare an inference engine type and class name.
 AbleVariable declareGlobalVariable(java.lang.String theVariableName, boolean theVariableStaticFlag, java.lang.String theVariableType)
          Declare a global variable by creating an instance and adding it to the ruleset.
 void declareInnerClass(java.lang.String theInnerClassName, java.lang.String theComment, java.util.Vector theFieldNames, java.util.Vector theFieldTypes)
          Declare an inner class, as a user-defined data type.
 void declarePredicate(java.lang.String thePredicateName)
          Declare a predicate.
 void declareUserDataType(java.lang.String theUserTypeName, java.lang.String theUserTypeClass)
          Declare a user-defined data type.
 void declareUserDefinedFunction(java.lang.String theUserDefinedFunctionName)
          Declare a user-defined function that must be available at runtime.
 void declareUserDefinedFunctionLib(java.lang.String theUDFLibName)
          Declare a user-defined function library that must be available at runtime.
 void declareUserDefinedFunctionLib(java.lang.String theUDFLibName, java.lang.Class theUDFLibClass)
          Declare a user-defined function library that must be available at runtime.
protected  AbleAntecedentClause findOrCreateAntecedent(AbleAntecedentClause theClause)
          See if the specified clause already exists, and if it does, return the original.
protected  AbleAntecedentClause findOrCreateAntecedent(AbleRd theLhs, int theRuleOp, AbleRd theRhs, double theRuleAntWeight)
          See if the specified clause exists, and if it does, return it.
protected  AbleAssertionClause findOrCreateAssertion(AbleLhs theLhs, int theRuleOp, AbleRd theRhs)
          See if the specified clause exists, and if it does, return it.
protected  AbleConsequentClause findOrCreateConsequent(AbleLhs theLhs, int theRuleOp, AbleRd theRhs)
          See if the specified clause exists, and if it does, return it.
protected  AbleRd findOrCreateDoubleLit(java.lang.String theRuleToken)
          See if the specified literal exists, and if it does, return it.
protected  AbleExpression findOrCreateExpression(AbleRd theLhs, int theRuleOp, AbleRd theRhs)
          See if the specified expression exists, and if it does, return it.
protected  AbleRd findOrCreateFloatLit(java.lang.String theRuleToken)
          See if the specified literal exists, and if it does, return it.
protected  AbleRd findOrCreateIntegerLit(java.lang.String theRuleToken)
          See if the specified literal exists, and if it does, return it.
protected  AbleVariable findOrCreateLocalPredicateVariable(java.lang.String theVariableName)
           
protected  AbleRd findOrCreateLongLit(java.lang.String theRuleToken)
          See if the specified literal exists, and if it does, return it.
protected  java.lang.String findOrCreatePredicateSymbol(java.lang.String thePredicateSymbol)
           
protected  AbleRd findOrCreateStringLit(java.lang.String theRuleToken)
          See if the specified literal exists, and if it does, return it.
 AbleARLParser getARLParser()
          Retrieve the parser used to instantiate the ruleset.
 AbleARLTreeNode getARLTree()
          Retrieve the content outline of this ruleset, produced by the parser
 long getBaseTraceLevel()
          Return the level for base tracing.
 java.beans.PropertyChangeSupport getChgSupport()
          Retrieve the PropertyChangeSupport object.
 java.lang.Object getControlParameter(java.lang.String theControlParameter)
          Returns a single control parameter on the current inference engine.
 java.lang.Object getControlParameter(java.lang.String theRuleBlockName, java.lang.String theControlParameter)
          Returns a single control parameter on the inference engine associated with the specified ruleblock.
 int getCorrelationMethod()
          Retrieve the current correlation method.
 java.util.Calendar getCurrentDateAndTime()
          A built-in method that can be called from within a ruleset; it returns a Calendar object containing the current date and time of day.
 java.util.Calendar getCurrentDateAndTime(java.lang.String theTimeZoneId, java.lang.String theLanguage, java.lang.String theCountry)
          A built-in method that can be called from within a ruleset; it returns a Calendar object containing the current date and time of day, based on a Locale determined from the input parameters.
 java.util.BitSet getCurrentFactBase()
          Retrieve the current fact base.
 java.lang.Object getDebugConsole()
          Get the debug console (if any) for this ruleset
 int getDebugLevel()
          Get the debug level for the associated inference engine
 java.util.Hashtable getDeclaredPredicates()
           
 java.util.Hashtable getDeclaredUserDefinedFunctions()
          Get all declared user-defined functions.
 int getDefuzzifyMethod()
          Retrieve the current defuzzification method.
 int getFuzzyInferenceMethod()
          Retrieve the current fuzzy inference method.
 java.util.Vector getFuzzyVariables()
          Get fuzzy variables.
 java.util.Vector getGeneratedRulesFromTemplate(java.lang.String theTemplateName)
          Retrieve the list of rules generated from the specified template
 java.util.Hashtable getImportedUserDefinedFunctions()
          Retrieve the set of active (imported) user-defined functions.
 AbleInferenceContext getInferenceContext()
          Return the current inference engine trace context (used for tracing/debugging).
 java.util.Stack getInferenceContextStack()
          Return the stack of inference engine trace contexts.
 AbleInferenceEngine getInferenceEngine()
          Retrieve the current inference engine object.
 AbleInferenceEngine getInferenceEngine(java.lang.String theRuleBlockName)
          Retrieve the inference engine associated with the specified ruleblock.
 java.lang.String getInferenceEngineClassName(java.lang.String theEngineType)
          Retrieve the inference engine class name from the engines list.
 long getInferenceTraceLevel()
          Return the level for inference tracing.
 AbleLogger getInferTraceLogger()
          Retrieve the inferencing tracer logger.
 java.util.BitSet getInitialFactBase()
          Retrieve the initial fact base.
 java.lang.Class getInnerClass(java.lang.String theClassName)
          Retrieve an inner class given its name
 int getNumInputVars()
          Retrieve the number of input variables.
 int getNumOutputVars()
          Retrieve the number of output variables.
 java.util.Vector getOutputVars()
          Retrieve the output variables.
 long getParseTraceLevel()
          Return the level for parse tracing.
protected  java.util.Hashtable getPredicateSymbols()
           
 java.util.ResourceBundle getResourceBundle()
          Retrieve the resource bundle for use with this ruleset.
 java.lang.String getResourceBundleName()
          Retrieve the resource bundle base name for use with this ruleset.
 AbleRule getRule(java.lang.String theRuleLabel)
          Retrieve a rule by name.
 AbleRuleBlock getRuleBlock(java.lang.String theRuleBlockName)
          Retrieve a rule block by name.
 java.util.Hashtable getRuleBlocks()
          Retrieve all rule blocks.
 boolean getRuleEnabled(java.lang.String theRuleLabel)
          Retrieve a rule's enabled state.
 boolean getRuleFired(java.lang.String theRuleLabel)
          Retrieve a rule's fired state.
 double getRulePriority(java.lang.String theRuleLabel)
          Retrieve a rule's priority.
 java.lang.String getRuleSetName()
          Retrieve the name of the ruleset.
 AbleRuleSetTemplate getRuleSetTemplate()
          Retrieve a ruleset template object (if defined) else return null
 int getRulesFiredCount(java.lang.String theRuleBlockName)
          Returns the number of rules fired by the specified rule block and associated inference engine during the last infer() call on the engine
 AbleRuleTemplate getRuleTemplate(java.lang.String theRuleName)
          Retrieve a rule template object based on specified rule name
 AbleRuleTemplate getRuleTemplateFromRule(java.lang.String theRuleName)
          Retrieve the template from which this rule was generated (if any)
 java.util.Vector getRuleTemplates()
          Retrieve all the rule template objects defined in this ruleset
 java.lang.String getSerFileName()
          Retrieve the name of the serialized file for this ruleset.
 java.io.File getSrcFile()
          Retrieve the name of the source file for this ruleset.
 java.lang.String getSrcFileName()
          Retrieve the name of the source file for this ruleset.
 java.lang.String getTemplateString(java.util.Vector theTemplateVars)
          Retrieve a text format string for use by ruleset templates.
protected  java.lang.String getTemplateStringDclInnerClasses(java.util.Vector theTemplateVars)
           
protected  java.lang.String getTemplateStringDclPredicates(java.util.Vector theTemplateVars)
           
protected  java.lang.String getTemplateStringHeader(java.util.Vector theTemplateVars)
           
protected  java.lang.String getTemplateStringInputVariables(java.util.Vector theTemplateVars)
           
protected  java.lang.String getTemplateStringOutputVariables(java.util.Vector theTemplateVars)
           
protected  java.lang.String getTemplateStringRules(java.util.Vector theTemplateVars)
           
protected  java.lang.String getTemplateStringTrailer()
           
protected  java.lang.String getTemplateStringUdfs(java.util.Vector theTemplateVars)
           
protected  java.lang.String getTemplateStringVariables(java.util.Vector theTemplateVars)
           
 java.util.Vector getTemplateVariables()
          Return a list of all template vars referenced by this ruleset.
protected  java.util.Vector getTemplateVariables(java.util.BitSet theIds)
          Get a list of template variables based on a BitSet.
 java.util.Hashtable getUserDefinedDataTypes()
          Retrieve the set of user-defined data types.
 AbleUserDefinedFunction getUserDefinedFunction(java.lang.String theUserDefinedFunctionName, int theArity)
          Retrieve the specified user-defined function
 java.util.Hashtable getUserDefinedFunctions()
          Get the complete master list of user-defined functions registered with this function manager.
 AbleVariable getVariable(java.lang.String theVariableName)
          Retrieve a reference to a variable declared in the ruleset.
 java.util.Hashtable getVariables()
          Get variables.
 java.util.Vector getVariables(java.util.BitSet theIds)
          Get a list of variables based on a BitSet.
 AbleWorkingMemory getWorkingMemory()
          Retrieve the current workingMemory object (may be null).
 AbleWorkingMemory getWorkingMemory(java.lang.String theRuleBlockName)
          Retrieve the workingMemory object associated with the specified rule block.
 java.lang.String getXmlFileName()
          Retrieve the name of the XML file for this ruleset.
 boolean hasDebugConsole()
          Tests whether this rule set object has an external debug console (GUI)
 void init()
          Initialize and configure the bean.
 void initRuleTemplates()
          Initialize the rule template in this ruleset and invoke the initRuleTemplates() ruleblock to refresh any info on rules that were already generated in this ruleset.
 void insertRuleAt(int theIndex, AbleRuleBlock theRuleBlock, AbleRule theRule)
          Insert an Able rule at the specified position in the rule block.
 void instantiateFrom(java.io.DataInputStream theStream, AbleLogger theTracer, boolean theStopOnAbleExceptionFlag)
          Deprecated. As of version 1.4.2, use parseFromArl(DataInputStream)
 void instantiateFrom(java.lang.String theFileName, AbleLogger theTracer, boolean theStopOnAbleExceptionFlag)
          Deprecated. As of version 1.4.2, use parseFromArl(String theFileName)
 void instantiateFromXml(java.io.File theFile, AbleLogger theTracer, boolean theStopOnAbleExceptionFlag)
          Deprecated. As of version 1.4.2, use parseFromXrl(File theFile)
 void instantiateFromXml(java.io.InputStream theInputStream, AbleLogger theTracer, boolean theStopOnAbleExceptionFlag)
          Deprecated. As of version 1.4.2, use parseFromXml(InputStream theInputStream)
 void instantiateFromXml(java.lang.String theFileName)
          Deprecated. As of version 1.4.2, use parseFromXrl(String theFileName)
 void instantiateFromXml(java.lang.String theFileName, AbleLogger theTracer, boolean theStopOnAbleExceptionFlag)
          Deprecated. As of version 1.4.2, use parseFromXml(String theFileName)
 java.lang.Object invokeRuleBlock(java.lang.String theRuleBlockName)
          Process the rules in the specified rule block in a sequential manner.
 java.lang.Object invokeUserDefinedFunction(java.lang.String theUserDefinedFunctionName, java.lang.Object[] theArgs)
          Call the actual method that the named user-defined function represents, passing in the array of argument objects.
protected  boolean ioBuffersOK()
          Determine whether the input and output buffers are the expected object type (Object[]) and that they have enough slots to hold the required input and output variables.
 boolean isBaseTraceHigh()
          Returns true if high level base trace messages should be sent to tracer.
 boolean isBaseTraceLow()
          Returns true if low level base trace messages should be sent to tracer.
 boolean isBaseTraceMedium()
          Returns true if medium level base trace messages should be sent to tracer.
protected  boolean isBuiltInDataType(java.lang.String theDataTypeName)
          Determine whether a data type is a built-in type.
protected  boolean isBuiltInFunction(java.lang.String theName)
           
 boolean isBuiltInVariableName(java.lang.String theVariableName)
          Determine whether a variable with the specified name is a "built-in" variable.
protected  boolean isDeclaredDataType(java.lang.String theUserTypeName)
          Determine whether an imported (user-defined) data type has already been declared within this ruleset.
 boolean isDeclaredPredicateName(java.lang.String thePredicateName)
           
 boolean isDeclaredRuleBlockName(java.lang.String theRuleBlockName)
          Determine whether a rule block with the specified name exists within the ruleset.
 boolean isDeclaredRuleLabel(java.lang.String theRuleLabel)
          Determine whether any rule in the ruleset contains the specified label.
protected  boolean isDeclaredUserDefinedFunctionLibName(java.lang.String theImportLibName)
          Determine whether a user-defined function library with the specified name exists within the ruleset.
protected  boolean isDeclaredUserDefinedFunctionName(java.lang.String theNameAndArity)
          Determine whether a user-defined function with the specified name has already been declared as an externally added user-defined function to this ruleset.
 boolean isExecutable()
          Determine whether the ruleset is executable.
 boolean isGlobalVariableName(java.lang.String theVariableName)
          Determine whether a global variable with the specified name exists in the ruleset.
 boolean isImportedUserDefinedFunction(java.lang.String theImportName)
          Determine whether an imported user-defined function with the specified name exists within the ruleset.
 boolean isInferenceTraceHigh()
          Returns true if high level inference trace messages should be sent to tracer.
 boolean isInferenceTraceLow()
          Returns true if low level inference trace messages should be sent to tracer.
 boolean isInferenceTraceMedium()
          Returns true if medium level inference trace messages should be sent to tracer.
 boolean isLocalOrGlobalVariableName(java.lang.String theVariableName)
          Determine whether a variable (either local or global) with the specified name exists in the ruleset.
 boolean isParseTraceHigh()
          Returns true if high level inference trace messages should be sent to tracer.
 boolean isParseTraceLow()
          Returns true if low level parse trace messages should be sent to tracer.
 boolean isParseTraceMedium()
          Returns true if medium level parse trace messages should be sent to tracer.
 boolean isTemplate()
          Returns true if this ruleset is a template ruleset, false otherwise.
 AbleRuleBlock parseConsultRuleBlockFromARL(java.lang.String theArlSource)
          Parse and instantiate a predicate consult() ruleblock object by reading an input String containing ABLE Rule Language text source.
 AbleRd parseExpressionFromARL(java.lang.String theArlSource)
          Parse and instantiate an AbleRd object (a Literal, Variable, or Expression) by reading an input String containing ABLE Rule Language text source.
 AbleRd parseExpressionFromXML(java.lang.String theArmlSource)
          Parse and instantiate an AbleRd object (a Literal, Variable, or Expression) by reading an input String containing ABLE Rule Language XML source.
 void parseFromARL(java.io.File theFile)
          Parse the ruleset object by reading a rule source file contained in the specified input file.
 void parseFromARL(java.io.InputStream theStream)
          Parse the ruleset by reading an ARL rule source file contained in the specified input stream.
 void parseFromARL(java.lang.String theFileName)
          Instantiate the ruleset object by reading a rule source file contained in the specified input file.
 void parseFromXML(java.io.File theFile)
          Parse the ruleset by reading an XML rule document contained in the specified input file.
 void parseFromXML(java.io.InputStream theInputStream)
          Instantiate the ruleset object by reading an XML rule document contained in the specified input stream.
 void parseFromXML(java.lang.String theFileName)
          Parse the ruleset by reading an XML rule source file contained in the specified input file.
 AbleRuleBlock parseRuleBlockFromARL(java.lang.String theArlSource)
          Parse and instantiate a complete ruleblock object by reading an input String containing ABLE Rule Language text source.
 AbleRuleBlock parseRuleBlockFromXML(java.lang.String theArmlSource)
          Parse and instantiate a complete ruleblock object by reading an input String containing ABLE Rule Language XML source.
 AbleRule parseRuleFromARL(java.lang.String theArlSource, java.lang.String theRuleBlockName, boolean theReplacementMode)
          Parse and instantiate a complete rule object by reading an input String containing ABLE Rule Language text source.
 AbleRule parseRuleFromXML(java.lang.String theArmlSource, java.lang.String theRuleBlockName, boolean theReplacementMode)
          Parse and instantiate a complete rule object by reading an input String containing ABLE Rule Language XML source.
 AbleRuleSet parseRuleSetFromARL(java.lang.String theArlSource)
          Parse and instantiate a complete ruleset object by reading an input String containing ABLE Rule Language text source.
 AbleRuleSet parseRuleSetFromXML(java.lang.String theArmlSource)
          Parse and instantiate a complete ruleset object by reading an input String containing ABLE Rule Language XML source string.
protected  boolean predicateNameIsBuiltIn(java.lang.String thePredicateName)
           
 void print(java.lang.Object theMsgText)
          Write a text string to the console (System.out) without a line separator.
 void println(java.lang.Object theMsgText)
          Write a text string to the console (System.out) followed by a line separator.
 void println(java.lang.Object theMsgText1, java.lang.Object theMsgText2)
          Write two text strings to the console (System.out) on the same line: msgText1 + msgText2.
 void process()
          Perform the standard processing function performed by this object.
 void process(boolean reset)
           
 java.lang.Object process(java.lang.Object theArg)
          Perform the main, standard processing function performed by this bean, using the argument Object (usually passed via an AbleEvent).
 void processAbleEvent(AbleEvent theAbleEvent)
          Process an Able event synchronously; that is, on the same thread as the caller.
protected  void processInput(java.util.BitSet theFactBase)
          For each variable appearing in the input sequence, extract a value from the input buffer and assign it to the variable.
 void processOutput()
          For each variable appearing in the output sequence, obtain the variable's current value and write it to the output buffer.
 void processTimerEvent()
          This method is called from the asynch thread when the bean timer is configured to fire.
 java.lang.Object processWithContext(java.lang.Object theArg, java.util.Hashtable theVars, java.util.Hashtable theFuncs, AbleWorkingMemory theWm)
          Process this ruleset with variables, user-defined functions (externally attached UDFs only), and working memory from some other ruleset.
 void quitAll()
          Stop all of the bean's asynchronous threads of control.
 void removeBreakpoint(AbleRuleBreakpoint theBreakpoint)
          Remove the breakpoint from the specified location
 void removeRule(AbleRule theRule)
          Remove an Able rule from the ruleset (and containing rule block).
 void removeRuleBlock(java.lang.String theRuleBlockName)
          Remove the ruleblock from the ruleset.
 void removeRuleSetChangeListener(java.beans.PropertyChangeListener theListener)
          Remove a property change listener from the ruleset.
 void removeUserDefinedFunction(java.lang.String theUserDefinedFunctionName, int theArity)
          Remove the named user-defined function from the master list of user-defined functions.
 void replaceRule(AbleRule theRule)
          Replace an Able rule (any type) in the ruleset.
 AbleRule replaceRuleFromTemplate(AbleRuleTemplate theTemplate)
          Replace an existing rule (previously generated from a template) using the template and its bound template variable values
 AbleRule replaceRuleFromTemplate(java.lang.String theTemplateName, java.lang.Object[] theTemplateVarValues)
          Replace an existing rule (previously generated from a template) using the template name and associated template variable values
 void reset()
          Reset the ruleset so that rules can be fired again.
 void resetVariable(java.lang.String theVariableName)
          Reset a global variable to its initial value (as declared in the variables section).
 void resetVariables(java.lang.Object[] theVariableNames)
          Reset a list of global variables to their initial value (as declared in the variables section).
 void returnFromRuleBlock(java.lang.Object theReturnValue)
           
 void saveAsArl(java.lang.String theFileName)
          Save (write) an AbleRuleSet out as an ARL text rule file.
 void saveAsXml(java.lang.String theFileName)
          Save (write) an AbleRuleSet out as an XML rule file.
 void setBaseTraceHandler(java.lang.Object handler, long theTraceLevel)
          Turn base tracing on or off.
 void setBaseTraceLevel(int theTraceLevel)
          Turn base tracing on or off from a ruleset or, an application which need not provide its own handler for output.
 void setBaseTraceLevel(long theTraceLevel)
          Turn ruleset tracing on or off.
 void setControlParameter(java.lang.String theControlParameter, java.lang.Object theValue)
          Set a single control parameter on the current inference engine.
 void setControlParameter(java.lang.String theRuleBlockName, java.lang.String theControlParameter, java.lang.Object theValue)
          Set a single control parameter on the inference engine associated with the specified ruleblock.
 void setCurrentFactBase(java.util.BitSet theFactBase)
          Set the current fact base, the set of bound variables during the course of inferencing.
 AbleRuleBlock setCurrentRuleBlock(java.lang.String theRuleBlockName)
          Set the current rule block by name.
 void setDebugConsole(java.lang.Object theDebugConsole)
          Set the debug console on this ruleset
 void setDebugLevel(int theDebugLevel)
          Set the debug level for the associated inference engine
 void setInferenceEngine(java.lang.String theInferenceEngine)
          Set the inference engine to the specified type.
 void setInferenceTraceHandler(java.lang.Object handler, long theTraceLevel)
          Turn inference tracing on or off.
 void setInferenceTraceLevel(int theTraceLevel)
          Turn inference tracing on or off from a ruleset or, an application which need not provide its own handler for output.
 void setInferenceTraceLevel(long theTraceLevel)
          Turn inference tracing on or off.
 void setInputBuffer(java.lang.Object theInputBuffer)
          Set the input buffer to the specified object.
 void setOutputBuffer(java.lang.Object theOutputBuffer)
          Set the output buffer to the specified object.
 void setParent(AbleBeanContainer theParent)
          Set the containing parent of this bean.
protected  void setParserInErrorState(boolean theParserInErrorState)
          Indicate whether any errors occurred during parsing.
 void setParseTraceHandler(java.lang.Object handler, long theTraceLevel)
          Turn parse tracing on or off.
 void setParseTraceLevel(int theTraceLevel)
          Turn parse tracing on or off.
 void setParseTraceLevel(long theTraceLevel)
          Turn parse tracing on or off.
 void setResourceBundleName(java.lang.String theResourceBundleName)
          Set the base name of a ResourceBundle (or subclass) to be associated with this ruleset.
 void setRuleEnabled(java.lang.String theRuleLabel, boolean theState)
          Set a rule's enabled state.
 void setRulePriority(java.lang.String theRuleLabel, double theRulePriority)
          Set a rule's priority.
 void setRulePrompt(java.lang.String theRuleName, java.lang.String thePrompt)
          Set the Prompt string on a rule to be used by an associated UI
 void setRuleSetName(java.lang.String theRuleSetName)
          Specify the name of the ruleset.
 void setRuleTemplateInfo(java.lang.String theTemplateName, java.lang.Object[] theTemplateVarValues)
          Set the rule template info for a previously generated rule.
 void setSerFileName(java.lang.String theSerFileName)
          Specify the name of the serialized file for this ruleset.
 void setSrcFile(java.io.File theSrcFile)
          Specify the source file object for this ruleset.
 void setSrcFileName(java.lang.String theSrcFileName)
          Specify the name of the source file for this ruleset.
 void setTemplate(boolean theTemplateFlag)
          Set the state of the template flag for this ruleset.
 void setUserDefinedFunctions(java.util.Hashtable theUserDefinedFunctions)
          Set the complete master list of user-defined functions for this function manager.
 void setValueList(java.lang.String theVariableName, java.util.Vector theValueList)
          Set the value list on a Categorical or Discrete variable
 void setVariablePrompt(java.lang.String theVariableName, java.lang.String thePrompt)
          Set the Prompt string on a variable to be used by an associated UI
 void setWorkingMemory(AbleWorkingMemory theWorkingMemory)
          Set the current workingMemory object to the specified value.
 void setXmlFileName(java.lang.String theXmlFileName)
          Specify the name of the XML document file for this ruleset.
 void throwException(java.lang.Exception theException)
          Throw an exception from a rule.
static java.lang.String TokenType(int theItem)
           
 java.lang.String toString()
          Retrieve a string describing (the contents of) the object.
 java.lang.String trace(java.lang.Object theMsgObject)
          Write a text string to the specified ruleset's Inference trace log.
 java.lang.String traceFormat(java.lang.String theFormatString, java.lang.Object[] theInsert)
          Write a formatted text string with a single insertion argument to the specified ruleset's Inference trace log.
 void updateCurrentFactBase(int theVarId)
          Update the current fact base by setting the bit representing a newly bound variable.
protected static java.lang.String wrapBraces(java.lang.String theArlString)
          Take a valid ARL string and wrap any braces with single quotes for use as part of a template (text format) string
 java.lang.String xmlString()
          Retrieve the XML representation of this rule set.
protected  java.lang.String xmlStringDclInnerClasses()
           
protected  java.lang.String xmlStringDclPredicates()
           
protected  java.lang.String xmlStringHeader()
           
protected  java.lang.String xmlStringImports()
           
protected  java.lang.String xmlStringInputVariables()
           
protected  java.lang.String xmlStringLibraries()
           
protected  java.lang.String xmlStringOutputVariables()
           
protected  java.lang.String xmlStringRules()
           
protected  java.lang.String xmlStringTrailer()
           
protected  java.lang.String xmlStringUdfs()
           
protected  java.lang.String xmlStringVariables()
           
 
Methods inherited from class com.ibm.able.AbleObject
addAbleEventListener, addDestBufferConnection, addPropertyChangeListener, addPropertyConnection, addSourceBufferConnection, addStateChangeListener, dataChanged, firePropertyChange, flushAbleEventQueue, getAbleEventListeners, getAbleEventProcessingEnabled, getAbleEventQueueSize, getComment, getDestBufferConnections, getFileName, getInputBuffer, getInputBuffer, getInputBufferAsStringArray, getInputBufferContents, getLogger, getName, getOutputBuffer, getOutputBuffer, getOutputBufferAsStringArray, getOutputBufferContents, getParent, getPropertyConnectionManager, getSleepTime, getSourceBufferConnections, getState, getTraceLogger, handleAbleEvent, hasInputBuffer, hasOutputBuffer, init, isAbleEventPostingEnabled, isAbleEventProcessingEnabled, isChanged, isConnectable, isDataFlowEnabled, isTimerEventProcessingEnabled, notifyAbleEventListeners, processBufferConnections, processNoEventProcessingEnabledSituation, quitEnabledEventProcessing, removeAbleEventListener, removeAllAbleEventListeners, removeAllBufferConnections, removeAllConnections, removeAllPropertyConnections, removeDestBufferConnection, removePropertyChangeListener, removePropertyConnection, removeSourceBufferConnection, removeStateChangeListener, restartEnabledEventProcessing, restoreFromFile, restoreFromFile, restoreFromSerializedFile, restoreFromStream, resumeAll, resumeEnabledEventProcessing, saveToFile, saveToFile, setAbleEventProcessingEnabled, setChanged, setComment, setDataFlowEnabled, setFileName, setInputBuffer, setLogger, setName, setOutputBuffer, setSleepTime, setState, setTimerEventProcessingEnabled, setTraceLogger, sourceConnectionsOK, startEnabledEventProcessing, suspendAll, suspendEnabledEventProcessing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defaultName

public static final java.lang.String defaultName
Value assigned to name by default.

FileNameUntitled

public static final java.lang.String FileNameUntitled
FileName: Default file name for an "untitled" ruleset, no matter what type.

FileTypeARLSource

public static final java.lang.String FileTypeARLSource
FileType: ARL RuleSet source rule language files.

FileTypeARLSerial

public static final java.lang.String FileTypeARLSerial
FileType: ARL RuleSet/SERialized ruleset object files.

FileTypeARLXml

public static final java.lang.String FileTypeARLXml
FileType: ARL RuleSet/XML source document files.

InferenceEngineUnknown

public static final java.lang.String InferenceEngineUnknown
Inference engine: Unknown.
See Also:
setInferenceEngine(java.lang.String)

InferenceEngineForward

public static final java.lang.String InferenceEngineForward
Inference engine: Forward.
See Also:
setInferenceEngine(java.lang.String)

InferenceEnginePatternMatch

public static final java.lang.String InferenceEnginePatternMatch
Inference method: PatternMatch.
See Also:
setInferenceEngine(java.lang.String)

InferenceEnginePatternMatchRete

public static final java.lang.String InferenceEnginePatternMatchRete
Inference method: PatternMatchRete.
See Also:
setInferenceEngine(java.lang.String)

InferenceEngineBackward

public static final java.lang.String InferenceEngineBackward
Inference method: BackwardChain.
See Also:
setInferenceEngine(java.lang.String)

InferenceEngineFuzzy

public static final java.lang.String InferenceEngineFuzzy
Inference Engine: Fuzzy
See Also:
setInferenceEngine(java.lang.String)

InferenceEnginePredicate

public static final java.lang.String InferenceEnginePredicate
Inference Engine: Predicate.
See Also:
setInferenceEngine(java.lang.String)

InferenceEngineScript

public static final java.lang.String InferenceEngineScript
Inference Engine: Script.
See Also:
setInferenceEngine(java.lang.String)

InferenceEngineMutEx

public static final java.lang.String InferenceEngineMutEx
Inference Engine: MutEx.
See Also:
setInferenceEngine(java.lang.String)

InferenceEngineDefault

public static final java.lang.String InferenceEngineDefault
Inference Engine. The value of this constant specifies the inference Engine used by ruleblocks when the inference method is not explicitly set by the user.

In this implementation, the default is set to InferenceEngineScript.

See Also:
setInferenceEngine(java.lang.String)

TokenTypeIsUnknown

public static final int TokenTypeIsUnknown
Token type; unknown.

TokenTypeIsBoolean

public static final int TokenTypeIsBoolean
Token type; the parsed string represents a boolean value, either "true" or "false".

TokenTypeIsName

public static final int TokenTypeIsName
Token type; the parsed string represents the name of a variable.

TokenTypeIsDouble

public static final int TokenTypeIsDouble
Token type; the parsed string represents a double literal.

TokenTypeIsSetName

public static final int TokenTypeIsSetName
Token type; the parsed string represents the name of a fuzzy set.

TokenTypeIsCallName

public static final int TokenTypeIsCallName
Token type; the parsed string represents the name of a user-defined function.

TokenTypeIsString

public static final int TokenTypeIsString
Token type; the parsed string represents either the name of a variable or a string literal.

TokenTypeIsVarFldPair

public static final int TokenTypeIsVarFldPair
Token type; the parsed string represents the name of a variable with a field name.

TokenTypeIsVarMthPair

public static final int TokenTypeIsVarMthPair
Token type; the parsed string represents the name of a variable with a method name.

TokenTypeIsVarInxPair

public static final int TokenTypeIsVarInxPair
Token type; the parsed string represents the name of an array variable with an index expression.

TokenTypeIsInteger

public static final int TokenTypeIsInteger
Token type; the parsed string represents an integer value

TokenTypeIsPredicate

public static final int TokenTypeIsPredicate
Token type; the parsed string represents a Predicate value

TokenTypeIsFloat

public static final int TokenTypeIsFloat
Token type; the parsed string represents a Float value

TokenTypeIsLong

public static final int TokenTypeIsLong
Token type; the parsed string represents a Long value

TokenTypeIsNewObject

public static final int TokenTypeIsNewObject
Token type; the parsed string represents a new Object value

TokenTypeIsChar

public static final int TokenTypeIsChar
Token type; the parsed string represents a character literal value

TokenTypeIsTimeStamp

public static final int TokenTypeIsTimeStamp
Token type; the parsed string represents a time stamp literal value

DEBUG_OFF

public static final int DEBUG_OFF
Debug type; No inference engine debugging.

DEBUG_USER_BREAKPOINT

public static final int DEBUG_USER_BREAKPOINT
Debug type; Stop at user breakpoints only..

DEBUG_INFERENCE_CYCLE

public static final int DEBUG_INFERENCE_CYCLE
Debug type; Stop at each inference cycle.

DEBUG_RULEBLOCK

public static final int DEBUG_RULEBLOCK
Debug type; Stop before entering each ruleblock.

DEBUG_RULE

public static final int DEBUG_RULE
Debug type; Stop before each rule.

DEBUG_CLAUSE

public static final int DEBUG_CLAUSE
Debug type; Stop before each clause.

myEngineType

protected java.lang.String myEngineType

myResourceBundleName

protected java.lang.String myResourceBundleName

myResourceBundle

protected transient java.util.ResourceBundle myResourceBundle

myBuiltInDataTypes

protected java.util.Hashtable myBuiltInDataTypes

myARLTree

protected transient AbleARLTreeNode myARLTree

myARLParser

protected transient AbleARLParser myARLParser

myVarId

protected int myVarId

myVarList

protected java.util.Hashtable myVarList

myVarOrder

protected java.util.Vector myVarOrder

myDeclaredVarsIn

protected java.util.Vector myDeclaredVarsIn

myDeclaredVarsOut

protected java.util.Vector myDeclaredVarsOut

myLocalVars

protected java.util.Hashtable myLocalVars

myGlobalTypedVariableFields

protected java.util.Hashtable myGlobalTypedVariableFields

myLocalTypedVariableFields

protected java.util.Hashtable myLocalTypedVariableFields

myTypedVariableFieldsList

protected java.util.Vector myTypedVariableFieldsList

myFieldList

protected transient java.util.Hashtable myFieldList

myFieldGetMethods

protected transient java.util.HashMap myFieldGetMethods

myFieldSetMethods

protected transient java.util.HashMap myFieldSetMethods

myRuleId

protected int myRuleId

myRuleList

protected java.util.Hashtable myRuleList

myRuleLabels

protected java.util.HashSet myRuleLabels

myRuleBlocks

protected java.util.Hashtable myRuleBlocks

myRuleBlocksOrder

protected java.util.Vector myRuleBlocksOrder

myCurrentRuleBlock

protected AbleRuleBlock myCurrentRuleBlock

myCurrentInferenceEngine

protected AbleInferenceEngine myCurrentInferenceEngine

myEngineList

protected java.util.Hashtable myEngineList

myRuleTemplateList

protected java.util.Hashtable myRuleTemplateList

myFbInitial

protected java.util.BitSet myFbInitial

myFbCurrent

protected java.util.BitSet myFbCurrent

myDeclaredUdfs

protected java.util.Hashtable myDeclaredUdfs

myRuntimeUdfs

protected java.util.Hashtable myRuntimeUdfs

myDeclaredUdfLibs

protected java.util.Vector myDeclaredUdfLibs

myImportedUdfs

protected java.util.Hashtable myImportedUdfs

myBuiltInUdfs

protected java.util.Hashtable myBuiltInUdfs

myDeclaredDataTypes

protected java.util.Hashtable myDeclaredDataTypes

myDeclaredDataTypesOrder

protected java.util.Vector myDeclaredDataTypesOrder

myInnerClasses

protected transient java.util.Hashtable myInnerClasses

myInnerClassDefs

protected java.util.Hashtable myInnerClassDefs

myDeclaredInnerClassesOrder

protected java.util.Vector myDeclaredInnerClassesOrder

myBuiltInPredicates

protected java.util.HashSet myBuiltInPredicates

myDeclaredPredicates

protected java.util.Hashtable myDeclaredPredicates

myDeclaredPredicatesOrder

protected java.util.Vector myDeclaredPredicatesOrder

myPredicateSymbols

protected java.util.Hashtable myPredicateSymbols

myNumericLiterals

protected java.util.Hashtable myNumericLiterals

myFloatLiterals

protected java.util.Hashtable myFloatLiterals

myIntegerLiterals

protected java.util.Hashtable myIntegerLiterals

myLongLiterals

protected java.util.Hashtable myLongLiterals

myStringLiterals

protected java.util.Hashtable myStringLiterals

myAstClauses

protected java.util.Vector myAstClauses

myAntClauses

protected java.util.Vector myAntClauses

myCnsClauses

protected java.util.Vector myCnsClauses

myExpressions

protected java.util.Hashtable myExpressions

myBaseTraceHandler

protected transient java.lang.Object myBaseTraceHandler

myInferTraceHandler

protected transient java.lang.Object myInferTraceHandler

myParseTraceHandler

protected transient java.lang.Object myParseTraceHandler

myBaseTraceLvl

protected transient long myBaseTraceLvl

myInferTraceLvl

protected transient long myInferTraceLvl

myParseTraceLvl

protected transient long myParseTraceLvl

myIsExReason

protected java.lang.String myIsExReason

myErrorName

protected java.lang.String myErrorName

myParserInErrorState

protected boolean myParserInErrorState

myChgSupport

protected java.beans.PropertyChangeSupport myChgSupport
This change support object is used differently than the "chgSupport" object found in the AbleObject super class. That latter change support object is all but ignored by "rules" objects.

This particular change support object is passed on to Able variables, rules, inference engines, and so on -- anything in the inferencing world, -- so that matters relating to rule processing can be followed separately from other types of change support. For example, whenever a data variable is added to a ruleset, the ruleset makes the variable use this change support object.

Change listeners can register with the ruleset using the addRuleSetChangeListener() method.

Note that at the moment, any listener registered here must be serializable, as this field is not transient.

See Also:
addRuleSetChangeListener(PropertyChangeListener), removeRuleSetChangeListener(PropertyChangeListener)

myWorkingMemory

protected AbleWorkingMemory myWorkingMemory

myVarThis

protected AbleBuiltInVariable myVarThis

myVarParent

protected AbleBuiltInVariable myVarParent

myVarFunctionList

protected AbleBuiltInVariable myVarFunctionList

myVarVariableList

protected AbleBuiltInVariable myVarVariableList

myVarInputBuffer

protected AbleArrayVariable myVarInputBuffer

myVarOutputBuffer

protected AbleArrayVariable myVarOutputBuffer

myVarWm

protected AbleTypedVariable myVarWm

myVarNull

protected AbleBuiltInVariable myVarNull

myVarException

protected AbleTypedVariable myVarException

myVarEvent

protected AbleTypedVariable myVarEvent

myVarBuiltInList

protected java.util.Vector myVarBuiltInList

myTemplateFlag

protected boolean myTemplateFlag
A flag that indicates whether this ruleset is a template ruleset. Template ruleset are used to customize and generate new rulesets but are not executable themselves.

mySrcFile

protected transient java.io.File mySrcFile
The file object containing the source language statements of this ruleset.

Note that this variable is transient. This is because serialized objects will likely be transferred from system to system with possibly different file systems and file naming conventions. When this happens, it is not likely that the source file will accompany the serialized file, and if it should, it is not likely that the source file would appear within the same directory structure as it did on the originating system!

Therefore, remember this: this variable has meaning only during a single Able Rule Editor session, and not from session to session!


mySrcFileName

protected transient java.lang.String mySrcFileName
The name of the file containing the source language statements of this ruleset.

This variable has meaning only during a single Able Editor session, and not from session to session!


myXmlFileName

protected transient java.lang.String myXmlFileName
The name of the file containing the XML document of this ruleset.

This variable has meaning only during a single Able Editor session, and not from session to session!


altInputBuffer

protected java.lang.Object altInputBuffer
"altInputBuffer" is initialized to null, but can be used by other objects to provide input data to this bean's process() synchronous method via an AbleEvent with "process" as the action string and an Object[] as the argument Object. This is used by the process(Object) method.

myInferenceContext

protected AbleInferenceContext myInferenceContext
This object holds the current state of the active inference engine This data is maintained by the inference engine and formatted using toString() for display when exceptions occur during inferencing.

myInferenceContextStack

protected java.util.Stack myInferenceContextStack
This object is a stack of AbleInferenceContext objects. Whenever a ruleblock is invoked, a new current context (myInferenceContext) is created and pushed onto the stack. When the ruleblock returns, the stack is popped with the top element becoming the current context.

myGoalVariableName

protected java.lang.String myGoalVariableName
The goal variable is used by backward chaining inference engines only. It is ignored by other inference engines. The variable is initialized to null.

myPredicateQuery

protected AblePredicateQuery myPredicateQuery
The predicate query is used by the predicate inference engine only. It is ignored by other inference engines. The variable is initialized to null.

myDebugLevel

protected int myDebugLevel
The debug level : 0 = off > 0 = on

Note: A user-defined function library (such as AbleDebugLib) must be imported for debugging to work

Constructor Detail

AbleRuleSet

public AbleRuleSet(java.lang.String theName)
            throws AbleException
Create a new ruleset, using the specified trace objects. If no trace objects are specified, that is, null is used, they will be created.
Parameters:
theName - The initial name of this ruleset. The name may change when the ruleset is instantiated from a source language or XML file.


AbleRuleSet

public AbleRuleSet()
            throws AbleException
Method Detail

TokenType

public static final java.lang.String TokenType(int theItem)

checkTimePeriodPreConditions

public final void checkTimePeriodPreConditions(java.util.Calendar theCurrentTime)
                                        throws AbleDataException
Evaluate each rule in every ruleblock against the time period preconditions. If the rule is active and if any of the time periods listed in the preconditions are satisfied, the rule is enabled. *

setParent

public void setParent(AbleBeanContainer theParent)
Set the containing parent of this bean.

super.setParent() is called and then the field "myVarParent" is updated to point to the new parent.

A PropertyChangeEvent is fired.

Overrides:
setParent in class AbleObject
Parameters:
theParent - An ABLE bean container object in which this bean currently resides. Note that a bean may only have one parent at any given time, so this new parent completely replaces the current parent.

See Also:
AbleObject.parent

setInputBuffer

public void setInputBuffer(java.lang.Object theInputBuffer)
                    throws AbleException
Set the input buffer to the specified object.

super.setInputBuffer() is called and then the field "myVarInputBuffer" is updated to point to the new buffer.

No PropertyChangeEvent is fired.

Overrides:
setInputBuffer in class AbleObject
Parameters:
theInputBuffer - Any object, such as a String[], Vector, Hashtable, and so on, that can act as a buffer of input data. A reference to the object is saved; the object is not cloned. Note that once the input buffer is set, it must not be tampered with while an AbleBean is reading data from it.

See Also:
AbleObject.inputBuffer

setOutputBuffer

public void setOutputBuffer(java.lang.Object theOutputBuffer)
                     throws AbleException
Set the output buffer to the specified object.

super.setOutputBuffer() is called and then the field "myVarOutputBuffer" is updated to point to the new buffer.

A PropertyChangeEvent is fired.

Overrides:
setOutputBuffer in class AbleObject
Parameters:
theOutputBuffer - Any object, such as a String[], Vector, Hashtable, and so on, that can act as a buffer of output data. A reference to the object is saved; the object is not cloned. Note that once the output buffer is set, it must not be tampered with while an AbleBean is writing data to it.

See Also:
AbleObject.outputBuffer

addIsExReason

protected void addIsExReason(java.lang.String theIsExReason)
Yeah, it's a weird name, but it's due to historical reasons!

Called by the current inference engine in response to rulesetValid() to explain why the ruleset is not executable.

Parameters:
theIsExReason - A string containing a reason the ruleset cannot be processed.

init

public void init()
          throws AbleException
Initialize and configure the bean. The bean's state changes from AbleState.Uninitiated to AbleState.Initiated.
Overrides:
init in class AbleObject
Following copied from class: com.ibm.able.AbleObject
Throws:
AbleException - If an error occurs.
See Also:
AbleObject.startEnabledEventProcessing()

process

public void process()
             throws AbleException
Perform the standard processing function performed by this object. This typically takes data from the inputBuffer, processes it, and places the results in the output buffer. Specifically:
  1. Determine whether the ruleset is executable. If it is, processing continues.
  2. Determine whether the IO buffers are of the proper type and size. If they are, processing continues.
  3. The ruleset is reset.
  4. An inference engine of the appropriate type is created, if necessary, and its infer() method is called.
  5. When inferencing is complete, dataChanged() is called.

Note that input and output buffers used by this object must be object arrays: Object[].

Overrides:
process in class AbleObject
Throws:
AbleParException - When any error occurs.
See Also:
ioBuffersOK(), reset()

process

public void process(boolean reset)
             throws AbleException

process

public java.lang.Object process(java.lang.Object theArg)
                         throws AbleException
Perform the main, standard processing function performed by this bean, using the argument Object (usually passed via an AbleEvent). Typically, this function involves taking data from the argument object, processing the data, and placing the processed data into an AbleEvent.
Overrides:
process in class AbleObject
Parameters:
theArg - An Object used to initialize the bean. Note: AbleRuleSet only accepts Object[] or Vector as arguments.

Returns:
the results , a clone of the outputBuffer

reset

public void reset()
           throws AbleException
Reset the ruleset so that rules can be fired again. Each variable is reset to its original initial value (if it had one) and all rules are set to their original state. Also, each element in the output buffer (if there is one) is cleared to the empty string "".

Note: This method is called as part of process() logic and does NOT have to be explicitly called between process() invocations.

Overrides:
reset in class AbleObject
Following copied from class: com.ibm.able.AbleObject
Throws:
AbleException - If an error occurs.
See Also:
AbleBean.reset()

processTimerEvent

public void processTimerEvent()
                       throws AbleException
This method is called from the asynch thread when the bean timer is configured to fire. Control is passed to the processTimerEvent() ruleblock (if any is defined).
Overrides:
processTimerEvent in class AbleObject
Following copied from class: com.ibm.able.AbleObject
Throws:
AbleException - If an error occurs.

processAbleEvent

public void processAbleEvent(AbleEvent theAbleEvent)
                      throws AbleException
Process an Able event synchronously; that is, on the same thread as the caller.

This method is called by our AbleEventQueue when the queue gets around to processing an asynchronous event. Note that this method also can be called directly from the handleAbleEvent() method described in the AbleEventListener interface when that method is given a synchronous event to handle.

Our AbleEventQueue "gets around to processing" an event when the following conditions are all true:

In this implementation, "process an Able event" means to obtain from the event itself the name of a method in THIS class and then call that method, passing in any optional arguments, which are also obtained directly from the event. If the invoked method returns an Object, the object is simply ignored, as there is no way to return it to the caller.

Note that the exceptions IllegalAccess, InvocationTarget, NoSuchMethod, and Security are all caught here, so that this method simply returns to the caller with no error indication. If logging is in effect, the exceptions are logged.

Overrides:
processAbleEvent in class AbleObject
Parameters:
theAbleEvent - The event to process.

See Also:
AbleObject.setAbleEventProcessingEnabled(int), AbleObject.startEnabledEventProcessing(), AbleObject.handleAbleEvent(AbleEvent)

quitAll

public void quitAll()
             throws AbleException
Stop all of the bean's asynchronous threads of control.

If the bean is a simple AbleBean, this method just calls its quitEnabledEventProcessing() method; if the bean is an AbleBeanContainer, the bean additionally calls the same method on each contained bean.

Overrides:
quitAll in class AbleObject
See Also:
AbleObject.quitEnabledEventProcessing()

dataChanged

public final void dataChanged()
                       throws AbleException
Signal all registered listeners that this bean's internal state has changed by sending a synchronous event to all registered listeners via the AbleObject.dataChanged(java.lang.Object) with this ruleset as the changed object.

addUserDefinedFunction

public void addUserDefinedFunction(AbleUserDefinedFunction theUserDefinedFunction)
Add a specific user-defined function to the master list of user-defined functions.
Specified by:
addUserDefinedFunction in interface AbleUserDefinedFunctionManager
Parameters:
theUserDefinedFunction - The user-defined function to be added to the master list.

removeUserDefinedFunction

public void removeUserDefinedFunction(java.lang.String theUserDefinedFunctionName,
                                      int theArity)
Remove the named user-defined function from the master list of user-defined functions.
Specified by:
removeUserDefinedFunction in interface AbleUserDefinedFunctionManager
Parameters:
theUserDefinedFunctionName - The name of the user-defined function to be removed from the master list.

theArity - The number of arguments expected by the named function.

containsUserDefinedFunction

public boolean containsUserDefinedFunction(java.lang.String theUserDefinedFunctionName,
                                           int theArity)
Determine whether the master list of user-defined functions contains a user-defined function with the specified name and arity.
Specified by:
containsUserDefinedFunction in interface AbleUserDefinedFunctionManager
Parameters:
theUserDefinedFunctionName - The name of a user-defined function that might be in the master list.

theArity - The number of arguments expected by the named function.

Returns:
true if a user-defined function with the specified name and number of arguments exists in the master list; false otherwise.

getUserDefinedFunction

public AbleUserDefinedFunction getUserDefinedFunction(java.lang.String theUserDefinedFunctionName,
                                                      int theArity)
Retrieve the specified user-defined function
Specified by:
getUserDefinedFunction in interface AbleUserDefinedFunctionManager
Parameters:
theUserDefinedFunctionName - The name of a user-defined function that might be in the master list.

theArity - The number of arguments expected by the named function.

Returns:
The specified user defined function object if found; null otherwise.

invokeUserDefinedFunction

public java.lang.Object invokeUserDefinedFunction(java.lang.String theUserDefinedFunctionName,
                                                  java.lang.Object[] theArgs)
                                           throws AbleException,
                                                  java.lang.NoSuchMethodException,
                                                  java.lang.reflect.InvocationTargetException,
                                                  java.lang.IllegalAccessException,
                                                  java.lang.SecurityException
Call the actual method that the named user-defined function represents, passing in the array of argument objects.
Specified by:
invokeUserDefinedFunction in interface AbleUserDefinedFunctionManager
Parameters:
theUserDefinedFunctionName - The name of the user-defined function containing an encapsulated method.

theArgs - An array of arguments expected by the encapsulated method.

Returns:
The invoked method's return value. This may be null. If the invoked method returns a primitive, the primitive is turned into a corresponding Object; for example, a double becomes a Double.
Throws:
AbleException - on any RMI error.
java.lang.NoSuchMethodException - the method or method signature is not defined in the encapsulated source object.
java.lang.reflect.InvocationTargetException - if an exception was thrown by the invoked method.
java.lang.SecurityException - if the method is not public or otherwise accessible.
java.lang.IllegalAccessException - if the method is not public or otherwise accessible.

setUserDefinedFunctions

public void setUserDefinedFunctions(java.util.Hashtable theUserDefinedFunctions)
Set the complete master list of user-defined functions for this function manager.
Specified by:
setUserDefinedFunctions in interface AbleUserDefinedFunctionManager
Parameters:
theUserDefinedFunctions - A list of AbleUserDefinedFunction objects. This list completely replaces the current list. The input list is cloned.


getUserDefinedFunctions

public java.util.Hashtable getUserDefinedFunctions()
Get the complete master list of user-defined functions registered with this function manager.
Specified by:
getUserDefinedFunctions in interface AbleUserDefinedFunctionManager
Returns:
A copy of the list of all registered UserDefinedFunction objects.

processWithContext

public java.lang.Object processWithContext(java.lang.Object theArg,
                                           java.util.Hashtable theVars,
                                           java.util.Hashtable theFuncs,
                                           AbleWorkingMemory theWm)
                                    throws AbleException
Process this ruleset with variables, user-defined functions (externally attached UDFs only), and working memory from some other ruleset. Note that this is a one way street: this ruleset's current context is lost forever; that is, the ruleset's context is not restored to its previous state when the inference cycle ends.
Parameters:
theArg - An Object used to initialize the bean. Note: AbleRuleSet only accepts Object[] or Vector as arguments.

theVars - A list of variables to merge with the local context.

theFuncs - A list of externally attached user-defined functions to merge with the local context.

theWm - The working memory. May be null.

Returns:
the results , a clone of the outputBuffer
Throws:
AbleParException -  

invokeRuleBlock

public java.lang.Object invokeRuleBlock(java.lang.String theRuleBlockName)
                                 throws AbleException
Process the rules in the specified rule block in a sequential manner.

This method is called from an inference engine when a rule is evaluated that contains a call to this built-in.

Parameters:
theRuleBlockName - The name of the rule block to process.

Throws:
AbleParException - On any processing errors

getCurrentDateAndTime

public java.util.Calendar getCurrentDateAndTime()
A built-in method that can be called from within a ruleset; it returns a Calendar object containing the current date and time of day.
Returns:
The current date and time of day.

getCurrentDateAndTime

public java.util.Calendar getCurrentDateAndTime(java.lang.String theTimeZoneId,
                                                java.lang.String theLanguage,
                                                java.lang.String theCountry)
A built-in method that can be called from within a ruleset; it returns a Calendar object containing the current date and time of day, based on a Locale determined from the input parameters.
Parameters:
theTimeZoneId - A timezone ID string comprised of a country name and a city; for example, "America/Los_Angeles".

theLanguage - A string representing a valid ISO Language Code. These codes are the lower-case two-letter codes as defined by ISO-639. You can find a full list of these codes at a number of sites, such as: http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt

theCountry - A string representing a valid ISO Country Code. These codes are the upper-case two-letter codes as defined by ISO-3166. You can find a full list of these codes at a number of sites, such as: http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html

Returns:
The current date and time of day.

instantiateFrom

public void instantiateFrom(java.io.DataInputStream theStream,
                            AbleLogger theTracer,
                            boolean theStopOnAbleExceptionFlag)
                     throws AbleParException,
                            antlr.RecognitionException,
                            antlr.TokenStreamException,
                            java.io.IOException
Deprecated. As of version 1.4.2, use parseFromArl(DataInputStream)

Instantiate the ruleset object by reading an ARL rule source file contained in the specified input stream. If no exceptions are thrown during this process, the ruleset is ready for processing when this method returns.

Note that if the ruleset contains any variables and rules from a previous instantiation, these are removed from the ruleset before the source file is read. That is, the ruleset is cleared, and made to look like a newly created ruleset.

Parameters:
theStream - The source from which a rule file is read.

theTracer - A trace object, used by the parser to record information during the parsing process.

theStopOnAbleExceptionFlag - Indicates whether the parser is to stop immediately when the first parsing error occurs, or if the parser is to attempt to continue parsing the source file. Specify true if parsing is to stop when an error occurs; false otherwise.

Throws:
AbleParException - On any error.
antlr.ParserException - If the rule file cannot be parsed successfully.
java.io.IOException - If an error occurs while reading the source rule file.

instantiateFrom

public void instantiateFrom(java.lang.String theFileName,
                            AbleLogger theTracer,
                            boolean theStopOnAbleExceptionFlag)
                     throws AbleParException,
                            antlr.RecognitionException,
                            antlr.TokenStreamException,
                            java.io.FileNotFoundException,
                            java.io.IOException
Deprecated. As of version 1.4.2, use parseFromArl(String theFileName)

Instantiate the ruleset object by reading a rule source file contained in the specified input file. If no exceptions are thrown during this process, the ruleset is ready for processing when this method returns.

Note that if the ruleset contains any variables and rules from a previous instantiation, these are removed from the ruleset before the source file is read. That is, the ruleset is cleared, and made to look like a newly created ruleset.

Parameters:
theFileName - The source from which a rule file is read.

theTracer - A trace object, used by the parser to record information during the parsing process.

theStopOnAbleExceptionFlag - Indicates whether the parser is to stop immediately when the first parsing error occurs, or if the parser is to attempt to continue parsing the source file. Specify true if parsing is to stop when an error occurs; false otherwise.

Throws:
AbleParException - On any error.
antlr.ParserException - If the rule file cannot be parsed successfully.
java.io.FileNotFoundException - If the specified input file cannot be found.
java.io.IOException - If an error occurs while reading the source rule file.

instantiateFromXml

public void instantiateFromXml(java.io.InputStream theInputStream,
                               AbleLogger theTracer,
                               boolean theStopOnAbleExceptionFlag)
                        throws java.lang.IllegalAccessException,
                               java.lang.InstantiationException,
                               java.lang.ClassNotFoundException,
                               AbleParException,
                               java.io.IOException
Deprecated. As of version 1.4.2, use parseFromXml(InputStream theInputStream)

Instantiate the ruleset object by reading an XML rule document contained in the specified input stream. If no exceptions are thrown during this process, the ruleset is ready for processing when this method returns.

Note that if the ruleset contains any variables and rules from a previous instantiation, these are removed from the ruleset before the source file is read. That is, the ruleset is cleared, and made to look like a newly created ruleset.

Parameters:
theStream - The source from which an XML rule document is read.

theTracer - A trace object, used by the parser to record information during the parsing process.

theStopOnAbleExceptionFlag - Indicates whether the parser is to stop immediately when the first parsing error occurs, or if the parser is to attempt to continue parsing the source file. Specify true if parsing is to stop when an error occurs; false otherwise.

Throws:
AbleParException - On any XML parser error.
java.io.IOException - If an error occurs while reading the XML document.

instantiateFromXml

public void instantiateFromXml(java.lang.String theFileName,
                               AbleLogger theTracer,
                               boolean theStopOnAbleExceptionFlag)
                        throws java.lang.IllegalAccessException,
                               java.lang.InstantiationException,
                               java.lang.ClassNotFoundException,
                               AbleParException,
                               java.io.FileNotFoundException,
                               java.io.IOException
Deprecated. As of version 1.4.2, use parseFromXml(String theFileName)

Instantiate the ruleset object by reading an XML rule document contained in the specified input file. If no exceptions are thrown during this process, the ruleset is ready for processing when this method returns.

Note that the ruleset is cleared of all objects before parsing.

Parameters:
theFileName - The source from which a rule file is read.

theTracer - A trace object, used by the parser to record information during the parsing process.

theStopOnAbleExceptionFlag - Indicates whether the parser is to stop immediately when the first parsing error occurs, or if the parser is to attempt to continue parsing the source file. Specify true if parsing is to stop when an error occurs; false otherwise.

Throws:
AbleParException - On any parser error.
java.io.FileNotFoundException - If the specified input file cannot be found.
java.io.IOException - If an error occurs while reading the XML document file.

instantiateFromXml

public void instantiateFromXml(java.lang.String theFileName)
                        throws java.lang.IllegalAccessException,
                               java.lang.InstantiationException,
                               java.lang.ClassNotFoundException,
                               AbleParException,
                               java.io.FileNotFoundException,
                               java.io.IOException
Deprecated. As of version 1.4.2, use parseFromXrl(String theFileName)

Instantiate the ruleset object by reading an XML rule document contained in the specified input file. If no exceptions are thrown during this process, the ruleset is ready for processing when this method returns.

Note that the ruleset is cleared of all objects before parsing.

Parameters:
theFileName - The source from which a rule file is read.

Throws:
AbleParException - On any parser error.
java.io.FileNotFoundException - If the specified input file cannot be found.
java.io.IOException - If an error occurs while reading the XML document file.

instantiateFromXml

public void instantiateFromXml(java.io.File theFile,
                               AbleLogger theTracer,
                               boolean theStopOnAbleExceptionFlag)
                        throws java.lang.IllegalAccessException,
                               java.lang.InstantiationException,
                               java.lang.ClassNotFoundException,
                               AbleParException,
                               java.io.FileNotFoundException,
                               java.io.IOException
Deprecated. As of version 1.4.2, use parseFromXrl(File theFile)

Instantiate the ruleset object by reading an XML rule document contained in the specified input file. If no exceptions are thrown during this process, the ruleset is ready for processing when this method returns.

Note that if the ruleset contains any variables and rules from a previous instantiation, these are removed from the ruleset before the source file is read. That is, the ruleset is cleared, and made to look like a newly created ruleset.

Parameters:
theFile - The source from which an XML rule document is read.

theTracer - A trace object, used by the parser to record information during the parsing process.

theStopOnAbleExceptionFlag - Indicates whether the parser is to stop immediately when the first parsing error occurs, or if the parser is to attempt to continue parsing the source file. Specify true if parsing is to stop when an error occurs; false otherwise.

Throws:
AbleParException - On any XML parser error.
java.io.FileNotFoundException - If the specified input file cannot be found.
java.io.IOException - If an error occurs while reading the XML document file.

parseFromARL

public void parseFromARL(java.io.InputStream theStream)
                  throws AbleParException
Parse the ruleset by reading an ARL rule source file contained in the specified input stream. If no exceptions are thrown during this process, the ruleset is ready for processing when this method returns.

Note that the ruleset is cleared of all objects before parsing.

Parameters:
theStream - The source from which a rule file is read.

Throws:
AbleParException - On any error.

parseFromARL

public void parseFromARL(java.lang.String theFileName)
                  throws AbleParException
Instantiate the ruleset object by reading a rule source file contained in the specified input file. If no exceptions are thrown during this process, the ruleset is ready for processing when this method returns.

Note that the ruleset is cleared of all objects before parsing.

Parameters:
theFileName - The source from which a rule file is read.

Throws:
AbleParException - On any error.

parseFromARL

public void parseFromARL(java.io.File theFile)
                  throws AbleParException
Parse the ruleset object by reading a rule source file contained in the specified input file. If no exceptions are thrown during this process, the ruleset is ready for processing when this method returns.
Parameters:
theFileName - The source from which a rule file is read.

Throws:
AbleParException - On any error.

parseRuleSetFromARL

public AbleRuleSet parseRuleSetFromARL(java.lang.String theArlSource)
                                throws AbleParException
Parse and instantiate a complete ruleset object by reading an input String containing ABLE Rule Language text source. If no exceptions are thrown during this process, the ruleset is returned. The init() method must be called before the ruleset can process data.

Note that the entire ruleset is compiled for the source string, so data types, variables, ruleblocks and rules which are referenced in the arlSource must be defined and accessible from the CLASSPATH.

Parameters:
theArlSource - The source from which a ruleset is compiled.

Returns:
The newly instantiated AbleRuleSet object
Throws:
AbleParException - On any error.

parseRuleBlockFromARL

public AbleRuleBlock parseRuleBlockFromARL(java.lang.String theArlSource)
                                    throws AbleParException
Parse and instantiate a complete ruleblock object by reading an input String containing ABLE Rule Language text source. If no exceptions are thrown during this process, the ruleblock is added to this ruleset object. The init() method must be called before the ruleset can process data.

Parameters:
theArlSource - The source from which a ruleblock is compiled and added to this ruleset object.

Returns:
The newly instantate AbleRuleBlock object
Throws:
AbleParException - On any error.

parseConsultRuleBlockFromARL

public AbleRuleBlock parseConsultRuleBlockFromARL(java.lang.String theArlSource)
                                           throws AbleParException
Parse and instantiate a predicate consult() ruleblock object by reading an input String containing ABLE Rule Language text source. If no exceptions are thrown during this process, the ruleblock is added to this ruleset object. The init() method must be called before the ruleset can process data.

Parameters:
theArlSource - The source from which a predicate consult() ruleblock is compiled and added to this ruleset object.

Returns:
The newly instantated AbleRuleBlock object
Throws:
AbleParException - On any error.

parseRuleFromARL

public AbleRule parseRuleFromARL(java.lang.String theArlSource,
                                 java.lang.String theRuleBlockName,
                                 boolean theReplacementMode)
                          throws AbleParException
Parse and instantiate a complete rule object by reading an input String containing ABLE Rule Language text source. If no exceptions are thrown during this process, the rule is added to the specified ruleblock in this ruleset object. The init() method must be called before the ruleset can process data.

Parameters:
theArlSource - The source from which a rule is compiled and added to this ruleset object.

theRuleBlockName - The name of the ruleblock to which this rule will be added.

theReplacementMode - A boolean true value if the rule is to replace an existing rule or false if it is to be added as a new rule to the ruleset.
Returns:
The newly instantiated AbleRule object
Throws:
AbleParException - On any error.

parseExpressionFromARL

public AbleRd parseExpressionFromARL(java.lang.String theArlSource)
                              throws AbleException
Parse and instantiate an AbleRd object (a Literal, Variable, or Expression) by reading an input String containing ABLE Rule Language text source. If no exceptions are thrown during this process, the instantiated object is returned by this method. It is NOT added to any structure in this ruleset object.

This method is intended to be used to construct pieces of AbleRules, and is the preferred way of doing this.

Specified by:
parseExpressionFromARL in interface AbleDataContext
Parameters:
theArlSource - The source from which a ruleblock is compiled and added to this ruleset object.

Returns:
the newly instantiated AbleRd object (a Literal, Variable, or Expression)
Throws:
AbleParException - On any error.

parseFromXML

public void parseFromXML(java.io.InputStream theInputStream)
                  throws AbleParException
Instantiate the ruleset object by reading an XML rule document contained in the specified input stream. If no exceptions are thrown during this process, the ruleset is ready for processing when this method returns.

Note that the ruleset is cleared of all objects before parsing.

Parameters:
theStream - The source from which an XML rule document is read.

Throws:
AbleParException - On any XML parser error.

parseFromXML

public void parseFromXML(java.io.File theFile)
                  throws AbleParException
Parse the ruleset by reading an XML rule document contained in the specified input file. If no exceptions are thrown during this process, the ruleset is ready for processing when this method returns.

Note that the ruleset is cleared of all objects before parsing.

Parameters:
theFile - The source from which an XML rule document is read.

Throws:
AbleParException - On any XML parser error.

parseFromXML

public void parseFromXML(java.lang.String theFileName)
                  throws AbleParException
Parse the ruleset by reading an XML rule source file contained in the specified input file. If no exceptions are thrown during this process, the ruleset is ready for processing when this method returns.

Note that the ruleset is cleared of all objects before parsing.

Parameters:
theFileName - The source from which an XML rule file is read.

Throws:
AbleParException - On any error.

parseRuleSetFromXML

public AbleRuleSet parseRuleSetFromXML(java.lang.String theArmlSource)
                                throws AbleParException
Parse and instantiate a complete ruleset object by reading an input String containing ABLE Rule Language XML source string. If no exceptions are thrown during this process, the ruleset is returned. The init() method must be called before the ruleset can process data.

Note that the entire ruleset is compiled for the source string, so data types, variables, ruleblocks and rules which are referenced in the arlSource must be defined and accessible from the CLASSPATH.

Parameters:
theArlSource - The String from which a ruleset is compiled.

Returns:
The newly instantiated AbleRuleSet object
Throws:
AbleParException - On any error.

parseRuleBlockFromXML

public AbleRuleBlock parseRuleBlockFromXML(java.lang.String theArmlSource)
                                    throws AbleParException
Parse and instantiate a complete ruleblock object by reading an input String containing ABLE Rule Language XML source. If no exceptions are thrown during this process, the ruleblock is added to this ruleset object. The init() method must be called before the ruleset can process data.

Note that the ruleblock is compiled using this ruleset object as the context, so all data types, variables, ruleblocks and rules which are referenced in the arlSource must have been already added to this ruleset.

Parameters:
theArmlSource - The XML source from which a ruleblock is compiled and added to this ruleset object. See AbleRuleSet.xsd schema for format details.

Returns:
The newly instantate AbleRuleBlock object
Throws:
AbleParException - On any XML parser

parseRuleFromXML

public AbleRule parseRuleFromXML(java.lang.String theArmlSource,
                                 java.lang.String theRuleBlockName,
                                 boolean theReplacementMode)
                          throws AbleParException
Parse and instantiate a complete rule object by reading an input String containing ABLE Rule Language XML source. If no exceptions are thrown during this process, the rule is added to the specified ruleblock in this ruleset object. The init() method must be called before the ruleset can process data.

Note that the rule is compiled using this ruleset object and the specfied ruleblock as the context, so all data types, variables, ruleblocks and rules which are referenced in the arlSource must have been already added to this ruleset.

Parameters:
theArmlSource - The XML source from which a rule is compiled and added to this ruleset object. See AbleRuleSet.xsd schema for format details.

theRuleBlockName - The name of the ruleblock to which this rule will be added.

theReplacementMode - A boolean true value if the rule is to replace an existing rule or false if it is to be added as a new rule to the ruleset.
Returns:
The newly instantiated AbleRule object
Throws:
AbleParException - On any XML parser error.

parseExpressionFromXML

public AbleRd parseExpressionFromXML(java.lang.String theArmlSource)
                              throws AbleParException
Parse and instantiate an AbleRd object (a Literal, Variable, or Expression) by reading an input String containing ABLE Rule Language XML source. If no exceptions are thrown during this process, the instantiated object is returned by this method. It is NOT added to any structure in this ruleset object.

This method is intended to be used to construct pieces of AbleRules, and is the preferred way of doing this.

Note that the AbleRd object is compiled using this ruleset object as the context, so all data types, variables, ruleblocks and rules which are referenced in the arlSource must have been already added to this ruleset.

Parameters:
theArmlSource - The XML source from which a ruleblock is compiled and added to this ruleset object. See AbleRuleSet.xsd schema for format details.

Returns:
the newly instantiated AbleRd object (a Literal, Variable, or Expression)
Throws:
AbleParException - On any XML parser error.

saveAsXml

public void saveAsXml(java.lang.String theFileName)
               throws AbleException
Save (write) an AbleRuleSet out as an XML rule file.

Usage: result = saveAsXml("d:\\joe\\myRuleSet.arml");

Parameters:
theFileName - A string representing a path to a destination Able Rule Language XML file.


saveAsArl

public void saveAsArl(java.lang.String theFileName)
               throws java.io.IOException,
                      AbleException
Save (write) an AbleRuleSet out as an ARL text rule file.

Usage: result = saveAsArl("d:\\joe\\myRuleSet.arml");

Parameters:
theFileName - A string representing a path to a destination Able Rule Language text file.


throwException

public void throwException(java.lang.Exception theException)
                    throws java.lang.Exception
Throw an exception from a rule.
Parameters:
theException - The Exception object we want to throw


setRuleSetName

public void setRuleSetName(java.lang.String theRuleSetName)
                    throws AbleParException
Specify the name of the ruleset.
Parameters:
theRuleSetName - The new name of the ruleset.

Throws:
AbleParException - If the name is null or an empty string.
See Also:
getRuleSetName()

getRuleSetName

public final java.lang.String getRuleSetName()
Retrieve the name of the ruleset.
Returns:
The current name of the ruleset.
See Also:
setRuleSetName(java.lang.String)

setInferenceEngine

public void setInferenceEngine(java.lang.String theInferenceEngine)
                        throws AbleParException
Set the inference engine to the specified type.
Parameters:
theInferenceEngine - The new inference engine. Must match a declared engine type

Throws:
AbleParException - If the specified inference engine is not recognised.
See Also:
getInferenceEngine()

addVariable

public void addVariable(AbleVariable theVariable)
                 throws AbleParException
Add a variable to the ruleset.

Note: There are side effects on the specified variable:

Parameters:
theVariable - The variable to add.

Throws:
AbleParException - If a variable with the specified name already exists.

getVariable

public AbleVariable getVariable(java.lang.String theVariableName)
Retrieve a reference to a variable declared in the ruleset.

Local variables are checked first, then global variables.

Parameters:
theVariableName - The name of the variable to retrieve.

Returns:
A reference to the named variable or null if the variable does not exist.

resetVariable

public void resetVariable(java.lang.String theVariableName)
                   throws AbleDataException
Reset a global variable to its initial value (as declared in the variables section). If any initial value is specified (even a null value) then the variable is considered to be bound (i.e. isBound() will return true). If no initial value is specified then the variable is considered to be unbound. This method also clears the associated bit in the factbase BitSet for this variable.
Parameters:
theVariableName - The name of the global variable to reset.
Throws:
An - exception that occurs during the variable reset.

resetVariables

public void resetVariables(java.lang.Object[] theVariableNames)
                    throws AbleDataException
Reset a list of global variables to their initial value (as declared in the variables section). If any initial value is specified (even a null value) then the variable is considered to be bound (i.e. isBound() will return true). If no initial value is specified then the variable is considered to be unbound.
Parameters:
theVariableNames - The list of global variables to be reset.
Throws:
An - exception that occurs during the variable reset.

getVariables

public java.util.Hashtable getVariables()
                                 throws AbleDataException
Get variables.
Returns:
A cloned list of all declared variables.

getFuzzyVariables

public java.util.Vector getFuzzyVariables()
                                   throws AbleDataException
Get fuzzy variables.
Returns:
A cloned list of all declared fuzzy variables.

getCorrelationMethod

public final int getCorrelationMethod()
Retrieve the current correlation method.
Specified by:
getCorrelationMethod in interface AbleDataContext
Returns:
The current correlation method.

getDefuzzifyMethod

public final int getDefuzzifyMethod()
Retrieve the current defuzzification method.
Specified by:
getDefuzzifyMethod in interface AbleDataContext
Returns:
The current defuzzification method.

getFuzzyInferenceMethod

public final int getFuzzyInferenceMethod()
Retrieve the current fuzzy inference method.
Specified by:
getFuzzyInferenceMethod in interface AbleDataContext
Returns:
The current fuzzy inference method.

getVariables

public java.util.Vector getVariables(java.util.BitSet theIds)
                              throws AbleDataException
Get a list of variables based on a BitSet.
Returns:
A list of all variables referenced in the BitSet.

getTemplateVariables

protected java.util.Vector getTemplateVariables(java.util.BitSet theIds)
                                         throws AbleDataException
Get a list of template variables based on a BitSet.
Returns:
A list of all template variables referenced in the BitSet.

getTemplateVariables

public java.util.Vector getTemplateVariables()
                                      throws AbleDataException
Return a list of all template vars referenced by this ruleset.

isLocalOrGlobalVariableName

public boolean isLocalOrGlobalVariableName(java.lang.String theVariableName)
Determine whether a variable (either local or global) with the specified name exists in the ruleset.

The local name space is checked first, then the global name space.

Parameters:
theVariableName - The name of a variable that might exist.

Returns:
true if a variable with the specified name exists in the ruleset; false otherwise.

isGlobalVariableName

public boolean isGlobalVariableName(java.lang.String theVariableName)
Determine whether a global variable with the specified name exists in the ruleset.
Parameters:
theVariableName - The name of a global variabel that might exist.
Returns:
true if a global variable with the specified name exists in the ruleset; false otherwise.

isBuiltInVariableName

public boolean isBuiltInVariableName(java.lang.String theVariableName)
Determine whether a variable with the specified name is a "built-in" variable.
Parameters:
theVariableName - The name of a variable that might be built-in.

Returns:
true if a variable with the specified name is built-in; false otherwise.

declareGlobalVariable

public AbleVariable declareGlobalVariable(java.lang.String theVariableName,
                                          boolean theVariableStaticFlag,
                                          java.lang.String theVariableType)
                                   throws AbleParException
Declare a global variable by creating an instance and adding it to the ruleset. Verify that the variable name is unused and that we know how to make an instance of the class represented by the specified data type (either user-defined via an import or a built-in type.
Parameters:
theVariableName - The name of the new global variable (must be unique in ruleset)
theVariableStaticFlag - A boolean value, true if this variable is static, false if not static
theVariableType - The data type of the variable. Could be one of the ARL built-in types or the name of an imported class (user-defined type).
Returns:
An instance of a variable of the specified data type.
Throws:
AbleParException - If the variable name is already used, or the data type is invalid

clearLocalVarList

protected void clearLocalVarList()

findOrCreateLocalPredicateVariable

protected AbleVariable findOrCreateLocalPredicateVariable(java.lang.String theVariableName)

addLocalVariable

public AbleVariable addLocalVariable(java.lang.String theVariableName,
                                     java.lang.String theVariableType)
                              throws AbleParException
Create and add a local variable to the ruleset
Parameters:
theVariableName - The unique name for this local variable
theVariableType - The data type for the local variable
Returns:
the new local AbleVariable object

addLocalOrGlobalVariable

protected AbleVariable addLocalOrGlobalVariable(java.lang.String theVariableName,
                                                java.lang.String theVariableType)
                                         throws AbleParException

addVariableToInputSequence

public void addVariableToInputSequence(java.lang.String theVariableName)
                                throws AbleParException
Specify that a variable is to be added to the input sequence.

Variables that are in the input sequence have their values taken from an input buffer before inferencing begins. Explicitly, all assertions are fired, variables appearing in the input sequence are assigned values from the user's supplied input buffer, and then all conditional rules are fired. In this way, data supplied at runtime always takes precedence over data "hardcoded" in a ruleset.

Note that a variable may appear in the input sequence more than once, but because the input buffer (where the values come from) is a Hashtable, this has no significance. It simply means that a variable's value is loaded more than once.

Parameters:
theVariableName - The name of a variable whose value is to be taken from the input buffer before inferencing begins.

Throws:
AbleParException - If a variable with the specified name doesn't exist.
See Also:
process()

getNumInputVars

public int getNumInputVars()
Retrieve the number of input variables.
Returns:
The number of variables to be read from the input buffer.

addVariableToOutputSequence

public void addVariableToOutputSequence(java.lang.String theVariableName)
                                 throws AbleParException
Specify that a variable is to be added to the output sequence.

Variables that are in the output sequence have their values written to an output buffer after inferencing ends.

Note that a variable may appear in the output sequence more than once, but because the output buffer (to where the values are written) is a Hashtable, this has no significance. It simply means that a variable's value is written more than once to the same key.

Parameters:
theVariableName - The name of a variable whose value is to be written to the output buffer after inferencing ends.

Throws:
AbleParException - If a variable with the specified name doesn't exist.
See Also:
process()

getNumOutputVars

public int getNumOutputVars()
Retrieve the number of output variables.
Returns:
The number of variables to be written to the output buffer.

getOutputVars

public final java.util.Vector getOutputVars()
Retrieve the output variables.
Returns:
A list of variables.

getInitialFactBase

public java.util.BitSet getInitialFactBase()
Retrieve the initial fact base.
Specified by:
getInitialFactBase in interface AbleDataContext
Returns:
The set of bound variables at the start of inferencing. Used by Fuzzy engine. A clone is returned.

getCurrentFactBase

public java.util.BitSet getCurrentFactBase()
Retrieve the current fact base.
Specified by:
getCurrentFactBase in interface AbleDataContext
Returns:
The set of bound variables during the course of inferencing. Used bu Fuzzy engine. A clone is returned.

setCurrentFactBase

public void setCurrentFactBase(java.util.BitSet theFactBase)
Set the current fact base, the set of bound variables during the course of inferencing. Used by Fuzzy engine.
Specified by:
setCurrentFactBase in interface AbleDataContext

updateCurrentFactBase

public void updateCurrentFactBase(int theVarId)
Update the current fact base by setting the bit representing a newly bound variable. Used by Fuzzy engine.
Specified by:
updateCurrentFactBase in interface AbleDataContext

setWorkingMemory

public void setWorkingMemory(AbleWorkingMemory theWorkingMemory)
Set the current workingMemory object to the specified value.
Parameters:
theWorkingMemory - The new working memory.


getWorkingMemory

public final AbleWorkingMemory getWorkingMemory()
Retrieve the current workingMemory object (may be null).
Returns:
The current working memory, or null if no working memory exists.

getWorkingMemory

public final AbleWorkingMemory getWorkingMemory(java.lang.String theRuleBlockName)
Retrieve the workingMemory object associated with the specified rule block.
Parameters:
theRuleBlockName - The name of the specified rule block.
Returns:
The working memory used by the rule block, or null if no working memory exists or the rule block could not be found.

declareUserDefinedFunction

public void declareUserDefinedFunction(java.lang.String theUserDefinedFunctionName)
                                throws AbleParException
Declare a user-defined function that must be available at runtime.
Parameters:
theUserDefinedFunctionName - The name of a user-defined function that will be available at runtime. The name must contain a slash followed by the arity of the function. For example, "foo/0" or "bar/3".


getDeclaredUserDefinedFunctions

public java.util.Hashtable getDeclaredUserDefinedFunctions()
                                                    throws AbleException
Get all declared user-defined functions.
Returns:
A cloned list of all parser-declared user-defined functions.

isDeclaredUserDefinedFunctionName

protected boolean isDeclaredUserDefinedFunctionName(java.lang.String theNameAndArity)
Determine whether a user-defined function with the specified name has already been declared as an externally added user-defined function to this ruleset.
Parameters:
theNameAndArity - The name of a user-defined function that might have been declared to this ruleset. The name must contain a slash followed by the arity of the function. For example, "foo/0" or "bar/3".

Returns:
true if a user-defined function with the specified name has been declared to the ruleset; false otherwise.

declareUserDefinedFunctionLib

public void declareUserDefinedFunctionLib(java.lang.String theUDFLibName)
                                   throws AbleParException
Declare a user-defined function library that must be available at runtime. Each accessible method in the library is made available as a user-defined function that can be called from within a rule.
Parameters:
theUDFLibName - The name of a user-defined function library that must be available at runtime. The name must be a fully qualified Java package name.


declareUserDefinedFunctionLib

public void declareUserDefinedFunctionLib(java.lang.String theUDFLibName,
                                          java.lang.Class theUDFLibClass)
                                   throws AbleParException
Declare a user-defined function library that must be available at runtime. Each accessible method in the library is made available as a user-defined function that can be called from within a rule.
Parameters:
theUDFLibName - The name of a user-defined function library that must be available at runtime. The name must be a fully qualified Java package name.

theUDFLibClass - The Class of a user-defined function library that must be available at runtime.


isDeclaredUserDefinedFunctionLibName

protected boolean isDeclaredUserDefinedFunctionLibName(java.lang.String theImportLibName)
Determine whether a user-defined function library with the specified name exists within the ruleset.
Parameters:
theImportLibName - The name of a user-defined function library that might exist.

Returns:
true if a user-defined function library with the specified name exists in the ruleset; false otherwise.

isImportedUserDefinedFunction

public boolean isImportedUserDefinedFunction(java.lang.String theImportName)
Determine whether an imported user-defined function with the specified name exists within the ruleset.
Parameters:
theImportName - The name of a user-defined function that might have been imported. The name must contain a slash followed by the arity of the function. For example, "foo/0" or "bar/3".

Returns:
true if an imported user-defined function with the specified name exists in the ruleset; false otherwise.

getImportedUserDefinedFunctions

public java.util.Hashtable getImportedUserDefinedFunctions()
Retrieve the set of active (imported) user-defined functions.
Returns:
The list of imported user-defined functions.

isBuiltInFunction

protected boolean isBuiltInFunction(java.lang.String theName)

declareUserDataType

public void declareUserDataType(java.lang.String theUserTypeName,
                                java.lang.String theUserTypeClass)
                         throws AbleParException
Declare a user-defined data type.
Parameters:
theUserTypeName - The name of a user-defined data type. The name can be used to declare variables of this type.

theUserTypeClass - The fully qualified class name to which the data type is to be equated.


isBuiltInDataType

protected boolean isBuiltInDataType(java.lang.String theDataTypeName)
Determine whether a data type is a built-in type.
Parameters:
theDataTypeName - The name of a data type that might exist.

Returns:
true if the data type with the specified name exists in our list of built-ins ; false otherwise.

isDeclaredDataType

protected boolean isDeclaredDataType(java.lang.String theUserTypeName)
Determine whether an imported (user-defined) data type has already been declared within this ruleset.
Parameters:
theUserTypeName - The name of an imported (user-defined) data type that might exist.

Returns:
true if an imported (user-defined) data type with the specified name exists in the ruleset; false otherwise.

getUserDefinedDataTypes

public java.util.Hashtable getUserDefinedDataTypes()
Retrieve the set of user-defined data types.
Returns:
A cloned list of user-defined data types.

declareInnerClass

public void declareInnerClass(java.lang.String theInnerClassName,
                              java.lang.String theComment,
                              java.util.Vector theFieldNames,
                              java.util.Vector theFieldTypes)
                       throws AbleParException
Declare an inner class, as a user-defined data type.
Parameters:
theInnerClassName - The name of a Java class defined in a ruleset which is treated as a user-defined data type. The name can be used to declare variables of this type.

theComment - A javadoc style comment string.

theFieldNames - A Vector of the (String) names of each field in the class.

theFieldTypes - A Vector of the (String) class types of each field in the class.


getInnerClass

public java.lang.Class getInnerClass(java.lang.String theClassName)
Description copied from interface: AbleDataContext
Retrieve an inner class given its name
Specified by:
getInnerClass in interface AbleDataContext

declarePredicate

public void declarePredicate(java.lang.String thePredicateName)
                      throws AbleParException
Declare a predicate.
Parameters:
thePredicateName - The name of the predicate being declared.


predicateNameIsBuiltIn

protected boolean predicateNameIsBuiltIn(java.lang.String thePredicateName)

isDeclaredPredicateName

public boolean isDeclaredPredicateName(java.lang.String thePredicateName)

getDeclaredPredicates

public java.util.Hashtable getDeclaredPredicates()

findOrCreatePredicateSymbol

protected java.lang.String findOrCreatePredicateSymbol(java.lang.String thePredicateSymbol)

getPredicateSymbols

protected java.util.Hashtable getPredicateSymbols()

addRuleBlock

public void addRuleBlock(java.lang.String theRuleBlockName,
                         java.lang.String theReturnType)
                  throws AbleParException
Specify the name of the current rule block under parse.
Parameters:
theRuleBlockName - The name of the current rule block found by the parser.

Throws:
AbleParException - If a rule block with the specified name already exists.

removeRuleBlock

public void removeRuleBlock(java.lang.String theRuleBlockName)
                     throws AbleParException
Remove the ruleblock from the ruleset.
Parameters:
theRuleBlockName - The name of the rule block to remove.


isDeclaredRuleBlockName

public boolean isDeclaredRuleBlockName(java.lang.String theRuleBlockName)
Determine whether a rule block with the specified name exists within the ruleset.
Parameters:
theRuleBlockName - The name of a rule block that might exist.

Returns:
true if a rule block with the specified name exists in the ruleset; false otherwise.

addRule

public void addRule(AbleRuleBlock theRuleBlock,
                    AbleRule theRule)
             throws AbleParException
Add an Able rule to the specified rule block. The rule label must be unique or an empty String. The rule structure is validated based on the rule type. The rule is then added to the specified ruleblock and to this ruleset.

Note: There are side effects on the specified rule:

Parameters:
theRuleBlock - theRuleBlock to which this rule should be added.
theRule - The rule to add.


insertRuleAt

public void insertRuleAt(int theIndex,
                         AbleRuleBlock theRuleBlock,
                         AbleRule theRule)
                  throws AbleParException
Insert an Able rule at the specified position in the rule block. Note, the rule label must be unique or be an empty String. The rule structure is validated based on the rule type. The rule is then added to the specified ruleblock at the desired position, and to this ruleset.

Note: There are side effects on the specified rule:

Parameters:
theIndex - The integer position where this rule should be inserted into the ruleblock.
theRuleBlock - theRuleBlock to which this rule should be added.
theRule - The rule to add.


removeRule

public void removeRule(AbleRule theRule)
                throws AbleParException
Remove an Able rule from the ruleset (and containing rule block). The rule and all references to it are removed from the ruleset.
Parameters:
theRule - The rule to be removed from the ruleset.


replaceRule

public void replaceRule(AbleRule theRule)
                 throws AbleParException
Replace an Able rule (any type) in the ruleset. Note, the rule label of the new rule must match an existing rule in the ruleset. The new rule is validated based on the rule type. The old rule is removed and the new rule is then added to the specified ruleblock and to this ruleset.

Note: There are side effects on the specified rule:

Parameters:
theRuleBlock - theRuleBlock to which this rule should be added.
theRule - The rule to add.


setCurrentRuleBlock

public final AbleRuleBlock setCurrentRuleBlock(java.lang.String theRuleBlockName)
Set the current rule block by name.
Parameters:
theRuleBlockName - The name of the desired rule block.

Returns:
The specified rule block, or null if the rule block does not exist.

getRuleBlock

public final AbleRuleBlock getRuleBlock(java.lang.String theRuleBlockName)
Retrieve a rule block by name.
Parameters:
theRuleBlockName - The name of the desired rule block.

Returns:
The specified rule block, or null if the rule block does not exist.

getRuleBlocks

public final java.util.Hashtable getRuleBlocks()
Retrieve all rule blocks.
Returns:
A Hashtable of all ruleblocks. Used by inference engines to retrieve the rule blocks for validation.

getRule

public final AbleRule getRule(java.lang.String theRuleLabel)
Retrieve a rule by name.
Parameters:
theRuleLabel - The name or label of the desired rule.

Returns:
The specified rule, or null if the rule does not exist.

getRulePriority

public final double getRulePriority(java.lang.String theRuleLabel)
                             throws AbleDataException
Retrieve a rule's priority.
Parameters:
theRuleLabel - The name or label of the desired rule.

Returns:
The priority of the specified rule, or -1.0 if the rule does not exist.

setRulePriority

public final void setRulePriority(java.lang.String theRuleLabel,
                                  double theRulePriority)
Set a rule's priority.
Parameters:
theRuleLabel - The name or label of the desired rule.

The - priority of the specified rule.

returnFromRuleBlock

public final void returnFromRuleBlock(java.lang.Object theReturnValue)
                               throws com.ibm.able.rules.AbleRuleSet.AbleReturnException

getRuleFired

public final boolean getRuleFired(java.lang.String theRuleLabel)
Retrieve a rule's fired state.
Parameters:
theRuleLabel - The name or label of the desired rule.

Returns:
The fired state of the specified rule, or false if the rule does not exist.

getRuleEnabled

public final boolean getRuleEnabled(java.lang.String theRuleLabel)
Retrieve a rule's enabled state.
Parameters:
theRuleLabel - The name or label of the desired rule.

Returns:
The enabled state of the specified rule, or false if the rule does not exist.

setRuleEnabled

public final void setRuleEnabled(java.lang.String theRuleLabel,
                                 boolean theState)
Set a rule's enabled state.
Parameters:
theRuleLabel - The name or label of the desired rule.

theState - The boolean state of the specified rule.


isDeclaredRuleLabel

public boolean isDeclaredRuleLabel(java.lang.String theRuleLabel)
Determine whether any rule in the ruleset contains the specified label.

Note that all rule labels within a ruleset must be unique.

Parameters:
theRuleLabel - Any string that might be a rule label.

Returns:
true if the specified label appears on any rule in the ruleset; false otherwise.

createRdObject

public AbleRd createRdObject(int theRuleTokenType,
                             java.lang.String theRuleToken,
                             java.util.Vector theCallParms,
                             AbleRd theFuzzyVar,
                             java.lang.String theHedges,
                             java.lang.String theFieldOrMethodName,
                             AbleRd theIndexExpr)
                      throws AbleParException
Create an AbleRd object suitable for use in AbleRules. This is the generic method used by the antlr and xml parsers to construct AbleRd objects. API users may want to use the more straightforward create...Literal methods instead.
Parameters:
theRuleTokenType - An AbleRuleSet.<TokenType> constant that indicates the type of token found by the parser.

theRuleToken - This string may be the name of a variable, the name of a user-defined function that will be available at runtime, a boolean literal, a numeric literal, or a simple string literal. The RuleTokenType parameter gives a clue.

theCallParms - A list of arguments (AbleRd objects) to pass to the function call (when tokenType is CallName), method call (when tokenType is VarMthPair), or a new object constructor (when tokenType is NewObject).

theFuzzyVar - The fuzzy variable used when theRuleTokenType is SetName, to look up fuzzy sets for the given variable.

theHedges - A string of single character AbleFuzzySet.Hedge<constant>s. Only used if theRuleTokenType is SetName.

theFieldOrMethodName - The name of a field or method within the named variable. Only used if theRuleTokenType is VarFldPair or VarMthPair.

theIndexExpr - The array index expression object. Only used if theRuleTokenType is VarInxPair.

Returns:
An AbleLiteral object (as an AbleRd object) that can be included in rule clauses.
Throws:
AbleParException - When any error occurs.

createCallLiteral

public AbleRd createCallLiteral(java.lang.String theCallName,
                                java.util.Vector theCallParms)
                         throws AbleParException
Create an AbleCallLiteral (AbleRd) object which represents a function call with arguments.
Parameters:
theCallName - This string must be the name of a user-defined function.

theCallParms - A list of arguments (AbleRd objects) to pass to the user-defined function.

Returns:
An AbleCallLiteral object (as an AbleRd object) that can be included in rule clauses.
Throws:
AbleParException - When any error occurs.

createFuzzySetLiteral

public AbleRd createFuzzySetLiteral(java.lang.String theRuleToken,
                                    AbleRd theFuzzyVar,
                                    java.lang.String theHedges)
                             throws AbleParException
Create an AbleFuzzySet literal (AbleRd) object.
Parameters:
theRuleToken - This string must be the name of a fuzzy set on theLhs fuzzy variable.

theFuzzyVar - An AbleFuzzyVariable object.

theHedges - A string of single character AbleFuzzySet.Hedge<constant>s.

Returns:
An AbleFuzzySet literal object (as an AbleRd object) that can be included in rule clauses.
Throws:
AbleParException - When any error occurs.

createVariableFieldLiteral

public AbleRd createVariableFieldLiteral(java.lang.String theRuleToken,
                                         java.lang.String theFieldName)
                                  throws AbleParException
Create an AbleTypedVariableField object which represents a data member (field) of the object contained by an AbleTypedVariable.
Parameters:
theRuleToken - This string must be the name of a variable.

theFieldName - The name of a field within the named variable.

Returns:
An AbleTypedVariableField object (as an AbleRd object) that can be included in rule clauses.
Throws:
AbleParException - When any error occurs.

createVariableMethodLiteral

public AbleRd createVariableMethodLiteral(java.lang.String theRuleToken,
                                          java.util.Vector theCallParms,
                                          java.lang.String theMethodName)
                                   throws AbleParException
Create an AbleTypedVariableMethodLiteral object, which represents a method call with arguments on an AbleTypedVariable.
Parameters:
theRuleToken - This string must be the name of a typed variable.

theCallParms - A list of arguments (AbleRd objects) to pass to the method.

theMethodName - The name of a field or method within the named variable. Only used if theRuleTokenType is VarFieldPair or VarMethodPair.

Returns:
An AbleTypedVariableMethodLiteral object (as an AbleRd object) that can be included in rule clauses.
Throws:
AbleParException - When any error occurs.

createArrayExpressionLiteral

public AbleRd createArrayExpressionLiteral(java.lang.String theArrayVarName,
                                           AbleRd theIndexExpr)
                                    throws AbleParException
Create an AbleArrayVariableExpression object (AbleRd) which represents an Array variable with an index expression.
Parameters:
theArrayVarName - This string must be the name of an array variable

theIndexExpr - The array index expression (AbleRd) object. This can be an integer literal or an expression which evaluates to an integer.

Returns:
An AbleArrayVariableExpression literal object (as an AbleRd object) that can be included in rule clauses.
Throws:
AbleParException - When any error occurs.

createNewObjectLiteral

public AbleRd createNewObjectLiteral(java.lang.String theDataType,
                                     java.util.Vector theCallParms,
                                     java.lang.String theFieldOrMethodName,
                                     AbleRd theIndexExpr)
                              throws AbleParException
Create an AbleRd object suitable for use on the right-hand side of an AbleClause.
Parameters:
theDataType - This string must be the name of a valid data type, either built-in or imported into the ruleset.

theCallParms - A list of arguments (AbleRd objects) to pass to the constructor.

theFieldOrMethodName - The name of a field or method within the named variable. Only used if theRuleTokenType is VarFieldPair or VarMethodPair.

theIndexExpr - The array index expression object. Only used if the data type is an array.

Returns:
An AbleNewObjectLiteral (as an AbleRd object) that can be included in rule clauses.
Throws:
AbleParException - When any error occurs.

createLiteral

public AbleRd createLiteral(int theRuleTokenType,
                            java.lang.String theRuleToken)
                     throws AbleParException
Create an AbleRd object literal suitable for use in an AbleExpression, and AbleClause or an AbleRule.
Parameters:
theRuleTokenType - An AbleRuleSet.<TokenType> constant that indicates the type of token found by the parser. It must be one of the supported simple literal types.

theRuleToken - This string may be a boolean, char, double, float, integer, long, string, or timestamp literal value. The theRuleTokenType parameter identifies the literal type using one of the AbleRuleSet.TokenTypeIs... constants.

Returns:
An AbleLiteral object (as an AbleRd object) that can be included in rule clauses.
Throws:
AbleParException - When any error occurs.

findOrCreateExpression

protected AbleExpression findOrCreateExpression(AbleRd theLhs,
                                                int theRuleOp,
                                                AbleRd theRhs)
See if the specified expression exists, and if it does, return it. If the expression doesn't already exist, create it, add it to the expression collection, and then return the new expression.
Parameters:
theLhs - The left-hand side of the expression, either an AbleVariable, an AbleLiteral, or another AbleExpression;

theRuleOp - The operator used in the clause. It must be an AbleData.<Operator> constant type.

theRhs - The right-hand side of the expression; either an AbleVariable, an AbleLiteral, or another AbleExpression.

Returns:
An AbleExpression that can be used in a rule.

findOrCreateDoubleLit

protected AbleRd findOrCreateDoubleLit(java.lang.String theRuleToken)
                                throws AbleParException
See if the specified literal exists, and if it does, return it. If the literal doesn't already exist, create it, add it to the literal namespace, and then return the new literal.
Parameters:
theRuleToken - A parsed token (a string) that is used as a literal in some clause. We turn the string into an AbleLiteral object, and we ensure that there is only one of each specific literal.

Returns:
An AbleDoubleLiteral object (as an AbleRd object) that can be included in rule clauses.

findOrCreateFloatLit

protected AbleRd findOrCreateFloatLit(java.lang.String theRuleToken)
                               throws AbleParException
See if the specified literal exists, and if it does, return it. If the literal doesn't already exist, create it, add it to the literal namespace, and then return the new literal.
Parameters:
theRuleToken - A parsed token (a string) that is used as a literal in some clause. We turn the string into an AbleLiteral object, and we ensure that there is only one of each specific literal.

Returns:
An AbleFloatLiteral object (as an AbleRd object) that can be included in rule clauses.

findOrCreateIntegerLit

protected AbleRd findOrCreateIntegerLit(java.lang.String theRuleToken)
                                 throws AbleParException
See if the specified literal exists, and if it does, return it. If the literal doesn't already exist, create it, add it to the literal namespace, and then return the new literal.
Parameters:
theRuleToken - A parsed token (a string) that is used as a literal in some clause. We turn the string into an AbleLiteral object, and we ensure that there is only one of each specific literal.

Returns:
An AbleIntegerLiteral object (as an AbleRd object) that can be included in rule clauses.

findOrCreateLongLit

protected AbleRd findOrCreateLongLit(java.lang.String theRuleToken)
                              throws AbleParException
See if the specified literal exists, and if it does, return it. If the literal doesn't already exist, create it, add it to the literal namespace, and then return the new literal.
Parameters:
theRuleToken - A parsed token (a string) that is used as a literal in some clause. We turn the string into an AbleLiteral object, and we ensure that there is only one of each specific literal.

Returns:
An AbleLongLiteral object (as an AbleRd object) that can be included in rule clauses.

findOrCreateStringLit

protected AbleRd findOrCreateStringLit(java.lang.String theRuleToken)
See if the specified literal exists, and if it does, return it. If the literal doesn't already exist, create it, add it to the literal namespace, and then return the new literal.
Parameters:
theRuleToken - A parsed token (a string) that is used as a literal in some clause. We turn the string into an AbleLiteral object, and we ensure that there is only one of each specific literal.

Returns:
An AbleStringLiteral object (as an AbleRd object) that can be included in rule clauses.

createTimeStampLit

public AbleRd createTimeStampLit(java.lang.String theRuleToken)
Given a string representation of a timestamp (date/time) create a TimeStampLiteral from it
Parameters:
theRuleToken - A parsed token (a string) that is used as a literal in some clause. We turn the string into a new AbleTimeStampLiteral object.

Returns:
An AbleTimeStampLiteral object (as an AbleRd object) that can be included in rule clauses.

findOrCreateAssertion

protected AbleAssertionClause findOrCreateAssertion(AbleLhs theLhs,
                                                    int theRuleOp,
                                                    AbleRd theRhs)
See if the specified clause exists, and if it does, return it. If the clause doesn't already exist, create it, add it to the clause collection, and then return the new clause.
Parameters:
theLhs - The left-hand side of the clause; must be an AbleVariable.

theRuleOp - The operator used in the clause. It must be an AbleData.<Operator> constant of an assignment type.

theRhs - The right-hand side of the clause; either an AbleVariable or an AbleLiteral.

Returns:
An AbleAssertionClause that can be used in a rule.

findOrCreateAntecedent

protected AbleAntecedentClause findOrCreateAntecedent(AbleRd theLhs,
                                                      int theRuleOp,
                                                      AbleRd theRhs,
                                                      double theRuleAntWeight)
See if the specified clause exists, and if it does, return it. If the clause doesn't already exist, create it, add it to the clause collection, and then return the new clause.
Parameters:
theLhs - The left-hand side of the clause; usually an AbleVariable.

theRuleOp - The operator used in the clause. It must be an AbleData.<Operator> constant of a comparison type.

theRhs - The right-hand side of the clause; either an AbleVariable or an AbleLiteral.

Returns:
An AbleAntecedentClause that can be used in a rule.

findOrCreateAntecedent

protected AbleAntecedentClause findOrCreateAntecedent(AbleAntecedentClause theClause)
See if the specified clause already exists, and if it does, return the original. If the clause doesn't already exist, add it to the clause collection, and return the new clause.
Parameters:
theClause - An potential antecedent clause to be added to the ruleset.

Returns:
An AbleAntecedentClause that can be used in a rule.

findOrCreateConsequent

protected AbleConsequentClause findOrCreateConsequent(AbleLhs theLhs,
                                                      int theRuleOp,
                                                      AbleRd theRhs)
See if the specified clause exists, and if it does, return it. If the clause doesn't already exist, create it, add it to the clause collection, and then return the new clause.
Parameters:
theLhs - The left-hand side of the clause; must be an AbleVariable.

theRuleOp - The operator used in the clause. It must be an AbleData.<Operator> constant of an assignment type.

theRhs - The right-hand side of the clause; either an AbleVariable or an AbleLiteral.

Returns:
An AbleConsequentClause that can be used in a rule.

createFuzzySet

public void createFuzzySet(AbleFuzzyVariable theFuzzyVariable,
                           java.lang.String theSetName,
                           java.lang.String theSetType,
                           java.util.Vector theArgs,
                           double theAlphaCut,
                           boolean isComplement)
                    throws AbleParException
Create a FuzzySet of the specified type and add it to a FuzzyVariable.
Parameters:
theFuzzyVariable - An AbleFuzzyVariable object

theSetName - The name of the fuzzy set to create (or base set name, if isComplement is true) .

theSetType - The type of fuzzy set to create. Must be one of "beta", "gaussian", "pi", "linear", "sigmoid", "shoulder", "trapezoid", or "triangle"

theArgs - A list of arguments to pass to the FuzzySet constructor. The number and types must match the constructors for the respective fuzzy set types.

theAlphaCut - The double value to use as the alphaCut parameter for this fuzzy set.

isComplement - A boolean value that is true if the fuzzy set is the complement of an existing fuzzy set, otherwise false.

Throws:
AbleParException - When any error occurs.

setSrcFile

public final void setSrcFile(java.io.File theSrcFile)
Specify the source file object for this ruleset.

This, and the following few methods, are used by the Able RuleSet Editor program. When the editor is told to save the source rules, this method is called so that the source file object may be temporarily saved across editor sessions. Then, when the user selects "customize" from the Able Editor, the rule editor will be able to retrieve the file object and reload the source rule file.

If there is no source rule file, the editor will try to reconstitute the source rules from the existing instantiated ruleset variables.

Note that the variable containing the source file is transient. This is because serialized objects will likely be transferred from system to system with possibly different file systems and file naming conventions. When this happens, it is not likely that the source file will accompany the serialized file, and if it should, it is not likely that the source file would appear within the same directory structure as it did on the originating system!

Parameters:
theSrcFile - The file object containing source rules.


getSrcFile

public final java.io.File getSrcFile()
Retrieve the name of the source file for this ruleset.
Returns:
The name of the file containing source rules.

getARLTree

public AbleARLTreeNode getARLTree()
Retrieve the content outline of this ruleset, produced by the parser

getARLParser

public AbleARLParser getARLParser()
Retrieve the parser used to instantiate the ruleset. May return null.
Returns:
AbleARLParser

setSrcFileName

public void setSrcFileName(java.lang.String theSrcFileName)
Specify the name of the source file for this ruleset.
Parameters:
theSrcFileName - The name of the file containing source rules.


getSrcFileName

public final java.lang.String getSrcFileName()
Retrieve the name of the source file for this ruleset.
Returns:
The name of the file containing source rules.

setSerFileName

public void setSerFileName(java.lang.String theSerFileName)
                    throws AbleException
Specify the name of the serialized file for this ruleset.
Parameters:
theSerFileName - The name of the file containing a serialized able ruleset.


getSerFileName

public final java.lang.String getSerFileName()
Retrieve the name of the serialized file for this ruleset.
Returns:
The name of the file containing a serialized ruleset file.

setXmlFileName

public void setXmlFileName(java.lang.String theXmlFileName)
                    throws AbleException
Specify the name of the XML document file for this ruleset.
Parameters:
theXmlFileName - The name of the file containing an XML ruleset document.


getXmlFileName

public final java.lang.String getXmlFileName()
Retrieve the name of the XML file for this ruleset.
Returns:
The name of the file containing an XML ruleset document.

isExecutable

public boolean isExecutable()
Determine whether the ruleset is executable.

The ruleset is executable if:

  1. The parsser, if used, completed successfully.
  2. Variables have been successfully defined.
  3. User-defined functions referenced in the source rule file are actually available.
  4. Rules with valid clauses have been successfully defined.
Returns:
true if the ruleset seems executable, false otherwise.

ioBuffersOK

protected boolean ioBuffersOK()
                       throws AbleException
Determine whether the input and output buffers are the expected object type (Object[]) and that they have enough slots to hold the required input and output variables.
Returns:
true if the buffers are big enough, false otherwise.

clear

public void clear()
Clear the ruleset of all variables and rules, clear out the trace logs, set the ruleset name to the empty string (""), and set all ruleset options (alphacut, correlation method, and so on) to default values.

processInput

protected void processInput(java.util.BitSet theFactBase)
                     throws AbleDataException
For each variable appearing in the input sequence, extract a value from the input buffer and assign it to the variable.

Note that the input buffer was pre-verified in the process() method when ioBuffersOK() was called.

Parameters:
theFactBase - Keeps track of which variables have known values.

Throws:
AbleDataException - When any error occurs.

processOutput

public final void processOutput()
                         throws AbleDataException
For each variable appearing in the output sequence, obtain the variable's current value and write it to the output buffer.

Note that the output buffer was pre-verified in the process() method when ioBuffersOK() was called.

Throws:
AbleDataException - When any data error occurs.

arlString

public java.lang.String arlString()
Return a formal able rule language (ARL) string with Java-like syntax.
Returns:
A String describing the object in Able rule language.

arlStringHeader

protected java.lang.String arlStringHeader()

arlStringLibraries

protected java.lang.String arlStringLibraries()

arlStringImports

protected java.lang.String arlStringImports()

arlStringDclPredicates

protected java.lang.String arlStringDclPredicates()

arlStringDclInnerClasses

protected java.lang.String arlStringDclInnerClasses()

arlStringVariables

protected java.lang.String arlStringVariables()

arlStringInputVariables

protected java.lang.String arlStringInputVariables()

arlStringOutputVariables

protected java.lang.String arlStringOutputVariables()

arlStringUdfs

protected java.lang.String arlStringUdfs()

arlStringRules

protected java.lang.String arlStringRules()

arlStringTrailer

protected java.lang.String arlStringTrailer()

xmlString

public java.lang.String xmlString()
Retrieve the XML representation of this rule set.
Returns:
A String containing an XML representation of this ruleset.

xmlStringHeader

protected java.lang.String xmlStringHeader()

xmlStringLibraries

protected java.lang.String xmlStringLibraries()

xmlStringImports

protected java.lang.String xmlStringImports()

xmlStringDclPredicates

protected java.lang.String xmlStringDclPredicates()

xmlStringDclInnerClasses

protected java.lang.String xmlStringDclInnerClasses()

xmlStringVariables

protected java.lang.String xmlStringVariables()

xmlStringInputVariables

protected java.lang.String xmlStringInputVariables()

xmlStringOutputVariables

protected java.lang.String xmlStringOutputVariables()

xmlStringUdfs

protected java.lang.String xmlStringUdfs()

xmlStringRules

protected java.lang.String xmlStringRules()

xmlStringTrailer

protected java.lang.String xmlStringTrailer()

setBaseTraceLevel

public void setBaseTraceLevel(long theTraceLevel)
Turn ruleset tracing on or off. When ruleset tracing is on, messages are written to the AbleLogger object indicating when variables and rules are created and updated, or when any ruleset option changes. Messages relating to inferencing or parsing are not logged.
Parameters:
theTraceValue - Use Able.TRC_LOW_RLST, Able.TRC_MEDIUM_RLST, and Able.TRC_HIGH_RLST to turn tracing on, Able.TRC_NONE to turn tracing off.


setBaseTraceHandler

public void setBaseTraceHandler(java.lang.Object handler,
                                long theTraceLevel)
Turn base tracing on or off. When base tracing is on, messages are written to the trace object indicating the activity of base Able Rule Language function.

If there is no handler for base trace messages, a console handler is created.

The base trace handler is started when needed, and stopped and removed from the trace logger when turned off.

Parameters:
theTraceValue - Use Able.TRC_LOW_RLST, Able.TRC_MEDIUM_RLST, and Able.TRC_HIGH_RLST to turn tracing on, Able.TRC_NONE to turn tracing off.


setBaseTraceLevel

public void setBaseTraceLevel(int theTraceLevel)
Turn base tracing on or off from a ruleset or, an application which need not provide its own handler for output. When base tracing is on, messages are written to the trace object indicating the activity of base Able Rule Language function.

If no handler for base trace messages exists, a console handler is created.

The base trace handler is started when needed, and stopped and removed from the trace logger when turned off.

Parameters:
theTraceValue - Use ARL.TRC_LOW, ARL.TRC_MEDIUM, and ARL.TRC_HIGH to turn tracing on, ARL.TRC_NONE to turn tracing off.


getBaseTraceLevel

public final long getBaseTraceLevel()
Return the level for base tracing.
Parameters:
theTraceValue - Use Able.TRC_LOW_RLST, Able.TRC_MEDIUM_RLST, and Able.TRC_HIGH_RLST to turn tracing on, Able.TRC_NONE to turn tracing off.


isBaseTraceLow

public final boolean isBaseTraceLow()
Returns true if low level base trace messages should be sent to tracer.

isBaseTraceMedium

public final boolean isBaseTraceMedium()
Returns true if medium level base trace messages should be sent to tracer.

isBaseTraceHigh

public final boolean isBaseTraceHigh()
Returns true if high level base trace messages should be sent to tracer.

declareEngineType

public final void declareEngineType(java.lang.String theEngineType,
                                    java.lang.String theEngineClassName)
Declare an inference engine type and class name.
Parameters:
theEngineType - the name of the inference engine (from the using clause)

theEngineClassName - the package.classname of the inference engine, must resolve to a subclass of AbleInferenceEngine and be in the CLASSPATH.

getInferenceEngineClassName

public final java.lang.String getInferenceEngineClassName(java.lang.String theEngineType)
Retrieve the inference engine class name from the engines list.
Parameters:
theEngineType - the name of the inference engine (from the using clause)
Returns:
the inference engine class name.

getInferenceEngine

public final AbleInferenceEngine getInferenceEngine()
Retrieve the current inference engine object.
Returns:
the current inference engine object.

getInferenceEngine

public final AbleInferenceEngine getInferenceEngine(java.lang.String theRuleBlockName)
Retrieve the inference engine associated with the specified ruleblock.
Parameters:
theRuleBlockName - The name of the rule block
Returns:
the inference engine in the specified rule block or null if the rule block could not be found.

setControlParameter

public final void setControlParameter(java.lang.String theControlParameter,
                                      java.lang.Object theValue)
                               throws AbleDataException
Set a single control parameter on the current inference engine.

getControlParameter

public final java.lang.Object getControlParameter(java.lang.String theControlParameter)
                                           throws AbleDataException
Returns a single control parameter on the current inference engine.

setControlParameter

public final void setControlParameter(java.lang.String theRuleBlockName,
                                      java.lang.String theControlParameter,
                                      java.lang.Object theValue)
                               throws AbleDataException
Set a single control parameter on the inference engine associated with the specified ruleblock.

getControlParameter

public final java.lang.Object getControlParameter(java.lang.String theRuleBlockName,
                                                  java.lang.String theControlParameter)
                                           throws AbleDataException
Returns a single control parameter on the inference engine associated with the specified ruleblock.

setValueList

public final void setValueList(java.lang.String theVariableName,
                               java.util.Vector theValueList)
                        throws AbleException
Set the value list on a Categorical or Discrete variable
Parameters:
theVariable - A Categorical or Discrete variable name.

theValueList - A Vector of String or Double values.


setVariablePrompt

public final void setVariablePrompt(java.lang.String theVariableName,
                                    java.lang.String thePrompt)
                             throws AbleException
Set the Prompt string on a variable to be used by an associated UI
Parameters:
theVariable - A variable name.

thePrompt - The prompt String to be used when querying a user for a value.


setRulePrompt

public final void setRulePrompt(java.lang.String theRuleName,
                                java.lang.String thePrompt)
                         throws AbleException
Set the Prompt string on a rule to be used by an associated UI
Parameters:
theRuleName - The name of the rule.

thePrompt - The prompt String to be used when querying a user for template values.


getInferTraceLogger

public final AbleLogger getInferTraceLogger()
Description copied from interface: AbleDataContext
Retrieve the inferencing tracer logger.
Specified by:
getInferTraceLogger in interface AbleDataContext
Following copied from interface: com.ibm.able.data.AbleDataContext
Returns:
the inferencing trace logger.

getInferenceContext

public final AbleInferenceContext getInferenceContext()
Return the current inference engine trace context (used for tracing/debugging).

getInferenceContextStack

public final java.util.Stack getInferenceContextStack()
Return the stack of inference engine trace contexts.

getRulesFiredCount

public int getRulesFiredCount(java.lang.String theRuleBlockName)
Returns the number of rules fired by the specified rule block and associated inference engine during the last infer() call on the engine

setInferenceTraceLevel

public void setInferenceTraceLevel(long theTraceLevel)
Turn inference tracing on or off. When inference tracing is on, messages are written to the trace object indicating which rules fired and their results.
Parameters:
theTraceValue - Use Able.TRC_LOW_INFER, Able.TRC_MEDIUM_INFER, and Able.TRC_HIGH_INFER to turn tracing on, Able.TRC_NONE to turn tracing off.


setInferenceTraceHandler

public void setInferenceTraceHandler(java.lang.Object handler,
                                     long theTraceLevel)
Turn inference tracing on or off. When inference tracing is on, messages are written to the trace object indicating the activity of the Able Rule Language inferencing engines.

If there is no handler, a console handler is created.

The handler is started when needed, and stopped and removed from the trace logger when turned off.

Parameters:
theTraceValue - Use Able.TRC_LOW_INFER, Able.TRC_MEDIUM_INFER, and Able.TRC_HIGH_INFER to turn tracing on, Able.TRC_NONE to turn tracing off.


setInferenceTraceLevel

public void setInferenceTraceLevel(int theTraceLevel)
Turn inference tracing on or off from a ruleset or, an application which need not provide its own handler for output. When inference tracing is on, messages are written to the trace object indicating the activity of the Able Rule Language inferencing engines.

If no handler for exists, a console handler is created.

The handler is started when needed, and stopped and removed from the trace logger when turned off.

Parameters:
theTraceValue - Use ARL.TRC_LOW, ARL.TRC_MEDIUM, and ARL.TRC_HIGH to turn tracing on, ARL.TRC_NONE to turn tracing off.


getInferenceTraceLevel

public final long getInferenceTraceLevel()
Return the level for inference tracing.
Parameters:
theTraceValue - Use Able.TRC_LOW_INFER, Able.TRC_MEDIUM_INFER, and Able.TRC_HIGH_INFER to turn tracing on, Able.TRC_NONE to turn tracing off.


isInferenceTraceLow

public final boolean isInferenceTraceLow()
Returns true if low level inference trace messages should be sent to tracer.

isInferenceTraceMedium

public final boolean isInferenceTraceMedium()
Returns true if medium level inference trace messages should be sent to tracer.

isInferenceTraceHigh

public final boolean isInferenceTraceHigh()
Returns true if high level inference trace messages should be sent to tracer.

setParseTraceLevel

public void setParseTraceLevel(long theTraceLevel)
Turn parse tracing on or off. When parse tracing is on, messages are written to the trace object indicating the activity of the Able Rule Language parsers.
Parameters:
theTraceValue - Use Able.TRC_LOW_PARSE, Able.TRC_MEDIUM_PARSE, and Able.TRC_HIGH_PARSE to turn tracing on, Able.TRC_NONE to turn tracing off.


setParseTraceHandler

public void setParseTraceHandler(java.lang.Object handler,
                                 long theTraceLevel)
Turn parse tracing on or off. When parse tracing is on, messages are written to the trace object indicating the activity of the Able Rule Language parsers.
Parameters:
theTraceValue - Use Able.TRC_LOW_PARSE, Able.TRC_MEDIUM_PARSE, and Able.TRC_HIGH_PARSE to turn tracing on, Able.TRC_NONE to turn tracing off.


setParseTraceLevel

public void setParseTraceLevel(int theTraceLevel)
Turn parse tracing on or off. When parse tracing is on, messages are written to the trace object indicating the activity of the Able Rule Language parsers.

If no handler for exists, a console handler is created.

The handler is started when needed, and stopped and removed from the trace logger when turned off.

Parameters:
theTraceValue - Use Able.TRC_LOW_PARSE, Able.TRC_MEDIUM_PARSE, and Able.TRC_HIGH_PARSE to turn tracing on, Able.TRC_NONE to turn tracing off.


getParseTraceLevel

public final long getParseTraceLevel()
Return the level for parse tracing.
Parameters:
theTraceValue - Use Able.TRC_LOW_PARSE, Able.TRC_MEDIUM_PARSE, and Able.TRC_HIGH_PARSE to turn tracing on, Able.TRC_NONE to turn tracing off.


isParseTraceLow

public final boolean isParseTraceLow()
Returns true if low level parse trace messages should be sent to tracer.

isParseTraceMedium

public final boolean isParseTraceMedium()
Returns true if medium level parse trace messages should be sent to tracer.

isParseTraceHigh

public final boolean isParseTraceHigh()
Returns true if high level inference trace messages should be sent to tracer.

addBreakpoint

public void addBreakpoint(AbleRuleBreakpoint theBreakpoint)
Add the breakpoint at the specified location

removeBreakpoint

public void removeBreakpoint(AbleRuleBreakpoint theBreakpoint)
Remove the breakpoint from the specified location

setDebugLevel

public void setDebugLevel(int theDebugLevel)
Set the debug level for the associated inference engine

getDebugLevel

public final int getDebugLevel()
Get the debug level for the associated inference engine

setDebugConsole

public final void setDebugConsole(java.lang.Object theDebugConsole)
Set the debug console on this ruleset
Parameters:
theDebugConsole - A GUI component (JFrame) to display/control debugging. Note that this is specified as an Object rather than a Swing component because we want to remain free of any cross dependencies on SWING/AWT GUI components.

getDebugConsole

public final java.lang.Object getDebugConsole()
Get the debug console (if any) for this ruleset

hasDebugConsole

public boolean hasDebugConsole()
Tests whether this rule set object has an external debug console (GUI)
Returns:
true if a console has been defined

getChgSupport

public final java.beans.PropertyChangeSupport getChgSupport()
Retrieve the PropertyChangeSupport object.
Returns:
the property change support object.

setParserInErrorState

protected final void setParserInErrorState(boolean theParserInErrorState)
Indicate whether any errors occurred during parsing. If errors occurred during parsing, the ruleset is proabaly not executable, so this flag is examined by isExecutable(). If the flag is on, the ruleset cannot be processed until a re-parse is done, or the ruleset is cleared and re-instantiated.
Parameters:
theParserInErrorState - true if an error occurred; false otherwise.

See Also:
isExecutable()

setResourceBundleName

public void setResourceBundleName(java.lang.String theResourceBundleName)
Set the base name of a ResourceBundle (or subclass) to be associated with this ruleset. When set, any prompts on variables will be interpreted to be keys into this message bundle.

getResourceBundleName

public java.lang.String getResourceBundleName()
Retrieve the resource bundle base name for use with this ruleset. Note: this could be null.

getResourceBundle

public java.util.ResourceBundle getResourceBundle()
Retrieve the resource bundle for use with this ruleset. Note: this could be null.
Specified by:
getResourceBundle in interface AbleDataContext

setTemplate

public void setTemplate(boolean theTemplateFlag)
Set the state of the template flag for this ruleset. If true, this ruleset is a template which is meta-data and is not an executable ruleset.

isTemplate

public boolean isTemplate()
Returns true if this ruleset is a template ruleset, false otherwise.

getRuleSetTemplate

public AbleRuleSetTemplate getRuleSetTemplate()
                                       throws AbleDataException
Retrieve a ruleset template object (if defined) else return null

addRuleFromTemplate

public AbleRule addRuleFromTemplate(java.lang.String theTemplateName,
                                    java.lang.Object[] theTemplateVarValues)
                             throws AbleException,
                                    AbleParException
Add a new rule using the template name and associated template variable values
Parameters:
theTemplateName - The name of the rule template
theTemplateVarValues - The list of Strings or AbleRd objects whose values are used to create the new rule
Returns:
The created AbleRule object

replaceRuleFromTemplate

public AbleRule replaceRuleFromTemplate(java.lang.String theTemplateName,
                                        java.lang.Object[] theTemplateVarValues)
                                 throws AbleDataException,
                                        AbleParException
Replace an existing rule (previously generated from a template) using the template name and associated template variable values
Parameters:
theTemplateName - The name of the rule template
theTemplateVarValues - The list of Strings or AbleRd objects whose values are used to create the new rule.
Returns:
The created AbleRule object

addRuleFromTemplate

public AbleRule addRuleFromTemplate(AbleRuleTemplate theTemplate)
                             throws AbleException,
                                    AbleParException
Add a new rule using the template and its bound template variable values
Parameters:
theTemplate - The rule template
Returns:
The created AbleRule object

replaceRuleFromTemplate

public AbleRule replaceRuleFromTemplate(AbleRuleTemplate theTemplate)
                                 throws AbleDataException,
                                        AbleParException
Replace an existing rule (previously generated from a template) using the template and its bound template variable values
Parameters:
theTemplate - The rule template
Returns:
The created AbleRule object

createRuleFromTemplate

protected AbleRule createRuleFromTemplate(AbleRuleTemplate theTemplate,
                                          boolean theReplacementMode)
                                   throws AbleDataException,
                                          AbleParException
Create a new rule (or replace an existing one) using the rule template and its bound template variable values
Parameters:
theTemplate - The rule template object with bound template variables
theReplacementMode - A boolean value, true if this rule is a replacement for an existing rule, false if it is a new rule.
Returns:
The created AbleRule object

getGeneratedRulesFromTemplate

public java.util.Vector getGeneratedRulesFromTemplate(java.lang.String theTemplateName)
                                               throws AbleDataException
Retrieve the list of rules generated from the specified template
Parameters:
theTemplateName - The label of the rule template
Returns:
A Vector of rules generated from this template, or null if none.

getRuleTemplateFromRule

public AbleRuleTemplate getRuleTemplateFromRule(java.lang.String theRuleName)
                                         throws AbleDataException
Retrieve the template from which this rule was generated (if any)
Parameters:
theRuleName - The name of the rule whose template we want to retrieve.
Returns:
The template rule or null if the rule was not generated by a template.

createRuleSetFromTemplate

public AbleRuleSet createRuleSetFromTemplate(AbleRuleSetTemplate theTemplate)
                                      throws AbleDataException,
                                             AbleParException
Create a new ruleset from a template using the template and its bound template variable values
Parameters:
theTemplate - A ruleset template object
Returns:
The created AbleRuleSet object

getRuleTemplates

public java.util.Vector getRuleTemplates()
                                  throws AbleDataException
Retrieve all the rule template objects defined in this ruleset
Returns:
A vector of all defined rule template objects

initRuleTemplates

public void initRuleTemplates()
                       throws AbleDataException
Initialize the rule template in this ruleset and invoke the initRuleTemplates() ruleblock to refresh any info on rules that were already generated in this ruleset.

setRuleTemplateInfo

public void setRuleTemplateInfo(java.lang.String theTemplateName,
                                java.lang.Object[] theTemplateVarValues)
                         throws AbleDataException,
                                AbleParException
Set the rule template info for a previously generated rule. This method allows editing of the generated rule using template APIs.
Parameters:
theTemplateName - The name of the rule template
theTemplateVarValues - The string values (or AbleRd values) to be used on the replacement variables
Returns:
The created AbleRule object

getRuleTemplate

public AbleRuleTemplate getRuleTemplate(java.lang.String theRuleName)
                                 throws AbleDataException
Retrieve a rule template object based on specified rule name
Returns:
A single rule template object or null if specified rule is not found or is not a rule template

getTemplateString

public java.lang.String getTemplateString(java.util.Vector theTemplateVars)
                                   throws AbleDataException
Retrieve a text format string for use by ruleset templates. The string contains "{n}" strings, where the index 'n' corresponds to the template variables defined in the ruleblock template. This string is based on the standard arlString() representation of the ruleset. After replacement of the template variable values, the resulting string must be a valid ARL format string that can be parsed.
Parameters:
theTemplateVars - An ordered list of template variables referenced by this ruleset.
Returns:
A Text format string used to create a new ruleset instance.
See Also:
AbleRuleTemplate

getTemplateStringHeader

protected java.lang.String getTemplateStringHeader(java.util.Vector theTemplateVars)

getTemplateStringDclPredicates

protected java.lang.String getTemplateStringDclPredicates(java.util.Vector theTemplateVars)

getTemplateStringDclInnerClasses

protected java.lang.String getTemplateStringDclInnerClasses(java.util.Vector theTemplateVars)

getTemplateStringVariables

protected java.lang.String getTemplateStringVariables(java.util.Vector theTemplateVars)

getTemplateStringInputVariables

protected java.lang.String getTemplateStringInputVariables(java.util.Vector theTemplateVars)

getTemplateStringOutputVariables

protected java.lang.String getTemplateStringOutputVariables(java.util.Vector theTemplateVars)

getTemplateStringUdfs

protected java.lang.String getTemplateStringUdfs(java.util.Vector theTemplateVars)

getTemplateStringRules

protected java.lang.String getTemplateStringRules(java.util.Vector theTemplateVars)
                                           throws AbleDataException

getTemplateStringTrailer

protected java.lang.String getTemplateStringTrailer()

print

public void print(java.lang.Object theMsgText)
Write a text string to the console (System.out) without a line separator.

println

public void println(java.lang.Object theMsgText)
Write a text string to the console (System.out) followed by a line separator.

println

public void println(java.lang.Object theMsgText1,
                    java.lang.Object theMsgText2)
Write two text strings to the console (System.out) on the same line: msgText1 + msgText2.

trace

public java.lang.String trace(java.lang.Object theMsgObject)
                       throws AbleException
Write a text string to the specified ruleset's Inference trace log.
Parameters:
theMsgObject - The object or text to be written.

Returns:
The input message text.

traceFormat

public java.lang.String traceFormat(java.lang.String theFormatString,
                                    java.lang.Object[] theInsert)
                             throws AbleException
Write a formatted text string with a single insertion argument to the specified ruleset's Inference trace log.

Uses Java MessageFormat ... traceFormat ("this is a {0} message" , new Object[] {"test"} )

Parameters:
theRuleSet - The AbleRuleSet object

theFormatString - A String with a single insertion point.

theInsert - An object to insert into the format string.

Returns:
the Formatted String

wrapBraces

protected static java.lang.String wrapBraces(java.lang.String theArlString)
Take a valid ARL string and wrap any braces with single quotes for use as part of a template (text format) string
Parameters:
theArlString - An ARL text source string
Returns:
A string with any curly braces wrapped with single quotes for use as part of template processing using text format strings.

convertToConjunctiveNormalForm

protected static java.util.Vector convertToConjunctiveNormalForm(AbleExpression theExpr,
                                                                 AbleRuleSet theRuleSet)
Convert an Expression into conjunctive normal form a list of AbleAntecedentClauses (which may contain Expressions)
Parameters:
theExpr - An AbleExpression object
theRuleSet - An AbleRuleSet object used for context
Returns:
A Vector of AbleAntecedentClauses

addRuleSetChangeListener

public void addRuleSetChangeListener(java.beans.PropertyChangeListener theListener)
                              throws AbleException
Add a property change listener to the ruleset. The listener is notified when any changes occur to the ruleset itself, and also when any changes occur to variables, rules, or fuzzy set solution areas.
Parameters:
theListener - Any property change listener.


removeRuleSetChangeListener

public void removeRuleSetChangeListener(java.beans.PropertyChangeListener theListener)
                                 throws AbleException
Remove a property change listener from the ruleset.
Parameters:
theListener - Any previously added property change listener.


toString

public java.lang.String toString()
Retrieve a string describing (the contents of) the object.
Overrides:
toString in class java.lang.Object
Returns:
A String containing the current contents of the object.

Copyright

public static java.lang.String Copyright()
Determine the copyright of this class.
Returns:
A String containing this class's copyright statement.

ABLE 2.0.0 07/02/2003 10:25:01

(C) Copyright IBM Corporation 1999, 2003