public interface Verifier
An instance of this interface can be obtained through the
VerifierFactory.newVerifier(java.lang.String) method or Schema.newVerifier()
method. Once it is created, an application can use one instance to validate
multiple documents.
This interface is not thread-safe and not reentrant. That is, only one thread can use it at any given time, and you can only validate one document at any given time.
| Modifier and Type | Field and Description |
|---|---|
static String |
FEATURE_FILTER
Deprecated.
|
static String |
FEATURE_HANDLER
Deprecated.
|
| 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.
|
VerifierHandler |
getVerifierHandler()
Gets a VerifierHandler.
|
boolean |
isFeature(String feature)
Checks whether a feature is supported or not.
|
void |
setEntityResolver(EntityResolver handler)
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 file)
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.
|
@Deprecated static final String FEATURE_HANDLER
getVerifierHandler method.
Now a verifier implementation is required to support VerifierHandler. Therefore an application doesn't need to check this feature.
@Deprecated static final String FEATURE_FILTER
getVerifierFilter method.
Now a verifier implementation is required to support VerifierFilter. Therefore an application doesn't need to check this feature.
boolean isFeature(String feature) throws SAXNotRecognizedException, SAXNotSupportedException
This method is modeled after SAX2.
feature - feature nameSAXNotRecognizedExceptionSAXNotSupportedExceptionvoid setFeature(String feature, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException
This method is modeled after SAX2.
feature - feature namevalue - feature valueSAXNotRecognizedExceptionSAXNotSupportedExceptionObject getProperty(String property) throws SAXNotRecognizedException, SAXNotSupportedException
This method is modeled after SAX2.
property - property nameSAXNotRecognizedExceptionSAXNotSupportedExceptionvoid setProperty(String property, Object value) throws SAXNotRecognizedException, SAXNotSupportedException
This method is modeled after SAX2.
property - property namevalue - property valueSAXNotRecognizedExceptionSAXNotSupportedExceptionvoid setErrorHandler(ErrorHandler handler)
ErrorHandler 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.
handler - this object will receive errors/warning encountered during the
validation.void setEntityResolver(EntityResolver handler)
EntityResolver to resolve external entity locations.
The given entity resolver is used in the verify(String) method and
the verify(InputSource) method.
handler - EntityResolverboolean verify(String uri) throws SAXException, IOException
uri - URI of a document.SAXExceptionIOExceptionboolean verify(InputSource source) throws SAXException, IOException
source - InputSource of a XML document to verify.SAXExceptionIOExceptionboolean verify(File file) throws SAXException, IOException
file - File to be validatedSAXExceptionIOExceptionboolean verify(Node node) throws SAXException
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.
node - the root DOM node of an XML document.UnsupportedOperationException - If the node type of the node parameter is something which this
implementation does not support.SAXExceptionVerifierHandler getVerifierHandler() throws SAXException
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.
SAXExceptionVerifierFilter getVerifierFilter() throws SAXException
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.
SAXExceptionCopyright © 2016 Philip Helger. All rights reserved.