Home » xml-commons-external-1.4.01-src » javax » xml » validation » [javadoc | source]
javax.xml.validation
abstract public class: ValidatorHandler [javadoc | source]
java.lang.Object
   javax.xml.validation.ValidatorHandler

All Implemented Interfaces:
    ContentHandler

Streaming validator that works on SAX stream.

A ValidatorHandler object is a thread-unsafe, non-reentrant object. In other words, it is the application's responsibility to make sure that one ValidatorHandler object is not used from more than one thread at any given time.

ValidatorHandler checks if the SAX events follow the set of constraints described in the associated Schema , and additionally it may modify the SAX events (for example by adding default values, etc.)

ValidatorHandler extends from ContentHandler , but it refines the underlying ContentHandler in the following way:

  1. startElement/endElement events must receive non-null String for uri, localName, and qname, even though SAX allows some of them to be null. Similarly, the user-specified ContentHandler will receive non-null Strings for all three parameters.
  2. Applications must ensure that ValidatorHandler 's ContentHandler#startPrefixMapping(String,String) and ContentHandler#endPrefixMapping(String) are invoked properly. Similarly, the user-specified ContentHandler will receive startPrefixMapping/endPrefixMapping events. If the ValidatorHandler introduces additional namespace bindings, the user-specified ContentHandler will receive additional startPrefixMapping/endPrefixMapping events.
  3. org.xml.sax.Attributes for the ContentHandler#startElement(String,String,String,Attributes) method may or may not include xmlns* attributes.

A ValidatorHandler is automatically reset every time the startDocument method is invoked.

Recognized Properties and Features

This spec defines the following feature that must be recognized by all ValidatorHandler implementations.

http://xml.org/sax/features/namespace-prefixes

This feature controls how a ValidatorHandler introduces namespace bindings that were not present in the original SAX event stream. When this feature is set to true, it must make sure that the user's ContentHandler will see the corresponding xmlns* attribute in the org.xml.sax.Attributes object of the ContentHandler#startElement(String,String,String,Attributes) callback. Otherwise, xmlns* attributes must not be added to org.xml.sax.Attributes that's passed to the user-specified ContentHandler .

(Note that regardless of this switch, namespace bindings are always notified to applications through ContentHandler#startPrefixMapping(String,String) and ContentHandler#endPrefixMapping(String) methods of the ContentHandler specified by the user.)

Note that this feature does NOT affect the way a ValidatorHandler receives SAX events. It merely changes the way it augments SAX events.

This feature is set to false by default.

Constructor:
 protected ValidatorHandler() 
Method from javax.xml.validation.ValidatorHandler Summary:
getContentHandler,   getErrorHandler,   getFeature,   getProperty,   getResourceResolver,   getTypeInfoProvider,   setContentHandler,   setErrorHandler,   setFeature,   setProperty,   setResourceResolver
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.xml.validation.ValidatorHandler Detail:
 abstract public ContentHandler getContentHandler()
    Gets the ContentHandler which receives the augmented validation result.
 abstract public ErrorHandler getErrorHandler()
 public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException 
    Look up the value of a feature flag.

    The feature name is any fully-qualified URI. It is possible for a ValidatorHandler to recognize a feature name but temporarily be unable to return its value. Some feature values may be available only in specific contexts, such as before, during, or after a validation.

    Implementors are free (and encouraged) to invent their own features, using names built on their own URIs.

 public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException 
    Look up the value of a property.

    The property name is any fully-qualified URI. It is possible for a ValidatorHandler to recognize a property name but temporarily be unable to return its value. Some property values may be available only in specific contexts, such as before, during, or after a validation.

    ValidatorHandler s are not required to recognize any specific property names.

    Implementors are free (and encouraged) to invent their own properties, using names built on their own URIs.

 abstract public LSResourceResolver getResourceResolver()
 abstract public TypeInfoProvider getTypeInfoProvider()
    Obtains the TypeInfoProvider implementation of this ValidatorHandler .

    The obtained TypeInfoProvider can be queried during a parse to access the type information determined by the validator.

    Some schema languages do not define the notion of type, for those languages, this method may not be supported. However, to be compliant with this specification, implementations for W3C XML Schema 1.0 must support this operation.

 abstract public  void setContentHandler(ContentHandler receiver)
 abstract public  void setErrorHandler(ErrorHandler errorHandler)
 public  void setFeature(String name,
    boolean value) throws SAXNotRecognizedException, SAXNotSupportedException 
    Set the value of a feature flag.

    Feature can be used to control the way a ValidatorHandler parses schemas, although ValidatorHandler s are not required to recognize any specific property names.

    The feature name is any fully-qualified URI. It is possible for a ValidatorHandler to expose a feature value but to be unable to change the current value. Some feature values may be immutable or mutable only in specific contexts, such as before, during, or after a validation.

 public  void setProperty(String name,
    Object object) throws SAXNotRecognizedException, SAXNotSupportedException 
    Set the value of a property.

    The property name is any fully-qualified URI. It is possible for a ValidatorHandler to recognize a property name but to be unable to change the current value. Some property values may be immutable or mutable only in specific contexts, such as before, during, or after a validation.

    ValidatorHandler s are not required to recognize setting any specific property names.

 abstract public  void setResourceResolver(LSResourceResolver resourceResolver)