Class Verifier
- All Implemented Interfaces:
IDContextProvider2,IVerifier,org.iso_relax.verifier.VerifierHandler,org.relaxng.datatype.ValidationContext,ContentHandler,DTDHandler
- Direct Known Subclasses:
IDConstraintChecker,TypeDetector
- Author:
- Kohsuke KAWAGUCHI
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Acceptorprotected final DocumentDeclarationSchema object against which the validation will be donestatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected ErrorHandlerError handlerprotected booleanThis flag will be set to true if an error is foundprotected intPanic level.Fields inherited from class com.sun.msv.verifier.AbstractVerifier
dummyLocator, idrefs, ids, locator, namespaceSupport, performIDcheck -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(char[] buf, int start, int len) voidvoidendElement(String namespaceUri, String localName, String qName) protected org.relaxng.datatype.Datatype[]returns current element type.final ErrorHandlerorg.relaxng.datatype.Datatype[]gets DataType that validated the last characters.voidignorableWhitespace(char[] buf, int start, int len) protected voidinit()final booleanisValid()checks if the document was valid.static StringlocalizeMessage(String propertyName, Object[] args) voidonDuplicateId(String id) this method is called when a duplicate id value is found.protected ValidityViolationsignals an error.protected ValidityViolationprotected voidonNextAcceptorReady(StartTagInfo sti, Acceptor nextAcceptor) this method is called from the startElement method after the tag name is processed and the child acceptor is created.final voidsetErrorHandler(ErrorHandler handler) final voidsetPanicMode(boolean usePanicMode) Turns on/off the panic mode.voidvoidstartElement(String namespaceUri, String localName, String qName, Attributes atts) protected voidMethods inherited from class com.sun.msv.verifier.AbstractVerifier
endPrefixMapping, getBaseUri, getLocator, isNotation, isUnparsedEntity, notationDecl, onID, processingInstruction, resolveNamespacePrefix, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDeclMethods 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, endPrefixMapping, processingInstruction, setDocumentLocator, skippedEntity, startPrefixMappingMethods inherited from interface com.sun.msv.verifier.IVerifier
getLocator
-
Field Details
-
current
-
errorHandler
Error handler -
hadError
protected boolean hadErrorThis flag will be set to true if an error is found -
docDecl
Schema object against which the validation will be done -
panicLevel
protected int panicLevelPanic level. If the level is non-zero, createChildAcceptors will silently recover from error. This effectively suppresses spurious error messages. This value is set to INITIAL_PANIC_LEVEL when first an error is encountered, and is decreased by successful stepForward and createChildAcceptor. This value is also propagated to child acceptors. -
ERR_UNEXPECTED_TEXT
- See Also:
-
ERR_UNEXPECTED_ATTRIBUTE
- See Also:
-
ERR_MISSING_ATTRIBUTE
- See Also:
-
ERR_UNEXPECTED_STARTTAG
- See Also:
-
ERR_UNCOMPLETED_CONTENT
- See Also:
-
ERR_UNEXPECTED_ELEMENT
- See Also:
-
ERR_UNSOLD_IDREF
- See Also:
-
ERR_DUPLICATE_ID
- See Also:
-
-
Constructor Details
-
Verifier
-
-
Method Details
-
getErrorHandler
- Specified by:
getErrorHandlerin interfaceIVerifier
-
setErrorHandler
- Specified by:
setErrorHandlerin interfaceIVerifier
-
isValid
public final boolean isValid()Description copied from interface:IVerifierchecks if the document was valid. This method may not be called before verification was completed. -
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
-
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.
-
verifyText
- Throws:
SAXException
-
startElement
public void startElement(String namespaceUri, String localName, String qName, Attributes atts) throws SAXException - Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classAbstractVerifier- Throws:
SAXException
-
onNextAcceptorReady
this method is called from the startElement method after the tag name is processed and the child acceptor is created.This method is called before the attributes are consumed.
derived class can use this method to do something useful.
- Throws:
SAXException
-
feedAttribute
protected org.relaxng.datatype.Datatype[] feedAttribute(Acceptor child, String uri, String localName, String qName, String value) throws SAXException - Throws:
SAXException
-
endElement
- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classAbstractVerifier- Throws:
SAXException
-
onError
protected ValidityViolation onError(StringRef ref, String defaultMsg, ErrorInfo ei) throws SAXException signals an error. This method can be overrided by the derived class to provide different behavior.- Throws:
SAXException
-
onError
- Throws:
SAXException
-
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).
-
characters
- Specified by:
charactersin interfaceContentHandler- Throws:
SAXException
-
ignorableWhitespace
- Specified by:
ignorableWhitespacein interfaceContentHandler- Throws:
SAXException
-
init
protected void init()- Overrides:
initin classAbstractVerifier
-
startDocument
- Specified by:
startDocumentin interfaceContentHandler- Throws:
SAXException
-
endDocument
- Specified by:
endDocumentin interfaceContentHandler- Throws:
SAXException
-
onDuplicateId
Description copied from class:AbstractVerifierthis method is called when a duplicate id value is found.- Specified by:
onDuplicateIdin classAbstractVerifier
-
localizeMessage
-