ABLE 2.3.0 07/13/2005 14:21:00

com.ibm.able.rules
Class AbleARMLParser

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended bycom.ibm.able.rules.AbleARMLParser
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class AbleARMLParser
extends org.xml.sax.helpers.DefaultHandler

This class will read an XML document written according to the RuleSet.xsd schema, and instantiate an AbleRuleSet object.


Field Summary
protected  boolean inRuleBlockHeader
           
protected  boolean inTagPredicateRuleBody
           
protected  boolean inTreeSharedCondition
           
protected  double myAlphaCut
           
protected  java.util.Vector myAntClauses
           
protected  AbleExpression myAntExpression
           
protected  java.util.Vector myAntExpressionList
           
protected  AbleARLParser myARLParser
           
protected  AbleAssertionClause myAstClause
           
protected  AbleExpression myBooleanExpression
           
protected  AbleConsequentClause myCnsClause
           
protected  java.lang.String myComment
           
protected  AbleVariable myDclVariable
           
protected  AbleTree myDecisionTree
           
protected  java.util.Vector myDoList
           
protected  java.util.Vector myElseList
           
protected  java.lang.String myEngineType
           
protected  AbleRd myExpression
           
protected  java.util.Stack myExpressionStack
           
protected  java.util.Vector myForInitExprList
           
protected  java.util.Vector myForIterExprList
           
protected  java.util.Vector myFormalParameterList
           
protected  java.lang.String myFormalSignature
           
protected  AbleExpression myForTestExpr
           
protected  AbleFuzzyVariable myFuzzyVariable
           
protected  java.lang.String myImportLibName
           
protected  AbleARLLexer myLexer
           
protected  antlr.LexerSharedInputState myLexerState
           
protected  org.xml.sax.Locator myLocator
           
protected  AbleExpression myLogicalExpression
           
protected  java.util.Vector myPlanEffectsList
           
protected  java.util.Vector myPlanExpansionList
           
protected  AbleExpression myPlanPrecondition
           
protected  java.util.Vector myPredClauses
           
protected  AblePredicate myPredLhs
           
protected  java.util.Stack myPropertyStack
           
protected  java.io.StringReader myReader
           
protected  AbleRule myRule
           
protected  double myRuleAntWeight
           
protected  AbleRuleBlock myRuleBlock
           
protected  java.lang.String myRuleBlockComment
           
protected  java.lang.String myRuleBlockInferenceEngine
           
protected  java.lang.String myRuleBlockName
           
protected  java.lang.String myRuleBlockReturnType
           
protected  AbleRd myRuleCns
           
protected  java.lang.String myRuleHedges
           
protected  java.lang.String myRuleLabel
           
protected  java.lang.Object[] myRulePreConditions
           
protected  AbleRd myRulePriority
           
protected  java.util.Hashtable myRuleProperties
           
protected  boolean myRuleReplacementMode
           
protected  AbleRuleSet myRuleSet
           
protected  java.lang.String myRuleSetName
           
protected  java.lang.String mySource
           
protected  boolean myStopOnParException
           
protected  AbleSwitchStatement mySwitchStatement
           
protected  boolean myTemplateFlag
           
protected  java.lang.String myTempString
           
protected  java.lang.StringBuffer myTempStringBuf
           
protected  java.util.Vector myThenList
           
protected  AbleLogger myTracer
           
protected  AbleTreeActionNode myTreeActionNode
           
protected  AbleTreeConditionNode myTreeConditionNode
           
protected  AbleTreeEdge myTreeEdge
           
protected  java.util.Stack myTreeStack
           
protected  AbleTreePartialExpression myTreeTerm
           
protected  java.lang.String myTreeTermRef
           
protected  AbleTreePartialExpression myTreeValue
           
protected  java.lang.String myTreeValueRef
           
protected  java.util.Vector myTreeValues
           
protected  java.lang.String myUserDefinedFunctionName
           
protected  java.lang.String myUserTypeClass
           
protected  java.lang.String myUserTypeName
           
protected  java.lang.String myVariableClassName
           
protected  double myVariableContinuousHi
           
protected  double myVariableContinuousLo
           
protected  int myVariableLength
           
protected  java.lang.String myVariableName
           
protected  boolean myVariableStaticFlag
           
protected  java.lang.String myVariableType
           
protected  AbleRd myVarInitializer
           
protected  java.util.Vector myVarInitializerArgs
           
protected  boolean myVarInitializerFlag
           
protected  boolean myVarIsLocal
           
protected  boolean myWdSelPosFlag
           
