Interface Validator
-
- All Known Implementing Classes:
CombineValidator
public interface ValidatorValidates an XML document with respect to a schema. The schema is determined when theValidatoris created and cannot be changed. The XML document is provided to theValidatorby calling methods of theContentHandlerobject returned bygetContentHandler; the methods must be called in the sequence specified by theContentHandlerinterface. If thegetDTDHandlermethod returns a non-null object, then method calls must be made on it reporting DTD information.Any errors will be reported to the
ErrorHandlerspecified when theValidatorwas created. If, after the call to theendDocumentmethod, no errors have been reported, then the XML document is valid.A single
Validatorobject is not safe for concurrent access from multiple threads. A singleValidatorHandlercan be used to validate only a single document at a time.After completing validation of an XML document (i.e. after calling the
endDocumenton theContentHandler),resetcan be called to allow validation of another document. Theresetmethod may create newContentHandlerandDTDHandlerobjects or may simply reinitialize the state of the existing objects. Therefore,getContentHandlerandgetDTDHandlermust be called afterresetto retrieve the objects to which the XML document to be validated must be provided.- Author:
- James Clark
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ContentHandlergetContentHandler()Returns the ContentHandler that will receive the XML document.DTDHandlergetDTDHandler()Returns a DTDHandler.voidreset()Cleans up after validating a document.
-
-
-
Method Detail
-
getContentHandler
ContentHandler getContentHandler()
Returns the ContentHandler that will receive the XML document. Information about the XML document to be validated must be reported by calling methods on the returned ContentHandler. When validation of an XML document has been completed (either endDocument() has been called or validation has been abandoned prematurely), reset() must be called. If no calls are made on the ContentHandler, then reset() need not be called. Implementations should allocate resources that require cleanup (e.g. threads, open files) lazily, typically in startDocument(). This method does not change the state of the Validator: the same object will always be returned unlessresetis called.- Returns:
- a ContentHandler, never
null - See Also:
reset()
-
getDTDHandler
DTDHandler getDTDHandler()
Returns a DTDHandler. Information about the DTD must be reported by calling methods on the returned object, unlessnullis returned. The same object will always be returned unlessresetis called: this method does not change the state of the Validator.- Returns:
- a DTDHandler, maybe
nullif DTD information is not significant to theValidator
-
reset
void reset()
Cleans up after validating a document. After completing validation of a document,resetmust be called. After calling reset(), another document may be validated. Calling this method may create new ContentHandler and DTDHandler objects or may simply reinitialize the state of the existing objects.
-
-