Class VerifierImpl
- java.lang.Object
-
- org.iso_relax.verifier.impl.VerifierImpl
-
- All Implemented Interfaces:
Verifier
public abstract class VerifierImpl extends Object implements Verifier
Partial implementation ofVerifier
.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 thesetErrorHandler
method after thegetVerifierHandler
method and that change should take effect.
-
-
Field Summary
Fields Modifier and Type Field Description protected EntityResolver
entityResolver
protected ErrorHandler
errorHandler
protected XMLReader
reader
-
Fields inherited from interface org.iso_relax.verifier.Verifier
FEATURE_FILTER, FEATURE_HANDLER
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
VerifierImpl()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Object
getProperty(String property)
Gets a property valueVerifierFilter
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 aEntityResolver
to resolve external entity locations.void
setErrorHandler(ErrorHandler handler)
Sets aErrorHandler
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 valueboolean
verify(File f)
validates an XML document.boolean
verify(String uri)
validates an XML document.boolean
verify(Node node)
validates an XML document.boolean
verify(InputSource source)
validates an XML document.
-
-
-
Field Detail
-
reader
protected XMLReader reader
-
errorHandler
protected ErrorHandler errorHandler
-
entityResolver
protected EntityResolver entityResolver
-
-
Constructor Detail
-
VerifierImpl
protected VerifierImpl() throws VerifierConfigurationException
- Throws:
VerifierConfigurationException
-
-
Method Detail
-
prepareXMLReader
protected void prepareXMLReader() throws VerifierConfigurationException
Creates and sets a sole instance of XMLReader which will be used by this verifier.- Throws:
VerifierConfigurationException
-
isFeature
public boolean isFeature(String feature) throws SAXNotRecognizedException, SAXNotSupportedException
Description copied from interface:Verifier
Checks whether a feature is supported or not.This method is modeled after SAX2.
- Specified by:
isFeature
in interfaceVerifier
- Parameters:
feature
- feature name- Throws:
SAXNotRecognizedException
SAXNotSupportedException
-
setFeature
public void setFeature(String feature, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException
Description copied from interface:Verifier
Sets a value to a feature.This method is modeled after SAX2.
- Specified by:
setFeature
in interfaceVerifier
- Parameters:
feature
- feature namevalue
- feature value- Throws:
SAXNotRecognizedException
SAXNotSupportedException
-
getProperty
public Object getProperty(String property) throws SAXNotRecognizedException, SAXNotSupportedException
Description copied from interface:Verifier
Gets a property valueThis method is modeled after SAX2.
- Specified by:
getProperty
in interfaceVerifier
- Parameters:
property
- property name- Throws:
SAXNotRecognizedException
SAXNotSupportedException
-
setProperty
public void setProperty(String property, Object value) throws SAXNotRecognizedException, SAXNotSupportedException
Description copied from interface:Verifier
Sets a property valueThis method is modeled after SAX2.
- Specified by:
setProperty
in interfaceVerifier
- Parameters:
property
- property namevalue
- property value- Throws:
SAXNotRecognizedException
SAXNotSupportedException
-
setErrorHandler
public void setErrorHandler(ErrorHandler handler)
Description copied from interface:Verifier
Sets aErrorHandler
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.
- Specified by:
setErrorHandler
in interfaceVerifier
- Parameters:
handler
- this object will receive errors/warning encountered during the validation.
-
setEntityResolver
public void setEntityResolver(EntityResolver resolver)
Description copied from interface:Verifier
Sets aEntityResolver
to resolve external entity locations.The given entity resolver is used in the
Verifier.verify(java.lang.String)
method and theVerifier.verify(org.xml.sax.InputSource)
method.- Specified by:
setEntityResolver
in interfaceVerifier
- Parameters:
resolver
- EntityResolver
-
verify
public boolean verify(String uri) throws SAXException, IOException
Description copied from interface:Verifier
validates an XML document.- Specified by:
verify
in interfaceVerifier
- Parameters:
uri
- URI of a document.- Returns:
- true if the document is valid. false if otherwise.
- Throws:
SAXException
IOException
-
verify
public boolean verify(InputSource source) throws SAXException, IOException
Description copied from interface:Verifier
validates an XML document.- Specified by:
verify
in interfaceVerifier
- Parameters:
source
- InputSource of a XML document to verify.- Returns:
- true if the document is valid. false if otherwise.
- Throws:
SAXException
IOException
-
verify
public boolean verify(File f) throws SAXException, IOException
Description copied from interface:Verifier
validates an XML document.- Specified by:
verify
in interfaceVerifier
- Parameters:
f
- File to be validated- Returns:
- true if the document is valid. false if otherwise.
- Throws:
SAXException
IOException
-
verify
public boolean verify(Node node) throws SAXException
Description copied from interface:Verifier
validates an XML document.An implementation is required to accept
Document
object as the node parameter. If it also implements partial validation, it can also accepts things likeElement
.- Specified by:
verify
in interfaceVerifier
- Parameters:
node
- the root DOM node of an XML document.- Returns:
- true if the document is valid. false if otherwise.
- Throws:
SAXException
-
getVerifierHandler
public abstract VerifierHandler getVerifierHandler() throws SAXException
Description copied from interface:Verifier
Gets a VerifierHandler.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.- Specified by:
getVerifierHandler
in interfaceVerifier
- Throws:
SAXException
-
getVerifierFilter
public VerifierFilter getVerifierFilter() throws SAXException
Description copied from interface:Verifier
Gets a VerifierFilter.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.- Specified by:
getVerifierFilter
in interfaceVerifier
- Throws:
SAXException
-
-