protected  AbleVariable myWdSelVariable
           
protected  java.lang.String myWdSelVarName
           
protected  java.lang.String myWdSelVarType
           
protected  java.util.Vector myWdWhenList
           
 
Constructor Summary
AbleARMLParser()
           
 
Method Summary
 void characters(char[] ch, int start, int end)
           
 void endElement(java.lang.String theUri, java.lang.String theLocalName, java.lang.String theRawName)
           
 void error(org.xml.sax.SAXParseException theSAXParseException)
           
 void fatalError(org.xml.sax.SAXParseException theSAXParseException)
           
 AbleRd instantiateExpressionFrom(AbleRuleSet theRuleSet, java.lang.String theArmlSource)
          Instantiate an AbleRd object (a Literal, Variable, or Expression) by reading an input String containing ABLE Rule Language text source.
 void instantiateFrom(org.xml.sax.InputSource theRuleSetSource, AbleRuleSet theRuleSet, AbleLogger theTracer, boolean theStopOnParExceptionFlag)
          Parse an XML ruleset with Sax InputSource as source object
 void instantiateFrom(java.io.InputStream theRuleSetInputStream, AbleRuleSet theRuleSet, AbleLogger theTracer, boolean theStopOnParExceptionFlag)
          Parse an XML ruleset, with InputStream as source object
 void instantiateFrom(java.io.Reader theRuleSetReader, AbleRuleSet theRuleSet, AbleLogger theTracer, boolean theStopOnParExceptionFlag)
          Parse an XML ruleset with a Reader as source object
 void instantiateFrom(java.lang.String theRuleSetDocument, AbleRuleSet theRuleSet, AbleLogger theTracer, boolean theStopOnParExceptionFlag)
          Parse a XML ruleset with URI as source
 AbleRuleBlock instantiateRuleBlockFrom(AbleRuleSet theRuleSet, java.lang.String theArmlSource)
          Instantiate a complete ruleblock object by reading an input String containing ABLE Rule Language XML source.
 AbleRule instantiateRuleFrom(AbleRuleSet theRuleSet, java.lang.String theArmlSource, java.lang.String theRuleBlockName, boolean theReplacementMode)
          Instantiate a complete rule object by reading an input String containing ABLE Rule Language text source.
 boolean isStopOnParException()
           
 boolean isTraceActive()
           
 AbleExpression parseActionFromARL(java.lang.String theArlSource)
          Parse and instantiate an Able action object (Expression or statement) by reading an input String containing ABLE Rule Language text source.
 AbleExpression 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.
 void setDocumentLocator(org.xml.sax.Locator theLocator)
           
 void setStopOnParException(boolean theStopOnParExceptionFlag)
           
 void setTraceActive(boolean theTraceValue)
           
 void startElement(java.lang.String theUri, java.lang.String theLocalName, java.lang.String theRawName, org.xml.sax.Attributes theAttributes)
           
 AbleRd testParseExpressionFromARL(AbleRuleSet theRuleSet, java.lang.String theSource)
           
 void warning(org.xml.sax.SAXParseException theSAXParseException)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myLocator

protected org.xml.sax.Locator myLocator

myRuleSet

protected AbleRuleSet myRuleSet

myTracer

protected AbleLogger myTracer

myStopOnParException

protected boolean myStopOnParException

myRuleSetName

protected java.lang.String myRuleSetName

myComment

protected java.lang.String myComment

myTemplateFlag

protected boolean myTemplateFlag

myAlphaCut

protected double myAlphaCut

myEngineType

protected java.lang.String myEngineType

myImportLibName

protected java.lang.String myImportLibName

myUserTypeName

protected java.lang.String myUserTypeName

myUserTypeClass

protected java.lang.String myUserTypeClass

myVariableName

protected java.lang.String myVariableName

myVarIsLocal

protected boolean myVarIsLocal

myDclVariable

protected AbleVariable myDclVariable

myVarInitializerFlag

protected boolean myVarInitializerFlag

myVarInitializer

protected AbleRd myVarInitializer

myVarInitializerArgs

protected java.util.Vector myVarInitializerArgs

myVariableContinuousLo

protected double myVariableContinuousLo

myVariableContinuousHi

protected double myVariableContinuousHi

myVariableLength

protected int myVariableLength

myVariableStaticFlag

protected boolean myVariableStaticFlag

myVariableType

protected java.lang.String myVariableType

myVariableClassName

protected java.lang.String myVariableClassName

myUserDefinedFunctionName

