Class PatternMatcher

java.lang.Object
com.thaiopensource.relaxng.pattern.PatternMatcher
All Implemented Interfaces:
Matcher, Cloneable

public class PatternMatcher extends Object implements Cloneable, Matcher
  • Constructor Details

  • Method Details

    • start

      public Matcher start()
      Description copied from interface: Matcher
      Return a copy of this Matcher reset to its starting state.
      Specified by:
      start in interface Matcher
      Returns:
      a new Matcher
    • equals

      public boolean equals(Object obj)
      Description copied from interface: Matcher
      Test whether obj is an equivalent Matcher.
      Specified by:
      equals in interface Matcher
      Overrides:
      equals in class Object
      Returns:
      true if they are obj is known to be equivalent, false otherwise
    • hashCode

      public int hashCode()
      Description copied from interface: Matcher
      Return a hashCode for the Matcher. This is consistent with equals.
      Specified by:
      hashCode in interface Matcher
      Overrides:
      hashCode in class Object
      Returns:
      a hash code
    • clone

      public final Object clone()
      Overrides:
      clone in class Object
    • copy

      public Matcher copy()
      Description copied from interface: Matcher
      Return a copy of the current Matcher. Future changes to the state of the copy will not affect this and vice-versa.
      Specified by:
      copy in interface Matcher
      Returns:
      a Matcher that is a copy of this
    • matchStartDocument

      public boolean matchStartDocument()
      Description copied from interface: Matcher
      Match a StartDocument event. This can only generate an error if the schema was equivalent to notAllowed.
      Specified by:
      matchStartDocument in interface Matcher
      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 interface Matcher
      Returns:
      false if there was an error, true otherwise
    • matchStartTagOpen

      public boolean matchStartTagOpen(Name name, String qName, MatchContext context)
      Description copied from interface: Matcher
      Match a StartTagOpen event.
      Specified by:
      matchStartTagOpen in interface Matcher
      Parameters:
      name - the element name
      qName - the element qName (may be empty or null if unknown)
      context - the MatchContext
      Returns:
      false if there was an error, true otherwise
    • matchAttributeName

      public boolean matchAttributeName(Name name, String qName, MatchContext context)
      Description copied from interface: Matcher
      Match an AttributeName event.
      Specified by:
      matchAttributeName in interface Matcher
      Parameters:
      name - the attribute name
      qName - the attribute qName (may be empty or null if unknown)
      context - the MatchContext
      Returns:
      false if there was an error, true otherwise
    • matchAttributeValue

      public boolean matchAttributeValue(String value, Name name, String qName, MatchContext context)
      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 interface Matcher
      Parameters:
      value - the attribute value, normalized in accordance with XML 1.0
      name - 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

      public boolean matchStartTagClose(Name name, String qName, MatchContext context)
      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 interface Matcher
      Parameters:
      name - the element name
      qName - the element qName (may be null or empty)
      context - the MatchContext
      Returns:
      false if there was an error, true otherwise
    • matchTextBeforeEndTag

      public boolean matchTextBeforeEndTag(String string, Name name, String qName, MatchContext context)
      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 to matchTextBeforeEndTag/matchTextBeforeStartTag are not allowed unless separated by a call to matchStartTagOpen or matchEndTag. Calls to matchTextBeforeEndTag can sometimes be optimized into calls to matchUntypedText.
      Specified by:
      matchTextBeforeEndTag in interface Matcher
      Parameters:
      string - the text to be matched
      name - the name of the parent element (i.e. the name of the element of the following EndTag event)
      qName - the qName of the parent element
      context - a match context
      Returns:
      false if there was an error, true otherwise
    • matchTextBeforeStartTag

      public boolean matchTextBeforeStartTag(String string, MatchContext context)
      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 to matchTextBeforeEndTag/matchTextBeforeStartTag are not allowed unless separated by a call to matchStartTagOpen or matchEndTag. Calls to matchTextBeforeStartTag can sometimes be optimized into calls to matchUntypedText.
      Specified by:
      matchTextBeforeStartTag in interface Matcher
      Parameters:
      string - the text to be matched
      context - a match context
      Returns:
      false if there was an error, true otherwise
    • matchUntypedText

      public boolean matchUntypedText(MatchContext context)
      Description copied from interface: Matcher
      An optimization of matchTextBeforeStartTag/matchTextBeforeEndTag. Unlike these functions, matchUntypedText does not need to examine the text. If isTextTyped 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 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.
      Specified by:
      matchUntypedText in interface Matcher
      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 to matchText must not be optimized to matchUntypedText.
      Specified by:
      isTextTyped in interface Matcher
      Returns:
      true if text may be typed, false otherwise
    • matchEndTag

      public boolean matchEndTag(Name name, String qName, MatchContext context)
      Description copied from interface: Matcher
      Match an EndTag event.
      Specified by:
      matchEndTag in interface Matcher
      Parameters:
      name - the element name
      qName - the elememt qname (may be empty or null if unknown)
      context - a match context
      Returns:
      false if there was an error, true otherwise
    • getErrorMessage

      public String getErrorMessage()
      Description copied from interface: Matcher
      Return the current error message. The current error message is changed by any matchE method that returns false. Initially, the current error message is null.
      Specified by:
      getErrorMessage in interface Matcher
      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 interface Matcher
      Returns:
      true if the document is valid so far, false otherwise
    • possibleStartTagNames

      public NameClass 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 to matchStartTagOpen would be allowed.
      Specified by:
      possibleStartTagNames in interface Matcher
      Returns:
      a NameClass contains the names of elements whose start-tags are possible
    • possibleAttributeNames

      public NameClass 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 to matchAttributeName would be allowed.
      Specified by:
      possibleAttributeNames in interface Matcher
      Returns:
      a NameClass containing the names of attributes that are possible
    • requiredElementNames

      public Set<Name> requiredElementNames()
      Specified by:
      requiredElementNames in interface Matcher
    • requiredAttributeNames

      public Set<Name> 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 to matchAttributeName 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 interface Matcher
      Returns:
      a non-null Set each member of which is a non-null Name corresponding to the name of a required attribute
      See Also: