APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.org.apache.xerces.internal.jaxp.validation

pack-priv final Class ValidatorImpl

extends Validator
implements PSVIProvider
Class Inheritance
All Implemented Interfaces
com.sun.org.apache.xerces.internal.xs.PSVIProvider
Imports
java.io.IOException, javax.xml.transform.Result, .Source, javax.xml.transform.dom.DOMSource, javax.xml.transform.sax.SAXSource, javax.xml.transform.stax.StAXSource, javax.xml.transform.stream.StreamSource, javax.xml.validation.Validator, com.sun.org.apache.xerces.internal.impl.Constants, com.sun.org.apache.xerces.internal.util.SAXMessageFormatter, .Status, com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException, com.sun.org.apache.xerces.internal.xs.AttributePSVI, .ElementPSVI, .PSVIProvider, org.w3c.dom.ls.LSResourceResolver, org.xml.sax.ErrorHandler, .SAXException, .SAXNotRecognizedException, .SAXNotSupportedException

Implementation of Validator for W3C XML Schemas.

Authors
Kohsuke Kawaguchi, Michael Glavassevich, IBM, Sunitha Reddy

Field Summary

Modifier and TypeField and Description
private static final String
CURRENT_ELEMENT_NODE

Support current-element-node property

private XMLSchemaValidatorComponentManager
fComponentManager

Component manager.

private boolean
fConfigurationChanged

Flag for tracking whether features/properties changed since last reset.

private DOMValidatorHelper
fDOMValidatorHelper

DOM validator helper.

private boolean
fErrorHandlerChanged

Flag for tracking whether the error handler changed since last reset.

private boolean
fResourceResolverChanged

Flag for tracking whether the resource resolver changed since last reset.

private ValidatorHandlerImpl
fSAXValidatorHelper

SAX validator helper.

private StAXValidatorHelper
fStaxValidatorHelper

StAX validator helper.

private StreamValidatorHelper
fStreamValidatorHelper

Stream validator helper.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public AttributePSVI
getAttributePSVI(int index)

Implements com.sun.org.apache.xerces.internal.xs.PSVIProvider.getAttributePSVI.

Provides AttributePSVI given the index of an attribute information item in the current element's attribute list.

public AttributePSVI
getAttributePSVIByName(String uri, String localname)

Implements com.sun.org.apache.xerces.internal.xs.PSVIProvider.getAttributePSVIByName.

Provides AttributePSVI given the namespace name and the local name of an attribute information item in the current element's attribute list.

public ElementPSVI
getElementPSVI()

Implements com.sun.org.apache.xerces.internal.xs.PSVIProvider.getElementPSVI.

Provides the post schema validation item for the current element information item.

public ErrorHandler
getErrorHandler()

Implements abstract javax.xml.validation.Validator.getErrorHandler.

Gets the current ErrorHandler set to this Validator.

public boolean
getFeature(String name)

Overrides javax.xml.validation.Validator.getFeature.

Look up the value of a feature flag.

public Object
getProperty(String name)

Overrides javax.xml.validation.Validator.getProperty.

Look up the value of a property.

public LSResourceResolver
public void
reset()

Implements abstract javax.xml.validation.Validator.reset.

Reset this Validator to its original configuration.

public void
setErrorHandler(ErrorHandler errorHandler)

Implements abstract javax.xml.validation.Validator.setErrorHandler.

Sets the ErrorHandler to receive errors encountered during the validate method invocation.

public void
setFeature(String name, boolean value)

Overrides javax.xml.validation.Validator.setFeature.

Set the value of a feature flag.

public void
setProperty(String name, Object object)

Overrides javax.xml.validation.Validator.setProperty.

Set the value of a property.

public void
setResourceResolver(LSResourceResolver resourceResolver)

Implements abstract javax.xml.validation.Validator.setResourceResolver.

Sets the LSResourceResolver to customize resource resolution while in a validation episode.

public void
validate(Source source, Result result)

Implements abstract javax.xml.validation.Validator.validate.

Validates the specified input and send the augmented validation result to the specified output.

Inherited from javax.xml.validation.Validator:
validate

Field Detail

CURRENT_ELEMENT_NODEback to summary
private static final String CURRENT_ELEMENT_NODE

Support current-element-node property

fComponentManagerback to summary
private XMLSchemaValidatorComponentManager fComponentManager

Component manager.

fConfigurationChangedback to summary
private boolean fConfigurationChanged

Flag for tracking whether features/properties changed since last reset.

fDOMValidatorHelperback to summary
private DOMValidatorHelper fDOMValidatorHelper

DOM validator helper.

fErrorHandlerChangedback to summary
private boolean fErrorHandlerChanged

Flag for tracking whether the error handler changed since last reset.

fResourceResolverChangedback to summary
private boolean fResourceResolverChanged

Flag for tracking whether the resource resolver changed since last reset.

fSAXValidatorHelperback to summary
private ValidatorHandlerImpl fSAXValidatorHelper

SAX validator helper.

fStaxValidatorHelperback to summary
private StAXValidatorHelper fStaxValidatorHelper

StAX validator helper.

fStreamValidatorHelperback to summary
private StreamValidatorHelper fStreamValidatorHelper

Stream validator helper.

Constructor Detail

ValidatorImplback to summary
public ValidatorImpl(XSGrammarPoolContainer grammarContainer)

Method Detail

getAttributePSVIback to summary
public AttributePSVI getAttributePSVI(int index)

Implements com.sun.org.apache.xerces.internal.xs.PSVIProvider.getAttributePSVI.

Doc from com.sun.org.apache.xerces.internal.xs.PSVIProvider.getAttributePSVI.

Provides AttributePSVI given the index of an attribute information item in the current element's attribute list. The method must be called by an application while in the scope of the methods which report the start and end of an element at a point where the attribute list is available. For example, for SAX the method must be called while in the scope of the document handler's startElement call. If the method is called outside of the specified scope, the return value is undefined.

Annotations
@Override
getAttributePSVIByNameback to summary
public AttributePSVI getAttributePSVIByName(String uri, String localname)

Implements com.sun.org.apache.xerces.internal.xs.PSVIProvider.getAttributePSVIByName.

Doc from com.sun.org.apache.xerces.internal.xs.PSVIProvider.getAttributePSVIByName.

Provides AttributePSVI given the namespace name and the local name of an attribute information item in the current element's attribute list. The method must be called by an application while in the scope of the methods which report the start and end of an element at a point where the attribute list is available. For example, for SAX the method must be called while in the scope of the document handler's startElement call. If the method is called outside of the specified scope, the return value is undefined.

Annotations
@Override
getElementPSVIback to summary
public ElementPSVI getElementPSVI()

Implements com.sun.org.apache.xerces.internal.xs.PSVIProvider.getElementPSVI.

Doc from com.sun.org.apache.xerces.internal.xs.PSVIProvider.getElementPSVI.

Provides the post schema validation item for the current element information item. The method must be called by an application while in the scope of the methods which report the start and end of an element. For example, for SAX the method must be called within the scope of the document handler's startElement or endElement call. If the method is called outside of the specified scope, the return value is undefined.

Annotations
@Override
getErrorHandlerback to summary
public ErrorHandler getErrorHandler()

Implements abstract javax.xml.validation.Validator.getErrorHandler.

Doc from javax.xml.validation.Validator.getErrorHandler.

Gets the current ErrorHandler set to this Validator.

Annotations
@Override
getFeatureback to summary
public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException

Overrides javax.xml.validation.Validator.getFeature.

Doc from javax.xml.validation.Validator.getFeature.

Look up the value of a feature flag.

The feature name is any fully-qualified URI. It is possible for a Validator 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.

Annotations
@Override
Exceptions
SAXNotRecognizedException:
If the feature value can't be assigned or retrieved.
SAXNotSupportedException:
When the Validator recognizes the feature name but cannot determine its value at this time.
getPropertyback to summary
public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException

Overrides javax.xml.validation.Validator.getProperty.

Doc from javax.xml.validation.Validator.getProperty.

Look up the value of a property.

The property name is any fully-qualified URI. It is possible for a Validator 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.

Validators 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.

Annotations
@Override
Exceptions
SAXNotRecognizedException:
If the property value can't be assigned or retrieved.
SAXNotSupportedException:
When the XMLReader recognizes the property name but cannot determine its value at this time.
getResourceResolverback to summary
public LSResourceResolver getResourceResolver()

Implements abstract javax.xml.validation.Validator.getResourceResolver.

Doc from javax.xml.validation.Validator.getResourceResolver.

Gets the current LSResourceResolver set to this Validator.

Annotations
@Override
resetback to summary
public void reset()

Implements abstract javax.xml.validation.Validator.reset.

Doc from javax.xml.validation.Validator.reset.

Reset this Validator to its original configuration.

Validator is reset to the same state as when it was created with Schema#newValidator(). reset() is designed to allow the reuse of existing Validators thus saving resources associated with the creation of new Validators.

The reset Validator is not guaranteed to have the same LSResourceResolver or ErrorHandler Objects, e.g. Object#equals(Object obj). It is guaranteed to have a functionally equal LSResourceResolver and ErrorHandler.

Annotations
@Override
setErrorHandlerback to summary
public void setErrorHandler(ErrorHandler errorHandler)

Implements abstract javax.xml.validation.Validator.setErrorHandler.

Doc from javax.xml.validation.Validator.setErrorHandler.

Sets the ErrorHandler to receive errors encountered during the validate method invocation.

Error handler can be used to customize the error handling process during a validation. When an ErrorHandler is set, errors found during the validation will be first sent to the ErrorHandler.

The error handler can abort further validation immediately by throwing SAXException from the handler. Or for example it can print an error to the screen and try to continue the validation by returning normally from the ErrorHandler

If any Throwable is thrown from an ErrorHandler, the caller of the validate method will be thrown the same Throwable object.

Validator is not allowed to throw SAXException without first reporting it to ErrorHandler.

When the ErrorHandler is null, the implementation will behave as if the following ErrorHandler is set:

class DraconianErrorHandler implements ErrorHandler {
    public void fatalError( org.xml.sax.SAXParseException e ) throws SAXException {
        throw e;
    }
    public void error( org.xml.sax.SAXParseException e ) throws SAXException {
        throw e;
    }
    public void warning( org.xml.sax.SAXParseException e ) throws SAXException {
        // noop
    }
}

When a new Validator object is created, initially this field is set to null.

Annotations
@Override
setFeatureback to summary
public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException

Overrides javax.xml.validation.Validator.setFeature.

Doc from javax.xml.validation.Validator.setFeature.

Set the value of a feature flag.

Feature can be used to control the way a Validator parses schemas, although Validators are not required to recognize any specific feature names.

The feature name is any fully-qualified URI. It is possible for a Validator 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.

Annotations
@Override
Exceptions
SAXNotRecognizedException:
If the feature value can't be assigned or retrieved.
SAXNotSupportedException:
When the Validator recognizes the feature name but cannot set the requested value.
setPropertyback to summary
public void setProperty(String name, Object object) throws SAXNotRecognizedException, SAXNotSupportedException

Overrides javax.xml.validation.Validator.setProperty.

Doc from javax.xml.validation.Validator.setProperty.

Set the value of a property.

The property name is any fully-qualified URI. It is possible for a Validator 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.

All implementations that implement JAXP 1.5 or newer are required to support the javax.xml.XMLConstants#ACCESS_EXTERNAL_DTD and javax.xml.XMLConstants#ACCESS_EXTERNAL_SCHEMA properties.

Annotations
@Override
Exceptions
SAXNotRecognizedException:
If the property value can't be assigned or retrieved.
SAXNotSupportedException:
When the Validator recognizes the property name but cannot set the requested value.
setResourceResolverback to summary
public void setResourceResolver(LSResourceResolver resourceResolver)

Implements abstract javax.xml.validation.Validator.setResourceResolver.

Doc from javax.xml.validation.Validator.setResourceResolver.

Sets the LSResourceResolver to customize resource resolution while in a validation episode.

Validator uses a LSResourceResolver when it needs to locate external resources while a validation, although exactly what constitutes "locating external resources" is up to each schema language.

When the LSResourceResolver is null, the implementation will behave as if the following LSResourceResolver is set:

class DumbLSResourceResolver implements LSResourceResolver {
    public org.w3c.dom.ls.LSInput resolveResource(
        String publicId, String systemId, String baseURI) {

        return null; // always return null
    }
}

If a LSResourceResolver throws a RuntimeException (or instances of its derived classes), then the Validator will abort the parsing and the caller of the validate method will receive the same RuntimeException.

When a new Validator object is created, initially this field is set to null.

Annotations
@Override
validateback to summary
public void validate(Source source, Result result) throws SAXException, IOException

Implements abstract javax.xml.validation.Validator.validate.

Doc from javax.xml.validation.Validator.validate.

Validates the specified input and send the augmented validation result to the specified output.

This method places the following restrictions on the types of the Source/Result accepted.

Source / Result Accepted
javax.xml.transform.stream.StreamSource javax.xml.transform.sax.SAXSource javax.xml.transform.dom.DOMSource javax.xml.transform.stax.StAXSource
null OK OK OK OK
javax.xml.transform.stream.StreamResult OK IllegalArgumentException IllegalArgumentException IllegalArgumentException
javax.xml.transform.sax.SAXResult IllegalArgumentException OK IllegalArgumentException IllegalArgumentException
javax.xml.transform.dom.DOMResult IllegalArgumentException IllegalArgumentException OK IllegalArgumentException
javax.xml.transform.stax.StAXResult IllegalArgumentException IllegalArgumentException IllegalArgumentException OK

To validate one Source into another kind of Result, use the identity transformer (see javax.xml.transform.TransformerFactory#newTransformer()).

Errors found during the validation is sent to the specified ErrorHandler.

If a document is valid, or if a document contains some errors but none of them were fatal and the ErrorHandler didn't throw any exception, then the method returns normally.

Annotations
@Override
Exceptions
SAXException:
If the ErrorHandler throws a SAXException or if a fatal error is found and the ErrorHandler returns normally.
IOException:
If the validator is processing a SAXSource and the underlying org.xml.sax.XMLReader throws an IOException.