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
RuleSetloader. Note you can override the default entity resolver by setting the System property of:org.kie.api.io.EntityResolveto 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 classExtensibleXmlParser.Null
-
Field Summary
Fields Modifier and Type Field Description static StringENTITY_RESOLVER_PROPERTY_NAMEprotected static org.slf4j.Loggerloggerstatic StringRULES_NAMESPACE_URINamespace 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 StringbuildPrintMessage(SAXParseException x)voidcharacters(char[] chars, int start, int len)voidendElement(String uri, String localName, String qname)ElementendElementBuilder()End a configuration node.voidendPrefixMapping(String prefix)voiderror(SAXParseException x)voidfatalError(SAXParseException x)AttributesgetAttrs()ClassLoadergetClassLoader()ObjectgetCurrent()ObjectgetData()LocatorgetLocator()Get theLocator.MapgetMetaData()ObjectgetNamespaceURI(String namespace)ObjectgetParent()ObjectgetParent(int index)ObjectgetParent(Class parent)CollectiongetParents()SAXParsergetParser()ObjectgetPeer()intgetTimeout()Timeout for retrieving remote resourcesObjectread(InputStream inputStream)Read aRuleSetfrom anInputStream.Objectread(Reader reader)Read aRuleSetfrom aReader.Objectread(InputSource in)Read aRuleSetfrom anInputSource.ObjectremoveParent()InputSourceresolveEntity(String publicId, String systemId)voidsetClassLoader(ClassLoader classLoader)voidsetData(Object data)voidsetDocumentLocator(Locator locator)voidsetParser(SAXParser parser)voidsetSemanticModules(SemanticModules modules)voidsetTimeout(int timeout)Sets the timeout for retrieving remote resources, e.g. xsd schemasvoidstartDocument()voidstartElement(String uri, String localName, String qname, Attributes attrs)voidstartElementBuilder(String tagName, Attributes attrs)Start a configuration node.voidstartPrefixMapping(String prefix, String uri)voidwarning(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 aRuleSetfrom aReader.- Parameters:
reader- The reader containing the rule-set.- Returns:
- The rule-set.
- Throws:
ParserConfigurationExceptionSAXExceptionIOException
-
read
public Object read(InputStream inputStream) throws SAXException, IOException
Read aRuleSetfrom anInputStream.- Parameters:
inputStream- The input-stream containing the rule-set.- Returns:
- The rule-set.
- Throws:
ParserConfigurationExceptionSAXExceptionIOException
-
read
public Object read(InputSource in) throws SAXException, IOException
Read aRuleSetfrom anInputSource.- Parameters:
in- The rule-set input-source.- Returns:
- The rule-set.
- Throws:
ParserConfigurationExceptionSAXExceptionIOException
-
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:
setDocumentLocatorin interfaceContentHandler- Overrides:
setDocumentLocatorin classDefaultHandler- See Also:
ContentHandler
-
getLocator
public Locator getLocator()
Get theLocator.- Returns:
- The locator.
-
startDocument
public void startDocument()
- Specified by:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin classDefaultHandler
-
startElement
public void startElement(String uri, String localName, String qname, Attributes attrs) throws SAXException
- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin 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:
endElementin interfaceContentHandler- Overrides:
endElementin 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:
charactersin interfaceContentHandler- Overrides:
charactersin 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:
resolveEntityin interfaceEntityResolver- Overrides:
resolveEntityin classDefaultHandler- Throws:
SAXException
-
startPrefixMapping
public void startPrefixMapping(String prefix, String uri) throws SAXException
- Specified by:
startPrefixMappingin interfaceContentHandler- Overrides:
startPrefixMappingin classDefaultHandler- Throws:
SAXException
-
endPrefixMapping
public void endPrefixMapping(String prefix) throws SAXException
- Specified by:
endPrefixMappingin interfaceContentHandler- Overrides:
endPrefixMappingin classDefaultHandler- Throws:
SAXException
-
buildPrintMessage
protected String buildPrintMessage(SAXParseException x)
-
warning
public void warning(SAXParseException x)
- Specified by:
warningin interfaceErrorHandler- Overrides:
warningin classDefaultHandler
-
error
public void error(SAXParseException x)
- Specified by:
errorin interfaceErrorHandler- Overrides:
errorin classDefaultHandler
-
fatalError
public void fatalError(SAXParseException x) throws SAXParseException
- Specified by:
fatalErrorin interfaceErrorHandler- Overrides:
fatalErrorin 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)
-
-