public class Verifier extends AbstractVerifier implements IVerifier
Modifier and Type | Field and Description |
---|---|
protected Acceptor |
current |
protected DocumentDeclaration |
docDecl
Schema object against which the validation will be done
|
static String |
ERR_DUPLICATE_ID |
static String |
ERR_MISSING_ATTRIBUTE |
static String |
ERR_UNCOMPLETED_CONTENT |
static String |
ERR_UNEXPECTED_ATTRIBUTE |
static String |
ERR_UNEXPECTED_ELEMENT |
static String |
ERR_UNEXPECTED_STARTTAG |
static String |
ERR_UNEXPECTED_TEXT |
static String |
ERR_UNSOLD_IDREF |
protected ErrorHandler |
errorHandler
Error handler
|
protected boolean |
hadError
This flag will be set to true if an error is found
|
protected int |
panicLevel
Panic level.
|
dummyLocator, idrefs, ids, locator, namespaceSupport, performIDcheck
Constructor and Description |
---|
Verifier(DocumentDeclaration documentDecl,
ErrorHandler errorHandler) |
Modifier and Type | Method and Description |
---|---|
void |
characters(char[] buf,
int start,
int len) |
void |
endDocument() |
void |
endElement(String namespaceUri,
String localName,
String qName) |
protected org.relaxng.datatype.Datatype[] |
feedAttribute(Acceptor child,
String uri,
String localName,
String qName,
String value) |
Object |
getCurrentElementType()
returns current element type.
|
ErrorHandler |
getErrorHandler() |
org.relaxng.datatype.Datatype[] |
getLastCharacterType()
gets DataType that validated the last characters.
|
void |
ignorableWhitespace(char[] buf,
int start,
int len) |
protected void |
init() |
boolean |
isValid()
checks if the document was valid.
|
static String |
localizeMessage(String propertyName,
Object[] args) |
void |
onDuplicateId(String id)
this method is called when a duplicate id value is found.
|
protected ValidityViolation |
onError(String msg,
ErrorInfo ei) |
protected ValidityViolation |
onError(StringRef ref,
String defaultMsg,
ErrorInfo ei)
signals an error.
|
protected void |
onNextAcceptorReady(StartTagInfo sti,
Acceptor nextAcceptor)
this method is called from the startElement method
after the tag name is processed and the child acceptor is created.
|
void |
setErrorHandler(ErrorHandler handler) |
void |
setPanicMode(boolean usePanicMode)
Turns on/off the panic mode.
|
void |
startDocument() |
void |
startElement(String namespaceUri,
String localName,
String qName,
Attributes atts) |
protected void |
verifyText() |
endPrefixMapping, getBaseUri, getLocator, isNotation, isUnparsedEntity, notationDecl, onID, processingInstruction, resolveNamespacePrefix, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLocator
endPrefixMapping, processingInstruction, setDocumentLocator, skippedEntity, startPrefixMapping
protected Acceptor current
protected ErrorHandler errorHandler
protected boolean hadError
protected final DocumentDeclaration docDecl
protected int panicLevel
public static final String ERR_UNEXPECTED_TEXT
public static final String ERR_UNEXPECTED_ATTRIBUTE
public static final String ERR_MISSING_ATTRIBUTE
public static final String ERR_UNEXPECTED_STARTTAG
public static final String ERR_UNCOMPLETED_CONTENT
public static final String ERR_UNEXPECTED_ELEMENT
public static final String ERR_UNSOLD_IDREF
public static final String ERR_DUPLICATE_ID
public Verifier(DocumentDeclaration documentDecl, ErrorHandler errorHandler)
public final ErrorHandler getErrorHandler()
getErrorHandler
in interface IVerifier
public final void setErrorHandler(ErrorHandler handler)
setErrorHandler
in interface IVerifier
public final boolean isValid()
IVerifier
public final void setPanicMode(boolean usePanicMode)
IVerifier
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,)
setPanicMode
in interface IVerifier
public org.relaxng.datatype.Datatype[] getLastCharacterType()
IVerifier
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.
getLastCharacterType
in interface IVerifier
protected void verifyText() throws SAXException
SAXException
public void startElement(String namespaceUri, String localName, String qName, Attributes atts) throws SAXException
startElement
in interface ContentHandler
startElement
in class AbstractVerifier
SAXException
protected void onNextAcceptorReady(StartTagInfo sti, Acceptor nextAcceptor) throws SAXException
This method is called before the attributes are consumed.
derived class can use this method to do something useful.
SAXException
protected org.relaxng.datatype.Datatype[] feedAttribute(Acceptor child, String uri, String localName, String qName, String value) throws SAXException
SAXException
public void endElement(String namespaceUri, String localName, String qName) throws SAXException
endElement
in interface ContentHandler
endElement
in class AbstractVerifier
SAXException
protected ValidityViolation onError(StringRef ref, String defaultMsg, ErrorInfo ei) throws SAXException
SAXException
protected ValidityViolation onError(String msg, ErrorInfo ei) throws SAXException
SAXException
public Object getCurrentElementType()
IVerifier
getCurrentElementType
in interface IVerifier
public void characters(char[] buf, int start, int len) throws SAXException
characters
in interface ContentHandler
SAXException
public void ignorableWhitespace(char[] buf, int start, int len) throws SAXException
ignorableWhitespace
in interface ContentHandler
SAXException
protected void init()
init
in class AbstractVerifier
public void startDocument() throws SAXException
startDocument
in interface ContentHandler
SAXException
public void endDocument() throws SAXException
endDocument
in interface ContentHandler
SAXException
public void onDuplicateId(String id)
AbstractVerifier
onDuplicateId
in class AbstractVerifier
Copyright © 2016 Oracle Corporation. All rights reserved.