Interface Verifier
-
- All Known Implementing Classes:
VerifierImpl
public interface VerifierAn instance of this interface can validates documents.An instance of this interface can be obtained through the
VerifierFactory.newVerifier(java.lang.String)method orSchema.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.
- Since:
- Feb. 23, 2001
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringFEATURE_FILTERDeprecated.static java.lang.StringFEATURE_HANDLERDeprecated.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.ObjectgetProperty(java.lang.String property)Gets a property valueVerifierFiltergetVerifierFilter()Gets a VerifierFilter.VerifierHandlergetVerifierHandler()Gets a VerifierHandler.booleanisFeature(java.lang.String feature)Checks whether a feature is supported or not.voidsetEntityResolver(org.xml.sax.EntityResolver handler)Sets aEntityResolverto resolve external entity locations.voidsetErrorHandler(org.xml.sax.ErrorHandler handler)Sets aErrorHandlerthat receives validation errors/warnings.voidsetFeature(java.lang.String feature, boolean value)Sets a value to a feature.voidsetProperty(java.lang.String property, java.lang.Object value)Sets a property valuebooleanverify(java.io.File file)validates an XML document.booleanverify(java.lang.String uri)validates an XML document.booleanverify(org.w3c.dom.Node node)validates an XML document.booleanverify(org.xml.sax.InputSource source)validates an XML document.
-
-
-
Field Detail
-
FEATURE_HANDLER
static final java.lang.String FEATURE_HANDLER
Deprecated.a read-only feature that checks whether the implementation supportsgetVerifierHandlermethod.Now a verifier implementation is required to support VerifierHandler. Therefore an application doesn't need to check this feature.
- See Also:
- Constant Field Values
-
FEATURE_FILTER
static final java.lang.String FEATURE_FILTER
Deprecated.a read-only feature that checks whether the implementation supportsgetVerifierFiltermethod.Now a verifier implementation is required to support VerifierFilter. Therefore an application doesn't need to check this feature.
- See Also:
- Constant Field Values
-
-
Method Detail
-
isFeature
boolean isFeature(java.lang.String feature) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionChecks whether a feature is supported or not.This method is modeled after SAX2.
- Parameters:
feature- feature name- Throws:
org.xml.sax.SAXNotRecognizedExceptionorg.xml.sax.SAXNotSupportedException
-
setFeature
void setFeature(java.lang.String feature, boolean value) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionSets a value to a feature.This method is modeled after SAX2.
- Parameters:
feature- feature namevalue- feature value- Throws:
org.xml.sax.SAXNotRecognizedExceptionorg.xml.sax.SAXNotSupportedException
-
getProperty
java.lang.Object getProperty(java.lang.String property) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionGets a property valueThis method is modeled after SAX2.
- Parameters:
property- property name- Throws:
org.xml.sax.SAXNotRecognizedExceptionorg.xml.sax.SAXNotSupportedException
-
setProperty
void setProperty(java.lang.String property, java.lang.Object value) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionSets a property valueThis method is modeled after SAX2.
- Parameters:
property- property namevalue- property value- Throws:
org.xml.sax.SAXNotRecognizedExceptionorg.xml.sax.SAXNotSupportedException
-
setErrorHandler
void setErrorHandler(org.xml.sax.ErrorHandler handler)
Sets aErrorHandlerthat 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.
- Parameters:
handler- this object will receive errors/warning encountered during the validation.
-
setEntityResolver
void setEntityResolver(org.xml.sax.EntityResolver handler)
Sets aEntityResolverto resolve external entity locations.The given entity resolver is used in the
verify(java.lang.String)method and theverify(org.xml.sax.InputSource)method.- Parameters:
handler- EntityResolver
-
verify
boolean verify(java.lang.String uri) throws org.xml.sax.SAXException, java.io.IOExceptionvalidates an XML document.- Parameters:
uri- URI of a document.- Returns:
- true if the document is valid. false if otherwise.
- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
verify
boolean verify(org.xml.sax.InputSource source) throws org.xml.sax.SAXException, java.io.IOExceptionvalidates an XML document.- Parameters:
source- InputSource of a XML document to verify.- Returns:
- true if the document is valid. false if otherwise.
- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
verify
boolean verify(java.io.File file) throws org.xml.sax.SAXException, java.io.IOExceptionvalidates an XML document.- Parameters:
file- File to be validated- Returns:
- true if the document is valid. false if otherwise.
- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
verify
boolean verify(org.w3c.dom.Node node) throws org.xml.sax.SAXExceptionvalidates an XML document.An implementation is required to accept
Documentobject as the node parameter. If it also implements partial validation, it can also accepts things likeElement.- Parameters:
node- the root DOM node of an XML document.- Returns:
- true if the document is valid. false if otherwise.
- Throws:
java.lang.UnsupportedOperationException- If the node type of the node parameter is something which this implementation does not support.org.xml.sax.SAXException
-
getVerifierHandler
VerifierHandler getVerifierHandler() throws org.xml.sax.SAXException
Gets a VerifierHandler.you can use the returned
VerifierHandlerto 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
VerifierHandlerobject.- Throws:
org.xml.sax.SAXException
-
getVerifierFilter
VerifierFilter getVerifierFilter() throws org.xml.sax.SAXException
Gets a VerifierFilter.you can use the returned
VerifierHandlerto 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
VerifierFilterobject.- Throws:
org.xml.sax.SAXException
-
-