protected java.lang.String myUserDefinedFunctionName

myFuzzyVariable

protected AbleFuzzyVariable myFuzzyVariable

myTempString

protected java.lang.String myTempString

myTempStringBuf

protected java.lang.StringBuffer myTempStringBuf

myRuleBlockName

protected java.lang.String myRuleBlockName

myRuleBlock

protected AbleRuleBlock myRuleBlock

myRuleBlockReturnType

protected java.lang.String myRuleBlockReturnType

myFormalSignature

protected java.lang.String myFormalSignature

myRuleAntWeight

protected double myRuleAntWeight

myRuleHedges

protected java.lang.String myRuleHedges

myRuleLabel

protected java.lang.String myRuleLabel

myRule

protected AbleRule myRule

myRulePreConditions

protected java.lang.Object[] myRulePreConditions

myRuleReplacementMode

protected boolean myRuleReplacementMode

inRuleBlockHeader

protected boolean inRuleBlockHeader

myRuleBlockInferenceEngine

protected java.lang.String myRuleBlockInferenceEngine

myRuleBlockComment

protected java.lang.String myRuleBlockComment

myAntClauses

protected java.util.Vector myAntClauses

myAntExpressionList

protected java.util.Vector myAntExpressionList

myAntExpression

protected AbleExpression myAntExpression

myRulePriority

protected AbleRd myRulePriority

myExpression

protected AbleRd myExpression

myExpressionStack

protected java.util.Stack myExpressionStack

myBooleanExpression

protected AbleExpression myBooleanExpression

myLogicalExpression

protected AbleExpression myLogicalExpression

myRuleCns

protected AbleRd myRuleCns

myAstClause

protected AbleAssertionClause myAstClause

myCnsClause

protected AbleConsequentClause myCnsClause

myThenList

protected java.util.Vector myThenList

myElseList

protected java.util.Vector myElseList

myWdWhenList

protected java.util.Vector myWdWhenList

myWdSelVarName

protected java.lang.String myWdSelVarName

myWdSelVarType

protected java.lang.String myWdSelVarType

myWdSelPosFlag

protected boolean myWdSelPosFlag

myWdSelVariable

protected AbleVariable myWdSelVariable

myPredLhs

protected AblePredicate myPredLhs

myPredClauses

protected java.util.Vector myPredClauses

myDoList

protected java.util.Vector myDoList

myForInitExprList

protected java.util.Vector myForInitExprList

myForTestExpr

protected AbleExpression myForTestExpr

myForIterExprList

protected java.util.Vector myForIterExprList

myPlanPrecondition

protected AbleExpression myPlanPrecondition

myFormalParameterList

protected java.util.Vector myFormalParameterList

myPlanEffectsList

protected java.util.Vector myPlanEffectsList

myPlanExpansionList

protected java.util.Vector myPlanExpansionList

mySwitchStatement

protected AbleSwitchStatement mySwitchStatement

myDecisionTree

protected AbleTree myDecisionTree

myTreeTerm

protected AbleTreePartialExpression myTreeTerm

myTreeTermRef

protected java.lang.String myTreeTermRef

myTreeValues

protected java.util.Vector myTreeValues

myTreeValue

protected AbleTreePartialExpression myTreeValue

myTreeValueRef

protected java.lang.String myTreeValueRef

inTreeSharedCondition

protected boolean inTreeSharedCondition

myTreeActionNode

protected AbleTreeActionNode myTreeActionNode

myTreeConditionNode

protected AbleTreeConditionNode myTreeConditionNode

myTreeStack

protected java.util.Stack myTreeStack

myTreeEdge

protected AbleTreeEdge myTreeEdge

myRuleProperties

protected java.util.Hashtable myRuleProperties

myPropertyStack

protected java.util.Stack myPropertyStack

inTagPredicateRuleBody

protected boolean inTagPredicateRuleBody

mySource

protected transient java.lang.String mySource

myReader

protected transient java.io.StringReader myReader

myLexer

protected transient AbleARLLexer myLexer

myARLParser

protected transient AbleARLParser myARLParser

myLexerState

protected transient antlr.LexerSharedInputState myLexerState
Constructor Detail

AbleARMLParser

public AbleARMLParser()
Method Detail

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator theLocator)

startElement

public void startElement(java.lang.String theUri,
                         java.lang.String theLocalName,
                         java.lang.String theRawName,
                         org.xml.sax.Attributes theAttributes)
                  throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

endElement

public void endElement(java.lang.String theUri,
                       java.lang.String theLocalName,
                       java.lang.String theRawName)
                throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

