public final class GenericMsvValidator extends XMLValidator implements com.sun.msv.grammar.IDContextProvider2
Note about id context provider interface: while it'd be nice to separate that part out, it is unfortunately closely tied to the validation process. Hence it's directly implemented by this class.
| Modifier and Type | Field and Description |
|---|---|
protected ArrayList |
mAcceptors |
protected ValidationContext |
mContext |
protected com.sun.msv.verifier.Acceptor |
mCurrAcceptor |
protected String |
mCurrAttrLocalName |
protected String |
mCurrAttrPrefix |
protected ElementIdMap |
mIdDefs
Map that contains information about element id (values of attributes
or textual content with type ID) declarations and references
|
protected XMLValidationSchema |
mParentSchema |
protected XMLValidationProblem |
mProblem
Sometimes a problem object has to be temporarily
stored, and only reported later on.
|
protected TextAccumulator |
mTextAccumulator |
protected com.sun.msv.verifier.DocumentDeclaration |
mVGM |
CONTENT_ALLOW_ANY_TEXT, CONTENT_ALLOW_NONE, CONTENT_ALLOW_UNDEFINED, CONTENT_ALLOW_VALIDATABLE_TEXT, CONTENT_ALLOW_WS, CONTENT_ALLOW_WS_NONSTRICT| Constructor and Description |
|---|
GenericMsvValidator(XMLValidationSchema parent,
ValidationContext ctxt,
com.sun.msv.verifier.DocumentDeclaration vgm) |
| Modifier and Type | Method and Description |
|---|---|
String |
getAttributeType(int index)
Method for getting schema-specified type of an attribute, if
information is available.
|
String |
getBaseUri() |
int |
getIdAttrIndex()
Method for finding out the index of the attribute that
is of type ID; derived from DTD, W4C Schema, or some other validation
source.
|
int |
getNotationAttrIndex()
Method for finding out the index of the attribute (collected using
the attribute collector; having DTD/Schema-derived info in same order)
that is of type NOTATION.
|
XMLValidationSchema |
getSchema()
Returns the schema instance that created this validator
object, if known (and applicable).
|
boolean |
isNotation(String notationName) |
boolean |
isUnparsedEntity(String entityName) |
void |
onID(org.relaxng.datatype.Datatype datatype,
com.sun.msv.verifier.regexp.StringToken idToken)
Note: we have to throw a dummy marker exception, which merely
signals that a validation problem is to be reported.
|
String |
resolveNamespacePrefix(String prefix) |
String |
validateAttribute(String localName,
String uri,
String prefix,
char[] valueChars,
int valueStart,
int valueEnd)
Callback method called on validator to give it a chance to validate
the value of an attribute, as well as to normalize its value if
appropriate (remove leading/trailing/intervening white space for
certain token types etc.).
|
String |
validateAttribute(String localName,
String uri,
String prefix,
String value)
Callback method called on validator to give it a chance to validate
the value of an attribute, as well as to normalize its value if
appropriate (remove leading/trailing/intervening white space for
certain token types etc.).
|
int |
validateElementAndAttributes()
Method called after calling
XMLValidator.validateAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String) on all
attributes (if any), but before starting to handle element
content. |
int |
validateElementEnd(String localName,
String uri,
String prefix)
Method called right after encountering an element close tag.
|
void |
validateElementStart(String localName,
String uri,
String prefix)
Method called to update information about the newly encountered (start)
element.
|
void |
validateText(char[] cbuf,
int textStart,
int textEnd,
boolean lastTextSegment)
Method called to validate textual content.
|
void |
validateText(String text,
boolean lastTextSegment)
Method called to validate textual content.
|
void |
validationCompleted(boolean eod)
Method called when the validation is completed; either due to the
input stream ending, or due to an explicit 'stop validation' request
by the application (via context object).
|
getSchemaTypeprotected final XMLValidationSchema mParentSchema
protected final ValidationContext mContext
protected final com.sun.msv.verifier.DocumentDeclaration mVGM
protected final ArrayList mAcceptors
protected com.sun.msv.verifier.Acceptor mCurrAcceptor
protected final TextAccumulator mTextAccumulator
protected ElementIdMap mIdDefs
protected String mCurrAttrPrefix
protected String mCurrAttrLocalName
protected XMLValidationProblem mProblem
public GenericMsvValidator(XMLValidationSchema parent, ValidationContext ctxt, com.sun.msv.verifier.DocumentDeclaration vgm)
public String getBaseUri()
getBaseUri in interface org.relaxng.datatype.ValidationContextpublic boolean isNotation(String notationName)
isNotation in interface org.relaxng.datatype.ValidationContextpublic boolean isUnparsedEntity(String entityName)
isUnparsedEntity in interface org.relaxng.datatype.ValidationContextpublic String resolveNamespacePrefix(String prefix)
resolveNamespacePrefix in interface org.relaxng.datatype.ValidationContextpublic void onID(org.relaxng.datatype.Datatype datatype,
com.sun.msv.verifier.regexp.StringToken idToken)
throws IllegalArgumentException
Note: we have to throw a dummy marker exception, which merely signals that a validation problem is to be reported. This is obviously messy, but has to do for now.
onID in interface com.sun.msv.grammar.IDContextProvider2IllegalArgumentExceptionpublic XMLValidationSchema getSchema()
XMLValidatorValidatorPair
will return null since it 'contains' multiple validators
and generally does not have just one parent or owner schema.getSchema in class XMLValidatorpublic void validateElementStart(String localName, String uri, String prefix) throws XMLStreamException
validateElementStart in class XMLValidatorXMLStreamExceptionpublic String validateAttribute(String localName, String uri, String prefix, String value) throws XMLStreamException
XMLValidatorvalidateAttribute in class XMLValidatorXMLStreamExceptionpublic String validateAttribute(String localName, String uri, String prefix, char[] valueChars, int valueStart, int valueEnd) throws XMLStreamException
XMLValidatorvalidateAttribute in class XMLValidatorvalueChars - Character array that contains value (possibly
along with some other text)valueStart - Index of the first character of the value in
in valueChars arrayvalueEnd - Index of the character AFTER the last character;
so that the length of the value String is
valueEnd - valueStartXMLStreamExceptionpublic int validateElementAndAttributes()
throws XMLStreamException
XMLValidatorXMLValidator.validateAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String) on all
attributes (if any), but before starting to handle element
content.validateElementAndAttributes in class XMLValidatorCONTENT_ALLOW_ constants, to indicate
what kind of textual content is allowed at the scope returned
to after the element has closed.XMLStreamExceptionpublic int validateElementEnd(String localName, String uri, String prefix) throws XMLStreamException
XMLValidatorvalidateElementEnd in class XMLValidatorXMLStreamExceptionpublic void validateText(String text, boolean lastTextSegment) throws XMLStreamException
XMLValidator
Note: this method is only guaranteed to be called when
XMLValidator.validateElementAndAttributes() for the currently open
element returned XMLValidator.CONTENT_ALLOW_VALIDATABLE_TEXT (or,
in case of mixed content, XMLValidator.validateElementEnd(java.lang.String, java.lang.String, java.lang.String), for the
last enclosed element). Otherwise, validator context may choose
not to call the method as an optimization.
validateText in class XMLValidatortext - Text content to validatelastTextSegment - Whether this text content is the last text
segment before a close element; true if it is, false if it is not,
or no determination can be made. Can be used for optimizing
validation -- if this is true, no text needs to be buffered since
no more will be sent before the current element closes.XMLStreamExceptionpublic void validateText(char[] cbuf,
int textStart,
int textEnd,
boolean lastTextSegment)
throws XMLStreamException
XMLValidator
Note: this method is only guaranteed to be called when
XMLValidator.validateElementAndAttributes() for the currently open
element returned XMLValidator.CONTENT_ALLOW_VALIDATABLE_TEXT (or,
in case of mixed content, XMLValidator.validateElementEnd(java.lang.String, java.lang.String, java.lang.String), for the
last enclosed element). Otherwise, validator context may choose
not to call the method as an optimization.
validateText in class XMLValidatorcbuf - Character array that contains text content to validatetextStart - Index of the first character of the content to
validatetextEnd - Character following the last character of the
content to validate (that is, length of content to validate is
textEnd - textStart).lastTextSegment - Whether this text content is the last text
segment before a close element; true if it is, false if it is not,
or no determination can be made. Can be used for optimizing
validation -- if this is true, no text needs to be buffered since
no more will be sent before the current element closes.XMLStreamExceptionpublic void validationCompleted(boolean eod)
throws XMLStreamException
XMLValidatorvalidationCompleted in class XMLValidatoreod - Flag that indicates whether this method was called by the
context due to the end of the stream (true); or by an application
requesting end of validation (false).XMLStreamExceptionpublic String getAttributeType(int index)
XMLValidatorgetAttributeType in class XMLValidatorpublic int getIdAttrIndex()
XMLValidatorgetIdAttrIndex in class XMLValidatorpublic int getNotationAttrIndex()
XMLValidatorgetNotationAttrIndex in class XMLValidator