org.drools.io
Class RuleSetReader

java.lang.Object
  |
  +--org.xml.sax.helpers.DefaultHandler
        |
        +--org.drools.io.RuleSetReader
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

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

RuleSet loader.

Version:
$Id: RuleSetReader.java,v 1.3 2004/01/01 23:43:55 bob Exp $
Author:
bob mcwhirter

Field Summary
static java.lang.String RULES_NAMESPACE_URI
          Namespace URI for the general tags.
 
Constructor Summary
RuleSetReader()
          Construct.
RuleSetReader(javax.xml.parsers.SAXParser parser)
          Construct.
RuleSetReader(SemanticsRepository repo)
          Construct.
RuleSetReader(SemanticsRepository repo, javax.xml.parsers.SAXParser parser)
          Construct.
 
Method Summary
 void characters(char[] chars, int start, int len)
           
protected  void endCondition(SemanticModule module, java.lang.String localName)
          End a condition.
protected  Configuration endConfiguration()
          End a configuration node.
protected  void endConsequence(SemanticModule module, java.lang.String localName)
          End a consequence.
protected  void endDeclaration()
          End a <declaration>.
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qname)
           
protected  void endExtraction(SemanticModule module, java.lang.String localName)
          End an extraction.
protected  void endObjectType(SemanticModule module, java.lang.String localName)
          End object-type.
protected  void endParameter()
          End a <parameter>.
protected  void endRule()
          End a <rule>.
protected  void endRuleSet()
          End a <rule-set>.
 org.xml.sax.Locator getLocator()
          Get the Locator.
 RuleSet read(org.xml.sax.InputSource in)
          Read a RuleSet from an InputSource.
 RuleSet read(java.io.InputStream inputStream)
          Read a RuleSet from an InputStream.
 RuleSet read(java.io.Reader reader)
          Read a RuleSet from a Reader.
 RuleSet read(java.lang.String url)
          Read a RuleSet from a URL.
 RuleSet read(java.net.URL url)
          Read a RuleSet from a URL.
 void setLocator(org.xml.sax.Locator locator)
           
protected  void startCondition(SemanticModule module, java.lang.String name, org.xml.sax.Attributes attrs)
          Start a condition.
protected  void startConfiguration(java.lang.String name, org.xml.sax.Attributes attrs)
          Start a configuration node.
protected  void startConsequence(SemanticModule module, java.lang.String name, org.xml.sax.Attributes attrs)
          Start a consequence.
protected  void startDeclaration(org.xml.sax.Attributes attrs)
          Start a <declaration>.
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qname, org.xml.sax.Attributes attrs)
           
protected  void startExtraction(SemanticModule module, java.lang.String localName, org.xml.sax.Attributes attrs)
          Start an extraction.
protected  void startObjectType(SemanticModule module, java.lang.String localName, org.xml.sax.Attributes attrs)
          Start an object-type.
protected  void startParameter(org.xml.sax.Attributes attrs)
          Start a <parameter>.
protected  void startRule(Rule rule, org.xml.sax.Attributes attrs)
           
protected  void startRule(SemanticModule module, java.lang.String localName, org.xml.sax.Attributes attrs)
           
protected  void startRuleSet(org.xml.sax.Attributes attrs)
          Start a <rule-set>.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RULES_NAMESPACE_URI

public static final java.lang.String RULES_NAMESPACE_URI
Namespace URI for the general tags.

See Also:
Constant Field Values
Constructor Detail

RuleSetReader

public RuleSetReader()
Construct.

Uses the default JAXP SAX parser and the default classpath-based DefaultSemanticModule.


RuleSetReader

public RuleSetReader(javax.xml.parsers.SAXParser parser)
Construct.

Uses the default classpath-based DefaultSemanticModule.

Parameters:
parser - The SAX parser.

RuleSetReader

public RuleSetReader(SemanticsRepository repo,
                     javax.xml.parsers.SAXParser parser)
Construct.

Parameters:
repo - The semantics repository.
parser - The SAX parser.

RuleSetReader

public RuleSetReader(SemanticsRepository repo)
Construct.

Parameters:
repo - The semantics repository.
Method Detail

read

public RuleSet read(java.net.URL url)
             throws java.lang.Exception
Read a RuleSet from a URL.

Parameters:
url - The rule-set URL.
Returns:
The rule-set.
Throws:
java.lang.Exception - If an error occurs during the parse.

read

public RuleSet read(java.io.Reader reader)
             throws java.lang.Exception
Read a RuleSet from a Reader.

Parameters:
reader - The reader containing the rule-set.
Returns:
The rule-set.
Throws:
java.lang.Exception - If an error occurs during the parse.

read

public RuleSet read(java.io.InputStream inputStream)
             throws java.lang.Exception
Read a RuleSet from an InputStream.

Parameters:
inputStream - The input-stream containing the rule-set.
Returns:
The rule-set.
Throws:
java.lang.Exception - If an error occurs during the parse.

read

public RuleSet read(java.lang.String url)
             throws java.lang.Exception
Read a RuleSet from a URL.

Parameters:
url - The rule-set URL.
Returns:
The rule-set.
Throws:
java.lang.Exception - If an error occurs during the parse.

read

public RuleSet read(org.xml.sax.InputSource in)
             throws java.lang.Exception
Read a RuleSet from an InputSource.

