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 void
characters(char[] ch, int start, int length)
void
endDocument()
void
endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
void
endPrefixMapping(java.lang.String prefix)
java.lang.Object
getCurrentElementType()
returns current element type.org.xml.sax.ErrorHandler
getErrorHandler()
org.relaxng.datatype.Datatype[]
getLastCharacterType()
gets DataType that validated the last characters.org.xml.sax.Locator
getLocator()
IVerifier
getVerifier()
void
ignorableWhitespace(char[] ch, int start, int length)
boolean
isValid()
checks if the document was valid.void
processingInstruction(java.lang.String target, java.lang.String data)
void
setDocumentLocator(org.xml.sax.Locator locator)
void
setErrorHandler(org.xml.sax.ErrorHandler handler)
void
setPanicMode(boolean usePanicMode)
Turns on/off the panic mode.void
skippedEntity(java.lang.String name)
void
startDocument()
void
startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
void
startPrefixMapping(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:IVerifier
checks 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:IVerifier
returns current element type. Actual java type depends on the implementation. This method works correctly only when called immediately after handling startElement event.- Specified by:
getCurrentElementType
in 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:IVerifier
gets 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:
getLastCharacterType
in interfaceIVerifier
- Returns:
- null if type-assignment was not possible.
-
getLocator
public final org.xml.sax.Locator getLocator()
- Specified by:
getLocator
in interfaceIVerifier
-
getErrorHandler
public final org.xml.sax.ErrorHandler getErrorHandler()
- Specified by:
getErrorHandler
in interfaceIVerifier
- Specified by:
getErrorHandler
in interfaceorg.xml.sax.XMLReader
- Overrides:
getErrorHandler
in classorg.xml.sax.helpers.XMLFilterImpl
-
setErrorHandler
public final void setErrorHandler(org.xml.sax.ErrorHandler handler)
- Specified by:
setErrorHandler
in interfaceIVerifier
- Specified by:
setErrorHandler
in interfaceorg.xml.sax.XMLReader
- Overrides:
setErrorHandler
in classorg.xml.sax.helpers.XMLFilterImpl
-
setPanicMode
public final void setPanicMode(boolean usePanicMode)
Description copied from interface:IVerifier
Turns 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:
setPanicMode
in interfaceIVerifier
-
getVerifier
public IVerifier getVerifier()
-
setDocumentLocator
public void setDocumentLocator(org.xml.sax.Locator locator)
- Specified by:
setDocumentLocator
in interfaceorg.xml.sax.ContentHandler
- Overrides:
setDocumentLocator
in classorg.xml.sax.helpers.XMLFilterImpl
-
startDocument
public void startDocument() throws org.xml.sax.SAXException
- Specified by:
startDocument
in interfaceorg.xml.sax.ContentHandler
- Overrides:
startDocument
in classorg.xml.sax.helpers.XMLFilterImpl
- Throws:
org.xml.sax.SAXException
-
endDocument
public void endDocument() throws org.xml.sax.SAXException
- Specified by:
endDocument
in interfaceorg.xml.sax.ContentHandler
- Overrides:
endDocument
in 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:
startPrefixMapping
in interfaceorg.xml.sax.ContentHandler
- Overrides:
startPrefixMapping
in 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:
endPrefixMapping
in interfaceorg.xml.sax.ContentHandler
- Overrides:
endPrefixMapping
in 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:
startElement
in interfaceorg.xml.sax.ContentHandler
- Overrides:
startElement
in 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:
endElement
in interfaceorg.xml.sax.ContentHandler
- Overrides:
endElement
in 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:
characters
in interfaceorg.xml.sax.ContentHandler
- Overrides:
characters
in 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:
ignorableWhitespace
in interfaceorg.xml.sax.ContentHandler
- Overrides:
ignorableWhitespace
in 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:
processingInstruction
in interfaceorg.xml.sax.ContentHandler
- Overrides:
processingInstruction
in 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:
skippedEntity
in interfaceorg.xml.sax.ContentHandler
- Overrides:
skippedEntity
in classorg.xml.sax.helpers.XMLFilterImpl
- Throws:
org.xml.sax.SAXException
-
-