Class PatternMatcher
java.lang.Object
com.thaiopensource.relaxng.pattern.PatternMatcher
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal Object
clone()
copy()
Return a copy of the currentMatcher
.boolean
Test whether obj is an equivalentMatcher
.Return the current error message.int
hashCode()
Return a hashCode for the Matcher.boolean
Return true if text may be typed in the current state, false otherwise.boolean
Return true if the document is valid so far.boolean
matchAttributeName
(Name name, String qName, MatchContext context) Match an AttributeName event.boolean
matchAttributeValue
(String value, Name name, String qName, MatchContext context) Match an AttributeValue event.boolean
Match an EndDocument event.boolean
matchEndTag
(Name name, String qName, MatchContext context) Match an EndTag event.boolean
Match a StartDocument event.boolean
matchStartTagClose
(Name name, String qName, MatchContext context) Match a StartTagClose event.boolean
matchStartTagOpen
(Name name, String qName, MatchContext context) Match a StartTagOpen event.boolean
matchTextBeforeEndTag
(String string, Name name, String qName, MatchContext context) Match a Text event that occurs immediately before an EndTag event.boolean
matchTextBeforeStartTag
(String string, MatchContext context) Match a Text event that occurs immediately before a StartTagOpen event.boolean
matchUntypedText
(MatchContext context) An optimization ofmatchTextBeforeStartTag
/matchTextBeforeEndTag
.Return a NameClass containing the names of attributes that are valid in the current state.Return a NameClass containing the names of elements whose start-tags are valid in the current state.Return a Set containing the names of attributes that are required in the current state.start()
Return a copy of thisMatcher
reset to its starting state.
-
Constructor Details
-
PatternMatcher
-
-
Method Details
-
start
Description copied from interface:Matcher
Return a copy of thisMatcher
reset to its starting state. -
equals
Description copied from interface:Matcher
Test whether obj is an equivalentMatcher
. -
hashCode
public int hashCode()Description copied from interface:Matcher
Return a hashCode for the Matcher. This is consistent with equals. -
clone
-
copy
Description copied from interface:Matcher
Return a copy of the currentMatcher
. Future changes to the state of the copy will not affect this and vice-versa. -
matchStartDocument
public boolean matchStartDocument()Description copied from interface:Matcher
Match a StartDocument event. This can only generate an error if the schema was equivalent tonotAllowed
.- Specified by:
matchStartDocument
in interfaceMatcher
- Returns:
- false if there was an error, true otherwise
-
matchEndDocument
public boolean matchEndDocument()Description copied from interface:Matcher
Match an EndDocument event.- Specified by:
matchEndDocument
in interfaceMatcher
- Returns:
- false if there was an error, true otherwise
-
matchStartTagOpen
Description copied from interface:Matcher
Match a StartTagOpen event.- Specified by:
matchStartTagOpen
in interfaceMatcher
- Parameters:
name
- the element nameqName
- the element qName (may be empty or null if unknown)context
- the MatchContext- Returns:
- false if there was an error, true otherwise
-
matchAttributeName
Description copied from interface:Matcher
Match an AttributeName event.- Specified by:
matchAttributeName
in interfaceMatcher
- Parameters:
name
- the attribute nameqName
- the attribute qName (may be empty or null if unknown)context
- the MatchContext- Returns:
- false if there was an error, true otherwise
-
matchAttributeValue
Description copied from interface:Matcher
Match an AttributeValue event. The MatchContext must include all the namespace declarations in the start-tag including those that lexically follow the attribute.- Specified by:
matchAttributeValue
in interfaceMatcher
- Parameters:
value
- the attribute value, normalized in accordance with XML 1.0name
- the attribute name (included for use in error messages)qName
- the attribute qName (included for use in error messages)context
- the MatchContext- Returns:
- false if there was an error, true otherwise
-
matchStartTagClose
Description copied from interface:Matcher
Match a StartTagClose event. This corresponds to the>
character that ends the start-tag). It may cause an error if there are required attributes that have not been matched. The parameters are used to generate error messages.- Specified by:
matchStartTagClose
in interfaceMatcher
- Parameters:
name
- the element nameqName
- the element qName (may be null or empty)context
- the MatchContext- Returns:
- false if there was an error, true otherwise
-
matchTextBeforeEndTag
Description copied from interface:Matcher
Match a Text event that occurs immediately before an EndTag event. All text between two tags must be collected together: consecutive calls tomatchTextBeforeEndTag
/matchTextBeforeStartTag
are not allowed unless separated by a call tomatchStartTagOpen
ormatchEndTag
. Calls tomatchTextBeforeEndTag
can sometimes be optimized into calls tomatchUntypedText
.- Specified by:
matchTextBeforeEndTag
in interfaceMatcher
- Parameters:
string
- the text to be matchedname
- the name of the parent element (i.e. the name of the element of the following EndTag event)qName
- the qName of the parent elementcontext
- a match context- Returns:
- false if there was an error, true otherwise
-
matchTextBeforeStartTag
Description copied from interface:Matcher
Match a Text event that occurs immediately before a StartTagOpen event. All text between two tags must be collected together: consecutive calls tomatchTextBeforeEndTag
/matchTextBeforeStartTag
are not allowed unless separated by a call tomatchStartTagOpen
ormatchEndTag
. Calls tomatchTextBeforeStartTag
can sometimes be optimized into calls tomatchUntypedText
.- Specified by:
matchTextBeforeStartTag
in interfaceMatcher
- Parameters:
string
- the text to be matchedcontext
- a match context- Returns:
- false if there was an error, true otherwise
-
matchUntypedText
Description copied from interface:Matcher
An optimization ofmatchTextBeforeStartTag
/matchTextBeforeEndTag
. Unlike these functions,matchUntypedText
does not need to examine the text. IfisTextTyped
returns false, then in this state text that consists of whitespace (' ', '\r', '\n', '\t') may be ignored and text that contains non-whitespace characters may be processed usingmatchUntypedText
. Furthermore it is not necessary to collect up all the text between tags; consecutive calls tomatchUntypedText
are allowed.matchUntypedText
must not be used unlessisTextTyped
returns false.- Specified by:
matchUntypedText
in interfaceMatcher
- Parameters:
context
- a match context- Returns:
- false if there was an error, true otherwise
-
isTextTyped
public boolean isTextTyped()Description copied from interface:Matcher
Return true if text may be typed in the current state, false otherwise. If text may be typed, then a call tomatchText
must not be optimized tomatchUntypedText
.- Specified by:
isTextTyped
in interfaceMatcher
- Returns:
- true if text may be typed, false otherwise
-
matchEndTag
Description copied from interface:Matcher
Match an EndTag event.- Specified by:
matchEndTag
in interfaceMatcher
- Parameters:
name
- the element nameqName
- the elememt qname (may be empty or null if unknown)context
- a match context- Returns:
- false if there was an error, true otherwise
-
getErrorMessage
Description copied from interface:Matcher
Return the current error message. The current error message is changed by anymatchE
method that returns false. Initially, the current error message is null.- Specified by:
getErrorMessage
in interfaceMatcher
- Returns:
- a string with the current error message, or null if there has not yet been an error.
-
isValidSoFar
public boolean isValidSoFar()Description copied from interface:Matcher
Return true if the document is valid so far. A document is valid so far if and only if no errors have yet been encountered.- Specified by:
isValidSoFar
in interfaceMatcher
- Returns:
- true if the document is valid so far, false otherwise
-
possibleStartTagNames
Description copied from interface:Matcher
Return a NameClass containing the names of elements whose start-tags are valid in the current state. This must be called only in a state in which a call tomatchStartTagOpen
would be allowed.- Specified by:
possibleStartTagNames
in interfaceMatcher
- Returns:
- a NameClass contains the names of elements whose start-tags are possible
-
possibleAttributeNames
Description copied from interface:Matcher
Return a NameClass containing the names of attributes that are valid in the current state. This must be called only in a state in which a call tomatchAttributeName
would be allowed.- Specified by:
possibleAttributeNames
in interfaceMatcher
- Returns:
- a NameClass containing the names of attributes that are possible
-
requiredElementNames
- Specified by:
requiredElementNames
in interfaceMatcher
-
requiredAttributeNames
Description copied from interface:Matcher
Return a Set containing the names of attributes that are required in the current state. This must be called only in a state in which a call tomatchAttributeName
would be allowed. Note that in a schema such as attribute foo|bar { text } neither foo nor bar are considered required attributes; an attribute name x is required only if every matching pattern contains an attribute named x. Similarly, this function provides no information about wildcard attribute names.- Specified by:
requiredAttributeNames
in interfaceMatcher
- Returns:
- a non-null Set each member of which is a non-null Name corresponding to the name of a required attribute
- See Also:
-