|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.msv.verifier.AbstractVerifier
com.sun.msv.verifier.Verifier
public class Verifier
SAX ContentHandler 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.
Field Summary | |
---|---|
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
|
Constructor Summary | |
---|---|
Verifier(DocumentDeclaration documentDecl,
ErrorHandler errorHandler)
|
Method Summary | |
---|---|
void |
characters(char[] buf,
int start,
int len)
|
void |
endDocument()
|
void |
endElement(String namespaceUri,
String localName,
String qName)
|
Object |
getCurrentElementType()
returns current element type. |
ErrorHandler |
getErrorHandler()
|
Datatype[] |
getLastCharacterType()
gets DataType that validated the last characters. |
void |
ignorableWhitespace(char[] buf,
int start,
int len)
|
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. |
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)
|
Methods inherited from class com.sun.msv.verifier.AbstractVerifier |
---|
endPrefixMapping, getBaseUri, getLocator, isNotation, isUnparsedEntity, notationDecl, onID, processingInstruction, resolveNamespacePrefix, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.sun.msv.verifier.IVerifier |
---|
getLocator |
Methods inherited from interface org.xml.sax.ContentHandler |
---|
endPrefixMapping, processingInstruction, setDocumentLocator, skippedEntity, startPrefixMapping |
Field Detail |
---|
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
Constructor Detail |
---|
public Verifier(DocumentDeclaration documentDecl, ErrorHandler errorHandler)
Method Detail |
---|
public final ErrorHandler getErrorHandler()
getErrorHandler
in interface IVerifier
public final void setErrorHandler(ErrorHandler handler)
setErrorHandler
in interface IVerifier
public final boolean isValid()
IVerifier
isValid
in interface IVerifier
isValid
in interface VerifierHandler
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 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
public void startElement(String namespaceUri, String localName, String qName, Attributes atts) throws SAXException
startElement
in interface ContentHandler
startElement
in class AbstractVerifier
SAXException
public void endElement(String namespaceUri, String localName, String qName) throws SAXException
endElement
in interface ContentHandler
endElement
in class AbstractVerifier
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
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
public static String localizeMessage(String propertyName, Object[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |