org.drools.io
Class RuleSetReader

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by 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. Note you can override the default entity resolver by setting the System property of: org.drools.io.EntityResolve to your own custom entity resolver. This can be done using -Dorg.drools.io.EntityResolver=YourClassHere on the command line, for instance.


Field Summary
static java.lang.String ENTITY_RESOLVER_PROPERTY_NAME
           
static java.lang.String RULES_NAMESPACE_URI
          Namespace URI for the general tags.
 
Constructor Summary
RuleSetReader()
          Construct.
RuleSetReader(RuleBaseContext factoryContext)
          Construct.
RuleSetReader(javax.xml.parsers.SAXParser parser)
          Construct.
RuleSetReader(javax.xml.parsers.SAXParser parser, RuleBaseContext context)
          Construct.
RuleSetReader(javax.xml.parsers.SAXParser parser, SemanticsRepository repo)
          Construct.
RuleSetReader(SemanticsRepository repo)
          Construct.
RuleSetReader(SemanticsRepository repo, RuleBaseContext context)
          Construct.
RuleSetReader(SemanticsRepository repo, javax.xml.parsers.SAXParser parser)
          Construct.
RuleSetReader(SemanticsRepository repo, javax.xml.parsers.SAXParser parser, RuleBaseContext context)
          Construct.
 
Method Summary
 void characters(char[] chars, int start, int len)
           
protected  Configuration endConfiguration()
          End a configuration node.
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qname)
           
 void endPrefixMapping(java.lang.String prefix)
           
 void error(org.xml.sax.SAXParseException x)
           
 void fatalError(org.xml.sax.SAXParseException x)
           
 RuleBaseContext getFactoryContext()
           
 org.xml.sax.Locator getLocator()
          Get the Locator.
 RuleSet getRuleSet()
           
 SemanticsRepository getSemanticsRepository()
           
 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.
 org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
           
 void setDocumentLocator(org.xml.sax.Locator locator)
           
protected  void startConfiguration(java.lang.String name, org.xml.sax.Attributes attrs)
          Start a configuration node.
 void startDocument()
           
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qname, org.xml.sax.Attributes attrs)
           
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
           
 void warning(org.xml.sax.SAXParseException x)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, ignorableWhitespace, notationDecl, processingInstruction, skippedEntity, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENTITY_RESOLVER_PROPERTY_NAME

public static final java.lang.String ENTITY_RESOLVER_PROPERTY_NAME
See Also:
Constant Field Values

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)
Construct.

Parameters:
repo - The semantics repository.

RuleSetReader

public RuleSetReader(RuleBaseContext factoryContext)
Construct.

Parameters:
factoryContext -

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,
                     RuleBaseContext context)
Construct.

Parameters:
repo - The semantics repository.

RuleSetReader

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

Parameters:
parser -
repo - The semantics repository.

RuleSetReader

public RuleSetReader(javax.xml.parsers.SAXParser parser,
                     RuleBaseContext context)
Construct.

Parameters:
parser -
context -

RuleSetReader

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

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

read

public RuleSet read(java.net.URL url)
             throws org.xml.sax.SAXException,
                    java.io.IOException
Read a RuleSet from a URL.

Parameters:
url - The rule-set URL.
Returns:
The rule-set.
Throws:
org.xml.sax.SAXException
java.io.IOException

read

public RuleSet read(java.io.Reader reader)
             throws org.xml.sax.SAXException,
                    java.io.IOException
Read a RuleSet from a Reader.

Parameters:
reader - The reader containing the rule-set.
Returns:
The rule-set.
Throws:
org.xml.sax.SAXException
java.io.IOException

read

public RuleSet read(java.io.InputStream inputStream)
             throws org.xml.sax.SAXException,
                    java.io.IOException
Read a RuleSet from an InputStream.

Parameters:
inputStream - The input-stream containing the rule-set.
Returns:
The rule-set.
Throws:
org.xml.sax.SAXException
java.io.IOException

read

public RuleSet read(java.lang.String url)
             throws org.xml.sax.SAXException,
                    java.io.IOException
Read a RuleSet from a URL.

Parameters:
url - The rule-set URL.
Returns:
The rule-set.
Throws:
org.xml.sax.SAXException
java.io.IOException

read

public RuleSet read(org.xml.sax.InputSource in)
             throws org.xml.sax.SAXException,
                    java.io.IOException
Read a RuleSet from an InputSource.

Parameters:
in - The rule-set input-source.
Returns:
The rule-set.
Throws:
org.xml.sax.SAXException
java.io.IOException

getSemanticsRepository

public SemanticsRepository getSemanticsRepository()

getRuleSet

public RuleSet getRuleSet()

getFactoryContext

public RuleBaseContext getFactoryContext()

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler
Overrides:
setDocumentLocator in class org.xml.sax.helpers.DefaultHandler
See Also:
ContentHandler

getLocator

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

Returns:
The locator.

startDocument

public void startDocument()
Specified by:
startDocument in interface org.xml.sax.ContentHandler
Overrides:
startDocument in class org.xml.sax.helpers.DefaultHandler

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
Parameters:
uri -
localName -
qname -
attrs -
Throws:
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
Parameters:
uri -
localName -
qname -
Throws:
org.xml.sax.SAXException
See Also:
ContentHandler

startConfiguration

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

Parameters:
name - Tag name.
attrs - Tag attributes.

characters

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

endConfiguration

protected Configuration endConfiguration()
End a configuration node.

Returns:
The configuration.

resolveEntity

public org.xml.sax.InputSource resolveEntity(java.lang.String publicId,
                                             java.lang.String systemId)
                                      throws org.xml.sax.SAXException
Specified by:
resolveEntity in interface org.xml.sax.EntityResolver
Overrides:
resolveEntity in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
                        throws org.xml.sax.SAXException
Specified by:
startPrefixMapping in interface org.xml.sax.ContentHandler
Overrides:
startPrefixMapping in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

endPrefixMapping

public void endPrefixMapping(java.lang.String prefix)
                      throws org.xml.sax.SAXException
Specified by:
endPrefixMapping in interface org.xml.sax.ContentHandler
Overrides:
endPrefixMapping in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

warning

public void warning(org.xml.sax.SAXParseException x)
Specified by:
warning in interface org.xml.sax.ErrorHandler
Overrides:
warning in class org.xml.sax.helpers.DefaultHandler

error

public void error(org.xml.sax.SAXParseException x)
Specified by:
error in interface org.xml.sax.ErrorHandler
Overrides:
error in class org.xml.sax.helpers.DefaultHandler

fatalError

public void fatalError(org.xml.sax.SAXParseException x)
                throws org.xml.sax.SAXParseException
Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Overrides:
fatalError in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXParseException