Class VerifierFilter
- java.lang.Object
-
- org.xml.sax.helpers.XMLFilterImpl
-
- com.sun.msv.verifier.VerifierFilter
-
- All Implemented Interfaces:
IVerifier,org.iso_relax.verifier.VerifierHandler,org.xml.sax.ContentHandler,org.xml.sax.DTDHandler,org.xml.sax.EntityResolver,org.xml.sax.ErrorHandler,org.xml.sax.XMLFilter,org.xml.sax.XMLReader
public class VerifierFilter extends org.xml.sax.helpers.XMLFilterImpl implements IVerifier
SAX XMLFilter that verifies incoming SAX event stream. This object can be reused to validate multiple documents. Just be careful NOT to use the same object to validate more than one documents at the same time.
-
-
Constructor Summary
Constructors Constructor Description VerifierFilter(DocumentDeclaration documentDecl, org.xml.sax.ErrorHandler errorHandler)VerifierFilter(IVerifier verifier)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcharacters(char[] ch, int start, int length)voidendDocument()voidendElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)voidendPrefixMapping(java.lang.String prefix)java.lang.ObjectgetCurrentElementType()returns current element type.org.xml.sax.ErrorHandlergetErrorHandler()org.relaxng.datatype.Datatype[]getLastCharacterType()gets DataType that validated the last characters.org.xml.sax.LocatorgetLocator()IVerifiergetVerifier()voidignorableWhitespace(char[] ch, int start, int length)booleanisValid()checks if the document was valid.voidprocessingInstruction(java.lang.String target, java.lang.String data)voidsetDocumentLocator(org.xml.sax.Locator locator)voidsetErrorHandler(org.xml.sax.ErrorHandler handler)voidsetPanicMode(boolean usePanicMode)Turns on/off the panic mode.voidskippedEntity(java.lang.String name)voidstartDocument()voidstartElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)voidstartPrefixMapping(java.lang.String prefix, java.lang.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, warning
-
-
-
-
Field Detail
-
verifier
private final IVerifier verifier
-
-
Constructor Detail
-
VerifierFilter
public VerifierFilter(IVerifier verifier)
- Parameters:
verifier- Verifier object that performs actual validation.
-
VerifierFilter
public VerifierFilter(DocumentDeclaration documentDecl, org.xml.sax.ErrorHandler errorHandler)
-
-
Method Detail
-
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
public java.lang.Object 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
public final org.xml.sax.Locator getLocator()
- Specified by:
getLocatorin interfaceIVerifier
-
getErrorHandler
public final org.xml.sax.ErrorHandler getErrorHandler()
- Specified by:
getErrorHandlerin interfaceIVerifier- Specified by:
getErrorHandlerin interfaceorg.xml.sax.XMLReader- Overrides:
getErrorHandlerin classorg.xml.sax.helpers.XMLFilterImpl
-
setErrorHandler
public final void setErrorHandler(org.xml.sax.ErrorHandler handler)
- Specified by:
setErrorHandlerin interfaceIVerifier- Specified by:
setErrorHandlerin interfaceorg.xml.sax.XMLReader- Overrides:
setErrorHandlerin classorg.xml.sax.helpers.XMLFilterImpl
-
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
public IVerifier getVerifier()
-
setDocumentLocator
public void setDocumentLocator(org.xml.sax.Locator locator)
- Specified by:
setDocumentLocatorin interfaceorg.xml.sax.ContentHandler- Overrides:
setDocumentLocatorin classorg.xml.sax.helpers.XMLFilterImpl
-
startDocument
public void startDocument() throws org.xml.sax.SAXException- Specified by:
startDocumentin interfaceorg.xml.sax.ContentHandler- Overrides:
startDocumentin classorg.xml.sax.helpers.XMLFilterImpl- Throws:
org.xml.sax.SAXException
-
endDocument
public void endDocument() throws org.xml.sax.SAXException- Specified by:
endDocumentin interfaceorg.xml.sax.ContentHandler- Overrides:
endDocumentin classorg.xml.sax.helpers.XMLFilterImpl- Throws:
org.xml.sax.SAXException
-
startPrefixMapping
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) throws org.xml.sax.SAXException- Specified by:
startPrefixMappingin interfaceorg.xml.sax.ContentHandler- Overrides:
startPrefixMappingin classorg.xml.sax.helpers.XMLFilterImpl- Throws:
org.xml.sax.SAXException
-
endPrefixMapping
public void endPrefixMapping(java.lang.String prefix) throws org.xml.sax.SAXException- Specified by:
endPrefixMappingin interfaceorg.xml.sax.ContentHandler- Overrides:
endPrefixMappingin classorg.xml.sax.helpers.XMLFilterImpl- Throws:
org.xml.sax.SAXException
-
startElement
public void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts) throws org.xml.sax.SAXException- Specified by:
startElementin interfaceorg.xml.sax.ContentHandler- Overrides:
startElementin classorg.xml.sax.helpers.XMLFilterImpl- Throws:
org.xml.sax.SAXException
-
endElement
public void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException- Specified by:
endElementin interfaceorg.xml.sax.ContentHandler- Overrides:
endElementin classorg.xml.sax.helpers.XMLFilterImpl- Throws:
org.xml.sax.SAXException
-
characters
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException- Specified by:
charactersin interfaceorg.xml.sax.ContentHandler- Overrides:
charactersin classorg.xml.sax.helpers.XMLFilterImpl- Throws:
org.xml.sax.SAXException
-
ignorableWhitespace
public void ignorableWhitespace(char[] ch, int start, int length) throws org.xml.sax.SAXException- Specified by:
ignorableWhitespacein interfaceorg.xml.sax.ContentHandler- Overrides:
ignorableWhitespacein classorg.xml.sax.helpers.XMLFilterImpl- Throws:
org.xml.sax.SAXException
-
processingInstruction
public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException- Specified by:
processingInstructionin interfaceorg.xml.sax.ContentHandler- Overrides:
processingInstructionin classorg.xml.sax.helpers.XMLFilterImpl- Throws:
org.xml.sax.SAXException
-
skippedEntity
public void skippedEntity(java.lang.String name) throws org.xml.sax.SAXException- Specified by:
skippedEntityin interfaceorg.xml.sax.ContentHandler- Overrides:
skippedEntityin classorg.xml.sax.helpers.XMLFilterImpl- Throws:
org.xml.sax.SAXException
-
-