characters

public void characters(char[] ch,
                       int start,
                       int end)
                throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

error

public void error(org.xml.sax.SAXParseException theSAXParseException)

fatalError

public void fatalError(org.xml.sax.SAXParseException theSAXParseException)
                throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

warning

public void warning(org.xml.sax.SAXParseException theSAXParseException)

instantiateFrom

public void instantiateFrom(java.lang.String theRuleSetDocument,
                            AbleRuleSet theRuleSet,
                            AbleLogger theTracer,
                            boolean theStopOnParExceptionFlag)
                     throws AbleParException,
                            java.lang.ClassNotFoundException,
                            java.lang.IllegalAccessException,
                            java.lang.InstantiationException,
                            java.io.IOException
Parse a XML ruleset with URI as source

Throws:
AbleParException
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.io.IOException

instantiateFrom

public void instantiateFrom(java.io.Reader theRuleSetReader,
                            AbleRuleSet theRuleSet,
                            AbleLogger theTracer,
                            boolean theStopOnParExceptionFlag)
                     throws AbleParException,
                            java.lang.ClassNotFoundException,
                            java.lang.IllegalAccessException,
                            java.lang.InstantiationException,
                            java.io.IOException
Parse an XML ruleset with a Reader as source object

Throws:
AbleParException
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.io.IOException

instantiateFrom

public void instantiateFrom(org.xml.sax.InputSource theRuleSetSource,
                            AbleRuleSet theRuleSet,
                            AbleLogger theTracer,
                            boolean theStopOnParExceptionFlag)
                     throws AbleParException,
                            java.lang.ClassNotFoundException,
                            java.lang.IllegalAccessException,
                            java.lang.InstantiationException,
                            java.io.IOException
Parse an XML ruleset with Sax InputSource as source object

Throws:
AbleParException
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.io.IOException

instantiateFrom

public void instantiateFrom(java.io.InputStream theRuleSetInputStream,
                            AbleRuleSet theRuleSet,
                            AbleLogger theTracer,
                            boolean theStopOnParExceptionFlag)
                     throws AbleParException,
                            java.lang.ClassNotFoundException,
                            java.lang.IllegalAccessException,
                            java.lang.InstantiationException,
                            java.io.IOException
Parse an XML ruleset, with InputStream as source object

Throws:
AbleParException
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.io.IOException

instantiateRuleBlockFrom

public AbleRuleBlock instantiateRuleBlockFrom(AbleRuleSet theRuleSet,
                                              java.lang.String theArmlSource)
                                       throws AbleParException
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:
theRuleSet - The ruleset object which serves as context
theArmlSource - The source from which a ruleblock is compiled and added to this ruleset object.

Returns:
The newly instantated AbleRuleBlock object
Throws:
AbleParException - On any error.
antlr.RecognitionException - If the ruleblock cannot be parsed successfully.

instantiateRuleFrom

public AbleRule instantiateRuleFrom(AbleRuleSet theRuleSet,
                                    java.lang.String theArmlSource,
                                    java.lang.String theRuleBlockName,
                                    boolean theReplacementMode)
                             throws AbleParException
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.

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:
theRuleSet - The ruleset object which serves as context
theArmlSource - 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.
antlr.RecognitionException - If the ruleblock cannot be parsed successfully.

instantiateExpressionFrom

public AbleRd instantiateExpressionFrom(AbleRuleSet theRuleSet,
                                        java.lang.String theArmlSource)
                                 throws AbleParException
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.

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:
theRuleSet - The ruleset object that serves as context.
theArmlSource - 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.
antlr.RecognitionException - If the ruleblock cannot be parsed successfully.

parseExpressionFromARL

public AbleExpression 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.

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.
AbleException

testParseExpressionFromARL

public AbleRd testParseExpressionFromARL(AbleRuleSet theRuleSet,
                                         java.lang.String theSource)
                                  throws AbleException
Throws:
AbleException

parseActionFromARL

public AbleExpression parseActionFromARL(java.lang.String theArlSource)
                                  throws AbleException
Parse and instantiate an Able action object (Expression or statement) 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.

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.
AbleException

setTraceActive

public void setTraceActive(boolean theTraceValue)

isTraceActive

public boolean isTraceActive()

setStopOnParException

public void setStopOnParException(boolean theStopOnParExceptionFlag)

isStopOnParException

public boolean isStopOnParException()

ABLE 2.3.0 07/13/2005 14:21:00

(C) Copyright IBM Corporation 1999, 2005