Parameters:
in - The rule-set input-source.
Returns:
The rule-set.
Throws:
java.lang.Exception - If an error occurs during the parse.

setLocator

public void setLocator(org.xml.sax.Locator locator)
See Also:
ContentHandler

getLocator

public org.xml.sax.Locator getLocator()
Get the Locator.

Returns:
The locator.

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qname,
                         org.xml.sax.Attributes attrs)
                  throws org.xml.sax.SAXException
Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
See Also:
ContentHandler

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qname)
                throws org.xml.sax.SAXException
Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
See Also:
ContentHandler

startRuleSet

protected void startRuleSet(org.xml.sax.Attributes attrs)
                     throws org.xml.sax.SAXException
Start a <rule-set>.

Parameters:
attrs - Tag attributes.
Throws:
org.xml.sax.SAXException - If an error occurs during parse.

endRuleSet

protected void endRuleSet()
                   throws org.xml.sax.SAXException
End a <rule-set>.

Throws:
org.xml.sax.SAXException - If an error occurs during parse.

startRule

protected void startRule(SemanticModule module,
                         java.lang.String localName,
                         org.xml.sax.Attributes attrs)
                  throws org.xml.sax.SAXException
org.xml.sax.SAXException

startRule

protected void startRule(Rule rule,
                         org.xml.sax.Attributes attrs)
                  throws org.xml.sax.SAXException
org.xml.sax.SAXException

endRule

protected void endRule()
                throws org.xml.sax.SAXException
End a <rule>.

Throws:
org.xml.sax.SAXException - If an error occurs during parse.

startParameter

protected void startParameter(org.xml.sax.Attributes attrs)
                       throws org.xml.sax.SAXException
Start a <parameter>.

Parameters:
attrs - Tag attributes.
Throws:
org.xml.sax.SAXException - If an error occurs during parse.

endParameter

protected void endParameter()
                     throws org.xml.sax.SAXException
End a <parameter>.

Throws:
org.xml.sax.SAXException - If an error occurs during parse.

startDeclaration

protected void startDeclaration(org.xml.sax.Attributes attrs)
                         throws org.xml.sax.SAXException
Start a <declaration>.

Parameters:
attrs - Tag attributes.
Throws:
org.xml.sax.SAXException - If an error occurs during parse.

endDeclaration

protected void endDeclaration()
                       throws org.xml.sax.SAXException
End a <declaration>.

Throws:
org.xml.sax.SAXException - If an error occurs during parse.

startObjectType

protected void startObjectType(SemanticModule module,
                               java.lang.String localName,
                               org.xml.sax.Attributes attrs)
                        throws org.xml.sax.SAXException
Start an object-type.

Parameters:
localName - Tag name.
attrs - Tag attributes.
Throws:
org.xml.sax.SAXException - If an error occurs during parse.

endObjectType

protected void endObjectType(SemanticModule module,
                             java.lang.String localName)
                      throws org.xml.sax.SAXException
End object-type.

Throws:
org.xml.sax.SAXException - If an error occurs during parse.

startExtraction

protected void startExtraction(SemanticModule module,
                               java.lang.String localName,
                               org.xml.sax.Attributes attrs)
                        throws org.xml.sax.SAXException
Start an extraction.

Parameters:
module - Semantic module.
localName - Tag name.
attrs - Tag attributes.
Throws:
org.xml.sax.SAXException - If an error occurs during parse.

endExtraction

protected void endExtraction(SemanticModule module,
                             java.lang.String localName)
                      throws org.xml.sax.SAXException
End an extraction.

Throws:
org.xml.sax.SAXException - If an error occurs during parse.

startCondition

protected void startCondition(SemanticModule module,
                              java.lang.String name,
                              org.xml.sax.Attributes attrs)
                       throws org.xml.sax.SAXException
Start a condition.

Parameters:
module - Semantic module.
name - Tag name.
attrs - Tag attributes.
Throws:
org.xml.sax.SAXException - If an error occurs during parse.

endCondition

protected void endCondition(SemanticModule module,
                            java.lang.String localName)
                     throws org.xml.sax.SAXException
End a condition.

Throws:
org.xml.sax.SAXException - If an error occurs during parse.

startConsequence

protected void startConsequence(SemanticModule module,
                                java.lang.String name,
                                org.xml.sax.Attributes attrs)
                         throws org.xml.sax.SAXException
Start a consequence.

Parameters:
module - Semantic module.
name - Tag name.
attrs - Tag attributes.
Throws:
org.xml.sax.SAXException - If an error occurs during parse.

endConsequence

protected void endConsequence(SemanticModule module,
                              java.lang.String localName)
                       throws org.xml.sax.SAXException
End a consequence.

Throws:
org.xml.sax.SAXException - If an error occurs during parse.

startConfiguration

protected void startConfiguration(java.lang.String name,
                                  org.xml.sax.Attributes attrs)
                           throws org.xml.sax.SAXException
Start a configuration node.

Parameters:
name - Tag name.
attrs - Tag attributes.
Throws:
org.xml.sax.SAXException - If an error occurs during parse.

characters

public void characters(char[] chars,
                       int start,
                       int len)
                throws org.xml.sax.SAXException
Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
See Also:
ContentHandler

endConfiguration

protected Configuration endConfiguration()
End a configuration node.

Returns:
The configuration.