public abstract class VerifierImpl extends Object implements Verifier
Verifier.
This class is useful as the base class of the verifier implementation.
The only remaining method that has to be implemented by the derived class is
the getVerifierHandler method. Please be noted that applications
can call the setErrorHandler method after the
getVerifierHandler method and that change should take effect.
| Modifier and Type | Field and Description |
|---|---|
protected EntityResolver |
entityResolver |
protected ErrorHandler |
errorHandler |
protected XMLReader |
reader |
FEATURE_FILTER, FEATURE_HANDLER| Modifier | Constructor and Description |
|---|---|
protected |
VerifierImpl() |
| Modifier and Type | Method and Description |
|---|---|
Object |
getProperty(String property)
Gets a property value
This method is modeled after SAX2.
|
VerifierFilter |
getVerifierFilter()
Gets a VerifierFilter.
|
abstract VerifierHandler |
getVerifierHandler()
Gets a VerifierHandler.
|
boolean |
isFeature(String feature)
Checks whether a feature is supported or not.
|
protected void |
prepareXMLReader()
Creates and sets a sole instance of XMLReader which will be used by this
verifier.
|
void |
setEntityResolver(EntityResolver resolver)
Sets a
EntityResolver to resolve external entity locations. |
void |
setErrorHandler(ErrorHandler handler)
Sets a
ErrorHandler that receives validation errors/warnings. |
void |
setFeature(String feature,
boolean value)
Sets a value to a feature.
|
void |
setProperty(String property,
Object value)
Sets a property value
This method is modeled after SAX2.
|
boolean |
verify(File f)
validates an XML document.
|
boolean |
verify(InputSource source)
validates an XML document.
|
boolean |
verify(Node node)
validates an XML document.
|
boolean |
verify(String uri)
validates an XML document.
|
protected XMLReader reader
protected ErrorHandler errorHandler
protected EntityResolver entityResolver
protected VerifierImpl()
throws VerifierConfigurationException
VerifierConfigurationExceptionprotected void prepareXMLReader()
throws VerifierConfigurationException
VerifierConfigurationExceptionpublic boolean isFeature(String feature) throws SAXNotRecognizedException, SAXNotSupportedException
VerifierThis method is modeled after SAX2.
isFeature in interface Verifierfeature - feature nameSAXNotRecognizedExceptionSAXNotSupportedExceptionpublic void setFeature(String feature, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException
VerifierThis method is modeled after SAX2.
setFeature in interface Verifierfeature - feature namevalue - feature valueSAXNotRecognizedExceptionSAXNotSupportedExceptionpublic Object getProperty(String property) throws SAXNotRecognizedException, SAXNotSupportedException
VerifierThis method is modeled after SAX2.
getProperty in interface Verifierproperty - property nameSAXNotRecognizedExceptionSAXNotSupportedExceptionpublic void setProperty(String property, Object value) throws SAXNotRecognizedException, SAXNotSupportedException
VerifierThis method is modeled after SAX2.
setProperty in interface Verifierproperty - property namevalue - property valueSAXNotRecognizedExceptionSAXNotSupportedExceptionpublic void setErrorHandler(ErrorHandler handler)
VerifierErrorHandler that receives validation errors/warnings.
If no error handler is set explicitly, a verifier implementation will not report any error/warning at all. However, the caller can still obtain the result of validation through the return value.
Conscious developers should always set an error handler explicitly as the default behavior has been changed several times.
setErrorHandler in interface Verifierhandler - this object will receive errors/warning encountered during the
validation.public void setEntityResolver(EntityResolver resolver)
VerifierEntityResolver to resolve external entity locations.
The given entity resolver is used in the Verifier.verify(String) method and
the Verifier.verify(InputSource) method.
setEntityResolver in interface Verifierresolver - EntityResolverpublic boolean verify(String uri) throws SAXException, IOException
Verifierverify in interface Verifieruri - URI of a document.SAXExceptionIOExceptionpublic boolean verify(InputSource source) throws SAXException, IOException
Verifierverify in interface Verifiersource - InputSource of a XML document to verify.SAXExceptionIOExceptionpublic boolean verify(File f) throws SAXException, IOException
Verifierverify in interface Verifierf - File to be validatedSAXExceptionIOExceptionpublic boolean verify(Node node) throws SAXException
Verifier
An implementation is required to accept Document object as the
node parameter. If it also implements partial validation, it can also
accepts things like Element.
verify in interface Verifiernode - the root DOM node of an XML document.SAXExceptionpublic abstract VerifierHandler getVerifierHandler() throws SAXException
Verifier
you can use the returned VerifierHandler to validate documents
through SAX.
Note that two different invocations of this method can return the same
value; this method does NOT necessarily create a new
VerifierHandler object.
getVerifierHandler in interface VerifierSAXExceptionpublic VerifierFilter getVerifierFilter() throws SAXException
Verifier
you can use the returned VerifierHandler to validate documents
through SAX.
Note that two different invocations of this method can return the same
value; this method does NOT necessarily create a new
VerifierFilter object.
getVerifierFilter in interface VerifierSAXExceptionCopyright © 2016 Philip Helger. All rights reserved.