java.lang.Object
org.xbib.content.xml.stream.StaxEventXMLReader
- All Implemented Interfaces:
XMLReader
SAX
XMLReader that reads from a StAX XMLEventReader.
Consumes XMLEvents from
an XMLEventReader, and calls the corresponding methods on the SAX callback interfaces.-
Constructor Summary
ConstructorsConstructorDescriptionStaxEventXMLReader(XMLEventReader reader) Constructs a new instance of theStaxEventXmlReaderthat reads from the givenXMLEventReader. -
Method Summary
Modifier and TypeMethodDescriptionbooleangetFeature(String name) Throws aSAXNotRecognizedExceptionexception.protected LexicalHandlergetProperty(String name) Throws aSAXNotRecognizedExceptionexception when the given property does not signify a lexical handler.protected booleanIndicates whether the SAX featurehttp://xml.org/sax/features/namespaces-prefixesis turned on.protected booleanIndicates whether the SAX featurehttp://xml.org/sax/features/namespacesis turned on.final voidParse the StAX XML reader passed at construction-time.final voidparse(InputSource ignored) Parse the StAX XML reader passed at construction-time.protected voidTemplate-method that parses the StAX reader passed at construction-time.voidsetContentHandler(ContentHandler contentHandler) voidsetDTDHandler(DTDHandler dtdHandler) voidsetEntityResolver(EntityResolver entityResolver) voidsetErrorHandler(ErrorHandler errorHandler) voidsetFeature(String name, boolean value) Throws aSAXNotRecognizedExceptionexception.protected voidsetLocator(Location location) Sett the SAXLocatorbased on the given StAXLocation.voidsetProperty(String name, Object value) Throws aSAXNotRecognizedExceptionexception when the given property does not signify a lexical handler.protected voidsetStandalone(boolean standalone) protected StringtoQualifiedName(QName qName) Convert aQNameto a qualified name, as used by DOM and SAX.
-
Constructor Details
-
StaxEventXMLReader
Constructs a new instance of theStaxEventXmlReaderthat reads from the givenXMLEventReader. The supplied event reader must be inXMLStreamConstants.START_DOCUMENTorXMLStreamConstants.START_ELEMENTstate.- Parameters:
reader- theXMLEventReaderto read from- Throws:
IllegalStateException- if the reader is not at the start of a document or element
-
-
Method Details
-
parseInternal
Template-method that parses the StAX reader passed at construction-time.- Throws:
SAXException- A SAX exception, possibly wrapping aXMLStreamExceptionXMLStreamException- if XML stream can not be processed
-
getFeature
Throws aSAXNotRecognizedExceptionexception.- Specified by:
getFeaturein interfaceXMLReader- Throws:
SAXNotRecognizedException- alwaysSAXNotSupportedException
-
setFeature
public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException Throws aSAXNotRecognizedExceptionexception.- Specified by:
setFeaturein interfaceXMLReader- Throws:
SAXNotRecognizedException- alwaysSAXNotSupportedException
-
setStandalone
protected void setStandalone(boolean standalone) -
hasNamespacesFeature
protected boolean hasNamespacesFeature()Indicates whether the SAX featurehttp://xml.org/sax/features/namespacesis turned on.- Returns:
- true if namespaces are featured
-
hasNamespacePrefixesFeature
protected boolean hasNamespacePrefixesFeature()Indicates whether the SAX featurehttp://xml.org/sax/features/namespaces-prefixesis turned on.- Returns:
- true if namespace prefixes are featured
-
setLocator
Sett the SAXLocatorbased on the given StAXLocation.- Parameters:
location- the location- See Also:
-
toQualifiedName
Convert aQNameto a qualified name, as used by DOM and SAX. The returned string has a format ofprefix:localNameif the prefix is set, or justlocalNameif not.- Parameters:
qName- theQName- Returns:
- the qualified name
-
parse
Parse the StAX XML reader passed at construction-time.NOTE:: The given
InputSourceis not read, but ignored.- Parameters:
ignored- is ignored- Throws:
SAXException- a SAX exception, possibly wrapping aXMLStreamException
-
parse
Parse the StAX XML reader passed at construction-time.NOTE:: The given system identifier is not read, but ignored.
- Parameters:
ignored- is ignored- Throws:
SAXException- A SAX exception, possibly wrapping aXMLStreamException
-
getContentHandler
- Specified by:
getContentHandlerin interfaceXMLReader
-
setContentHandler
- Specified by:
setContentHandlerin interfaceXMLReader
-
getDTDHandler
- Specified by:
getDTDHandlerin interfaceXMLReader
-
setDTDHandler
- Specified by:
setDTDHandlerin interfaceXMLReader
-
getEntityResolver
- Specified by:
getEntityResolverin interfaceXMLReader
-
setEntityResolver
- Specified by:
setEntityResolverin interfaceXMLReader
-
getErrorHandler
- Specified by:
getErrorHandlerin interfaceXMLReader
-
setErrorHandler
- Specified by:
setErrorHandlerin interfaceXMLReader
-
getLexicalHandler
-
getProperty
Throws aSAXNotRecognizedExceptionexception when the given property does not signify a lexical handler. The property name for a lexical handler ishttp://xml.org/sax/properties/lexical-handler.- Specified by:
getPropertyin interfaceXMLReader- Throws:
SAXNotRecognizedExceptionSAXNotSupportedException
-
setProperty
public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException Throws aSAXNotRecognizedExceptionexception when the given property does not signify a lexical handler. The property name for a lexical handler ishttp://xml.org/sax/properties/lexical-handler.- Specified by:
setPropertyin interfaceXMLReader- Throws:
SAXNotRecognizedExceptionSAXNotSupportedException
-