public interface Matcher
matchE on the
Matcher object. The kinds of event are:
The method calls must occur in an order corresponding to a well-formed XML document. In a well-formed document the sequence of events matches the following grammar:
document ::= StartDocument element element ::= startTag child* EndTag startTag ::= StartTagOpen attribute* StartTagClose attribute ::= AttributeName AttributeValue child ::= element | Text
Text events must be maximal. Two consecutive Text events are not allowed.
Each method matchE returns false if matching
the event against the document resulted in an error and true otherwise.
If it returned false, then the error message can be obtained using
getErrorMessage. In either case, the state of the
Matcher changes so the Matcher is prepared
to match the next event.
The copy() and equals() methods allow
applications to perform incremental revalidation.
| Modifier and Type | Method and Description |
|---|---|
Matcher |
copy()
Return a copy of the current
Matcher. |
boolean |
equals(java.lang.Object obj)
Return true if obj is an equivalent
Matcher. |
java.lang.String |
getErrorMessage()
Return the current error message.
|
boolean |
isTextTyped()
Return true if text may be typed in the current state, false otherwise.
|
boolean |
isValidSoFar()
Return true if the document is valid so far.
|
boolean |
matchAttributeName(Name name) |
boolean |
matchAttributeValue(Name name,
java.lang.String value,
ValidationContext vc)
Match an attribute value.
|
boolean |
matchEndTag(ValidationContext vc)
Match an end-tag.
|
boolean |
matchStartDocument()
This can only generate an error if the schema was
equivalent to
notAllowed. |
boolean |
matchStartTagClose()
Match the close of a start-tag (the
> character that ends the start-tag). |
boolean |
matchStartTagOpen(Name name) |
boolean |
matchText(java.lang.String string,
ValidationContext vc,
boolean nextTagIsEndTag)
Match a text event.
|
boolean |
matchUntypedText()
An optimization of
matchText. |
java.util.Set |
possibleAttributes(java.util.Set knownNames)
Return a Set of the names of attributes that are valid
in the current state.
|
java.util.Set |
possibleStartTags(java.util.Set knownNames)
Return a Set of the names of elements whose start-tags are valid
in the current state.
|
Matcher copy()
Matcher.
Future changes to the state of the copy will not affect this and vice-versa.Matcher that is a copy of thisboolean equals(java.lang.Object obj)
Matcher.equals in class java.lang.Objectboolean matchStartDocument()
notAllowed.boolean matchStartTagOpen(Name name)
boolean matchAttributeName(Name name)
boolean matchAttributeValue(Name name, java.lang.String value, ValidationContext vc)
name - the attribute name (included for use in error messages)value - the attribute value, normalized in accordance with XML 1.0vc - a validation contextboolean matchStartTagClose()
> character that ends the start-tag).
This may cause an error if there are required attributes that have not been matched.boolean matchText(java.lang.String string,
ValidationContext vc,
boolean nextTagIsEndTag)
matchText are not allowed unless separated
by a call to matchStartTagOpen or matchEndTag.
Calls to matchText can sometimes be optimized into
calls to matchUntypedText.string - the text to be matchedvc - a validation contextnextTagIsEndTag - true if the next event is an EndTag, false if it is
a StartTagOpenboolean matchUntypedText()
matchText.
Unlike matchText, matchUntypedText does not
need to examine the text.
If isTextTyped returns false, then in this state
text that consists of whitespace may be ignored and text that contains
non-whitespace characters may be processed using matchUntypedText.
Furthermore it is not necessary to collect up all the text between tags;
consecutive calls to matchUntypedText are allowed.
matchUntypedText must not be used unless isTextTyped
returns false.boolean isTextTyped()
matchText must not be optimized
to matchUntypedText.boolean matchEndTag(ValidationContext vc)
vc - a validation contextjava.lang.String getErrorMessage()
matchE method
that returns false. Initially, the current error message is null.boolean isValidSoFar()
java.util.Set possibleStartTags(java.util.Set knownNames)
matchStartTagOpen would be allowed.
The members of the Set have type com.thaiopensource.xml.util.Name.
When an element pattern with a wildcard name-class is possible, then all
Names in knownNames that are contained in the wildcard name-class will be
included in the returned Set. The returned list may contain duplicates.
Does not modify knownNames.knownNames - a Set of names to be considered for wildcards, or nulljava.util.Set possibleAttributes(java.util.Set knownNames)
matchAttributeName would be allowed.
The members of the Set have type com.thaiopensource.xml.util.Name.
When an attribute pattern with a wildcard name-class is possible, then all
Names in knownNames that are contained in the wildcard name-class will be
included in the returned Set. The returned list may contain duplicates.
Does not modify knownNames.knownNames - a Set of names to be considered for wildcards, or null