Package org.drools.core.xml
Class ExtensibleXmlParser
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- org.drools.core.xml.ExtensibleXmlParser
-
- All Implemented Interfaces:
ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
public class ExtensibleXmlParser extends DefaultHandler
RuleSet
loader. Note you can override the default entity resolver by setting the System property of:org.kie.api.io.EntityResolve
to your own custom entity resolver. This can be done using -Dorg.drools.io.EntityResolver=YourClassHere on the command line, for instance.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ExtensibleXmlParser.Null
-
Field Summary
Fields Modifier and Type Field Description static String
ENTITY_RESOLVER_PROPERTY_NAME
protected static org.slf4j.Logger
logger
static String
RULES_NAMESPACE_URI
Namespace URI for the general tags.
-
Constructor Summary
Constructors Constructor Description ExtensibleXmlParser()
Construct.ExtensibleXmlParser(SAXParser parser)
Construct.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
buildPrintMessage(SAXParseException x)
void
characters(char[] chars, int start, int len)
void
endElement(String uri, String localName, String qname)
Element
endElementBuilder()
End a configuration node.void
endPrefixMapping(String prefix)
void
error(SAXParseException x)
void
fatalError(SAXParseException x)
Attributes
getAttrs()
ClassLoader
getClassLoader()
Object
getCurrent()
Object
getData()
Locator
getLocator()
Get theLocator
.Map
getMetaData()
Object
getNamespaceURI(String namespace)
Object
getParent()
Object
getParent(int index)
Object
getParent(Class parent)
Collection
getParents()
SAXParser
getParser()
Object
getPeer()
int
getTimeout()
Timeout for retrieving remote resourcesObject
read(InputStream inputStream)
Read aRuleSet
from anInputStream
.Object
read(Reader reader)
Read aRuleSet
from aReader
.Object
read(InputSource in)
Read aRuleSet
from anInputSource
.Object
removeParent()
InputSource
resolveEntity(String publicId, String systemId)
void
setClassLoader(ClassLoader classLoader)
void
setData(Object data)
void
setDocumentLocator(Locator locator)
void
setParser(SAXParser parser)
void
setSemanticModules(SemanticModules modules)
void
setTimeout(int timeout)
Sets the timeout for retrieving remote resources, e.g. xsd schemasvoid
startDocument()
void
startElement(String uri, String localName, String qname, Attributes attrs)
void
startElementBuilder(String tagName, Attributes attrs)
Start a configuration node.void
startPrefixMapping(String prefix, String uri)
void
warning(SAXParseException x)
-
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, ignorableWhitespace, notationDecl, processingInstruction, skippedEntity, unparsedEntityDecl
-
-
-
-
Field Detail
-
logger
protected static final transient org.slf4j.Logger logger
-
ENTITY_RESOLVER_PROPERTY_NAME
public static final String ENTITY_RESOLVER_PROPERTY_NAME
- See Also:
- Constant Field Values
-
RULES_NAMESPACE_URI
public static final String RULES_NAMESPACE_URI
Namespace URI for the general tags.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ExtensibleXmlParser
public ExtensibleXmlParser()
Construct.Uses the default JAXP SAX parser and the default classpath-based
DefaultSemanticModule
.
-
ExtensibleXmlParser
public ExtensibleXmlParser(SAXParser parser)
Construct.Uses the default classpath-based
DefaultSemanticModule
.- Parameters:
parser
- The SAX parser.
-
-
Method Detail
-
setSemanticModules
public void setSemanticModules(SemanticModules modules)
-
read
public Object read(Reader reader) throws SAXException, IOException
Read aRuleSet
from aReader
.- Parameters:
reader
- The reader containing the rule-set.- Returns:
- The rule-set.
- Throws:
ParserConfigurationException
SAXException
IOException
-
read
public Object read(InputStream inputStream) throws SAXException, IOException
Read aRuleSet
from anInputStream
.- Parameters:
inputStream
- The input-stream containing the rule-set.- Returns:
- The rule-set.
- Throws:
ParserConfigurationException
SAXException
IOException
-
read
public Object read(InputSource in) throws SAXException, IOException
Read aRuleSet
from anInputSource
.- Parameters:
in
- The rule-set input-source.- Returns:
- The rule-set.
- Throws:
ParserConfigurationException
SAXException
IOException
-
setData
public void setData(Object data)
-
getData
public Object getData()
-
getClassLoader
public ClassLoader getClassLoader()
-
setClassLoader
public void setClassLoader(ClassLoader classLoader)
-
getMetaData
public Map getMetaData()
-
setDocumentLocator
public void setDocumentLocator(Locator locator)
- Specified by:
setDocumentLocator
in interfaceContentHandler
- Overrides:
setDocumentLocator
in classDefaultHandler
- See Also:
ContentHandler
-
getLocator
public Locator getLocator()
Get theLocator
.- Returns:
- The locator.
-
startDocument
public void startDocument()
- Specified by:
startDocument
in interfaceContentHandler
- Overrides:
startDocument
in classDefaultHandler
-
startElement
public void startElement(String uri, String localName, String qname, Attributes attrs) throws SAXException
- Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Parameters:
uri
-localName
-qname
-attrs
-- Throws:
SAXException
- See Also:
ContentHandler
-
endElement
public void endElement(String uri, String localName, String qname) throws SAXException
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Parameters:
uri
-localName
-qname
-- Throws:
SAXException
- See Also:
ContentHandler
-
startElementBuilder
public void startElementBuilder(String tagName, Attributes attrs)
Start a configuration node.- Parameters:
tagName
- Tag name.attrs
- Tag attributes.
-
characters
public void characters(char[] chars, int start, int len)
- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classDefaultHandler
- Parameters:
chars
-start
-len
-- See Also:
ContentHandler
-
endElementBuilder
public Element endElementBuilder()
End a configuration node.- Returns:
- The configuration.
-
getParent
public Object getParent()
-
getParser
public SAXParser getParser()
-
getParent
public Object getParent(int index)
-
removeParent
public Object removeParent()
-
getParents
public Collection getParents()
-
getPeer
public Object getPeer()
-
getCurrent
public Object getCurrent()
-
resolveEntity
public InputSource resolveEntity(String publicId, String systemId) throws SAXException
- Specified by:
resolveEntity
in interfaceEntityResolver
- Overrides:
resolveEntity
in classDefaultHandler
- Throws:
SAXException
-
startPrefixMapping
public void startPrefixMapping(String prefix, String uri) throws SAXException
- Specified by:
startPrefixMapping
in interfaceContentHandler
- Overrides:
startPrefixMapping
in classDefaultHandler
- Throws:
SAXException
-
endPrefixMapping
public void endPrefixMapping(String prefix) throws SAXException
- Specified by:
endPrefixMapping
in interfaceContentHandler
- Overrides:
endPrefixMapping
in classDefaultHandler
- Throws:
SAXException
-
buildPrintMessage
protected String buildPrintMessage(SAXParseException x)
-
warning
public void warning(SAXParseException x)
- Specified by:
warning
in interfaceErrorHandler
- Overrides:
warning
in classDefaultHandler
-
error
public void error(SAXParseException x)
- Specified by:
error
in interfaceErrorHandler
- Overrides:
error
in classDefaultHandler
-
fatalError
public void fatalError(SAXParseException x) throws SAXParseException
- Specified by:
fatalError
in interfaceErrorHandler
- Overrides:
fatalError
in classDefaultHandler
- Throws:
SAXParseException
-
getTimeout
public int getTimeout()
Timeout for retrieving remote resources- Returns:
-
setTimeout
public void setTimeout(int timeout)
Sets the timeout for retrieving remote resources, e.g. xsd schemas- Parameters:
timeout
-
-
getAttrs
public Attributes getAttrs()
-
setParser
public void setParser(SAXParser parser)
-
-