org.iso_relax.verifier.impl
Class VerifierImpl

java.lang.Object
  |
  +--org.iso_relax.verifier.impl.VerifierImpl
All Implemented Interfaces:
Verifier

public abstract class VerifierImpl
extends java.lang.Object
implements Verifier

Partial implementation of 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.

Version:
$Id: VerifierImpl.java,v 1.4 2003/05/30 23:46:33 kkawa Exp $
Author:
Kohsuke KAWAGUCHI

Field Summary
protected  EntityResolver entityResolver
           
protected  ErrorHandler errorHandler
           
protected  XMLReader reader
           
 
Fields inherited from interface org.iso_relax.verifier.Verifier
FEATURE_FILTER, FEATURE_HANDLER
 
Constructor Summary
protected VerifierImpl()
           
 
Method Summary
 java.lang.Object getProperty(java.lang.String property)
          Gets a property value
 VerifierFilter getVerifierFilter()
          Gets a VerifierFilter.
abstract  VerifierHandler getVerifierHandler()
          Gets a VerifierHandler.
 boolean isFeature(java.lang.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(java.lang.String feature, boolean value)
          Sets a value to a feature.
 void setProperty(java.lang.String property, java.lang.Object value)
          Sets a property value
 boolean verify(java.io.File f)
          validates an XML document.
 boolean verify(InputSource source)
          validates an XML document.
 boolean verify(Node node)
          validates an XML document.
 boolean verify(java.lang.String uri)
          validates an XML document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reader

protected XMLReader reader

errorHandler

protected ErrorHandler errorHandler

entityResolver

protected EntityResolver entityResolver
Constructor Detail

VerifierImpl

protected VerifierImpl()
                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.

VerifierConfigurationException

isFeature

public boolean isFeature(java.lang.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 interface Verifier
Parameters:
feature - feature name
SAXNotRecognizedException
SAXNotSupportedException

setFeature

public void setFeature(java.lang.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 interface Verifier
Parameters:
feature - feature name
value - feature value
SAXNotRecognizedException
SAXNotSupportedException

getProperty

public java.lang.Object getProperty(java.lang.String property)
                             throws SAXNotRecognizedException,
                                    SAXNotSupportedException
Description copied from interface: Verifier
Gets a property value

This method is modeled after SAX2.

Specified by:
getProperty in interface Verifier
Parameters:
property - property name
SAXNotRecognizedException
SAXNotSupportedException

setProperty

public void setProperty(java.lang.String property,
                        java.lang.Object value)
                 throws SAXNotRecognizedException,
                        SAXNotSupportedException
Description copied from interface: Verifier
Sets a property value

This method is modeled after SAX2.

Specified by:
setProperty in interface Verifier
Parameters:
property - property name
value - property value
SAXNotRecognizedException
SAXNotSupportedException

setErrorHandler

public void setErrorHandler(ErrorHandler handler)
Description copied from interface: Verifier
Sets a 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.

Specified by:
setErrorHandler in interface Verifier
Parameters:
handler - this object will receive errors/warning encountered during the validation.

setEntityResolver

public void setEntityResolver(EntityResolver resolver)
Description copied from interface: Verifier
Sets a EntityResolver to resolve external entity locations.

The given entity resolver is used in the Verifier.verify(String) method and the Verifier.verify(InputSource) method.

Specified by:
setEntityResolver in interface Verifier
Parameters:
resolver - EntityResolver

verify

public boolean verify(java.lang.String uri)
               throws SAXException,
                      java.io.IOException
Description copied from interface: Verifier
validates an XML document.

Specified by:
verify in interface Verifier
Parameters:
uri - URI of a document.
Returns:
true if the document is valid. false if otherwise.
SAXException
java.io.IOException

verify

public boolean verify(InputSource source)
               throws SAXException,
                      java.io.IOException
Description copied from interface: Verifier
validates an XML document.

Specified by:
verify in interface Verifier
Parameters:
source - InputSource of a XML document to verify.
Returns:
true if the document is valid. false if otherwise.
SAXException
java.io.IOException

verify

public boolean verify(java.io.File f)
               throws SAXException,
                      java.io.IOException
Description copied from interface: Verifier
validates an XML document.

Specified by:
verify in interface Verifier
Parameters:
f - File to be validated
Returns:
true if the document is valid. false if otherwise.
SAXException
java.io.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 like Element.

Specified by:
verify in interface Verifier
Parameters:
node - the root DOM node of an XML document.
Returns:
true if the document is valid. false if otherwise.
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 interface Verifier
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 interface Verifier
SAXException