Class VerifierFilter
- All Implemented Interfaces:
IVerifier,org.iso_relax.verifier.VerifierHandler,ContentHandler,DTDHandler,EntityResolver,ErrorHandler,XMLFilter,XMLReader
- Author:
- Kohsuke KAWAGUCHI
-
Constructor Summary
ConstructorsConstructorDescriptionVerifierFilter(DocumentDeclaration documentDecl, ErrorHandler errorHandler) VerifierFilter(IVerifier verifier) -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(char[] ch, int start, int length) voidvoidendElement(String namespaceURI, String localName, String qName) voidendPrefixMapping(String prefix) returns current element type.final ErrorHandlerorg.relaxng.datatype.Datatype[]gets DataType that validated the last characters.final LocatorvoidignorableWhitespace(char[] ch, int start, int length) booleanisValid()checks if the document was valid.voidprocessingInstruction(String target, String data) voidsetDocumentLocator(Locator locator) final voidsetErrorHandler(ErrorHandler handler) final voidsetPanicMode(boolean usePanicMode) Turns on/off the panic mode.voidskippedEntity(String name) voidvoidstartElement(String namespaceURI, String localName, String qName, Attributes atts) voidstartPrefixMapping(String prefix, String uri) Methods inherited from class org.xml.sax.helpers.XMLFilterImpl
error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getFeature, getParent, getProperty, notationDecl, parse, parse, resolveEntity, setContentHandler, setDTDHandler, setEntityResolver, setFeature, setParent, setProperty, unparsedEntityDecl, warningMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xml.sax.ContentHandler
declaration
-
Constructor Details
-
VerifierFilter
- Parameters:
verifier- Verifier object that performs actual validation.
-
VerifierFilter
-
-
Method Details
-
isValid
public boolean isValid()Description copied from interface:IVerifierchecks if the document was valid. This method may not be called before verification was completed. -
getCurrentElementType
Description copied from interface:IVerifierreturns current element type. Actual java type depends on the implementation. This method works correctly only when called immediately after handling startElement event.- Specified by:
getCurrentElementTypein interfaceIVerifier- Returns:
- null this method returns null when it doesn't support type-assignment feature, or type-assignment is impossible for the current element (for example due to the ambiguous grammar).
-
getLastCharacterType
public org.relaxng.datatype.Datatype[] getLastCharacterType()Description copied from interface:IVerifiergets DataType that validated the last characters.This method works correctly only when called immediately after startElement and endElement method. When called, this method returns DataType object that validated the last character literals.
For RELAX NG grammar, this method can return an array of length 2 or more. This happens when the last character matches <list> pattern. In that case, each type corresponds to each token (where tokens are the white-space separation of the last characters).
For any other grammar, this method always returns an array of length 1 (or null, if the type assignment failed).
So when you are using VerifierFilter, you can call this method only in your startElement and endElement method.
- Specified by:
getLastCharacterTypein interfaceIVerifier- Returns:
- null if type-assignment was not possible.
-
getLocator
- Specified by:
getLocatorin interfaceIVerifier
-
getErrorHandler
- Specified by:
getErrorHandlerin interfaceIVerifier- Specified by:
getErrorHandlerin interfaceXMLReader- Overrides:
getErrorHandlerin classXMLFilterImpl
-
setErrorHandler
- Specified by:
setErrorHandlerin interfaceIVerifier- Specified by:
setErrorHandlerin interfaceXMLReader- Overrides:
setErrorHandlerin classXMLFilterImpl
-
setPanicMode
public final void setPanicMode(boolean usePanicMode) Description copied from interface:IVerifierTurns on/off the panic mode. Panic mode is on by default. Turning it on is good for general use. It prevents false error messages to appear.However, turning it off is sometimes useful, when you are sure that the structure of the document is almost valid (e.g., validating a document generated by an application or when you are sure about the validity of the structure and only interested in validating datatypes,)
- Specified by:
setPanicModein interfaceIVerifier
-
getVerifier
-
setDocumentLocator
- Specified by:
setDocumentLocatorin interfaceContentHandler- Overrides:
setDocumentLocatorin classXMLFilterImpl
-
startDocument
- Specified by:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin classXMLFilterImpl- Throws:
SAXException
-
endDocument
- Specified by:
endDocumentin interfaceContentHandler- Overrides:
endDocumentin classXMLFilterImpl- Throws:
SAXException
-
startPrefixMapping
- Specified by:
startPrefixMappingin interfaceContentHandler- Overrides:
startPrefixMappingin classXMLFilterImpl- Throws:
SAXException
-
endPrefixMapping
- Specified by:
endPrefixMappingin interfaceContentHandler- Overrides:
endPrefixMappingin classXMLFilterImpl- Throws:
SAXException
-
startElement
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException - Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classXMLFilterImpl- Throws:
SAXException
-
endElement
- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classXMLFilterImpl- Throws:
SAXException
-
characters
- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classXMLFilterImpl- Throws:
SAXException
-
ignorableWhitespace
- Specified by:
ignorableWhitespacein interfaceContentHandler- Overrides:
ignorableWhitespacein classXMLFilterImpl- Throws:
SAXException
-
processingInstruction
- Specified by:
processingInstructionin interfaceContentHandler- Overrides:
processingInstructionin classXMLFilterImpl- Throws:
SAXException
-
skippedEntity
- Specified by:
skippedEntityin interfaceContentHandler- Overrides:
skippedEntityin classXMLFilterImpl- Throws:
SAXException
-