public class SAXEntityParser extends Object implements XMLReader
Default implementation cannot be used for parsing of XML document entities! It wraps client's parser that it actually used for performing the parsing task.
Primary use case (parse general entity):
XMLReader entityParser = new SAXEntityParser(xmlReader); entityParser.setErrorHandler(errorHandler); entityParser.parse(inputSource);Secondary use case (delegating parser): It requires subclassing and allow subclass entirely define internal wrapping logic. Warning: Implementation gurantees only proper ErrorHandler callbacks.
Constructor and Description |
---|
SAXEntityParser(XMLReader peer)
Creates a new instance of general entity parser.
|
SAXEntityParser(XMLReader peer,
boolean generalEntity)
Creates a new instance of SAXEntityParser.
|
Modifier and Type | Method and Description |
---|---|
ContentHandler |
getContentHandler() |
DTDHandler |
getDTDHandler() |
EntityResolver |
getEntityResolver() |
ErrorHandler |
getErrorHandler() |
boolean |
getFeature(String name) |
Object |
getProperty(String name) |
void |
parse(InputSource entity)
Start entity parsing using peer parser.
|
void |
parse(String sid) |
protected boolean |
propagateException(SAXParseException ex)
Examine if the exception should be propagated into client's
ErrorHandler . |
void |
setContentHandler(ContentHandler contentHandler) |
void |
setDTDHandler(DTDHandler dTDHandler) |
void |
setEntityResolver(EntityResolver entityResolver) |
void |
setErrorHandler(ErrorHandler errorHandler) |
void |
setFeature(String name,
boolean val) |
void |
setProperty(String name,
Object val) |
protected InputSource |
wrapInputSource(InputSource input)
Create wrapper input source.
|
public SAXEntityParser(XMLReader peer)
peer
- parser that will be used for parsing. Wrapped parser is
exclusively owned by this class no other clients can share it.public SAXEntityParser(XMLReader peer, boolean generalEntity)
peer
- parser that will be used for parsinggeneralEntity
- if false
treat entity as parameter
entity (i.e. DTD entities).public void parse(InputSource entity) throws IOException, SAXException
parse
in interface XMLReader
entity
- entity input sourceIOException
SAXException
protected InputSource wrapInputSource(InputSource input)
EntityResolver
redirects the first query to wrapped
InputSource
.input
- InputSource to be wrapped.protected boolean propagateException(SAXParseException ex)
ErrorHandler
.ex
- examined exceptiontrue
if the exception originates from client's
InputSource
and should be propagated.public ContentHandler getContentHandler()
getContentHandler
in interface XMLReader
public DTDHandler getDTDHandler()
getDTDHandler
in interface XMLReader
public EntityResolver getEntityResolver()
getEntityResolver
in interface XMLReader
public ErrorHandler getErrorHandler()
getErrorHandler
in interface XMLReader
public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException
getFeature
in interface XMLReader
SAXNotRecognizedException
SAXNotSupportedException
public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException
getProperty
in interface XMLReader
SAXNotRecognizedException
SAXNotSupportedException
public void parse(String sid) throws IOException, SAXException
parse
in interface XMLReader
IOException
SAXException
public void setContentHandler(ContentHandler contentHandler)
setContentHandler
in interface XMLReader
public void setDTDHandler(DTDHandler dTDHandler)
setDTDHandler
in interface XMLReader
public void setEntityResolver(EntityResolver entityResolver)
setEntityResolver
in interface XMLReader
public void setErrorHandler(ErrorHandler errorHandler)
setErrorHandler
in interface XMLReader
public void setFeature(String name, boolean val) throws SAXNotRecognizedException, SAXNotSupportedException
setFeature
in interface XMLReader
SAXNotRecognizedException
SAXNotSupportedException
public void setProperty(String name, Object val) throws SAXNotRecognizedException, SAXNotSupportedException
setProperty
in interface XMLReader
SAXNotRecognizedException
SAXNotSupportedException