Class XMLRuleHandler

  • All Implemented Interfaces:
    org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler
    Direct Known Subclasses:
    DisambiguationRuleHandler, FalseFriendRuleHandler, PatternRuleHandler

    public class XMLRuleHandler
    extends org.xml.sax.helpers.DefaultHandler
    XML rule handler that loads rules from XML and throws exceptions on errors and warnings.
    • Field Detail

      • YES

        protected static final java.lang.String YES
        Definitions of values in XML files.
        See Also:
        Constant Field Values
      • correctExample

        protected java.lang.StringBuilder correctExample
      • incorrectExample

        protected java.lang.StringBuilder incorrectExample
      • errorTriggerExample

        protected java.lang.StringBuilder errorTriggerExample
      • exampleCorrection

        protected java.lang.StringBuilder exampleCorrection
      • message

        protected java.lang.StringBuilder message
      • suggestionsOutMsg

        protected java.lang.StringBuilder suggestionsOutMsg
      • match

        protected java.lang.StringBuilder match
      • elements

        protected java.lang.StringBuilder elements
      • exceptions

        protected java.lang.StringBuilder exceptions
      • correctExamples

        protected java.util.List<CorrectExample> correctExamples
      • incorrectExamples

        protected java.util.List<IncorrectExample> incorrectExamples
      • inPattern

        protected boolean inPattern
      • inCorrectExample

        protected boolean inCorrectExample
      • inIncorrectExample

        protected boolean inIncorrectExample
      • inErrorTriggerExample

        protected boolean inErrorTriggerExample
      • inMessage

        protected boolean inMessage
      • inSuggestion

        protected boolean inSuggestion
      • inMatch

        protected boolean inMatch
      • inRuleGroup

        protected boolean inRuleGroup
      • inToken

        protected boolean inToken
      • inException

        protected boolean inException
      • inPhrases

        protected boolean inPhrases
      • inAndGroup

        protected boolean inAndGroup
      • inOrGroup

        protected boolean inOrGroup
      • tokenSpaceBefore

        protected boolean tokenSpaceBefore
      • tokenSpaceBeforeSet

        protected boolean tokenSpaceBeforeSet
      • posToken

        protected java.lang.String posToken
      • posNegation

        protected boolean posNegation
      • posRegExp

        protected boolean posRegExp
      • caseSensitive

        protected boolean caseSensitive
      • regExpression

        protected boolean regExpression
      • tokenNegated

        protected boolean tokenNegated
      • tokenInflected

        protected boolean tokenInflected
      • tokenLevelCaseSensitive

        protected boolean tokenLevelCaseSensitive
      • tokenLevelCaseSet

        protected boolean tokenLevelCaseSet
      • exceptionPosToken

        protected java.lang.String exceptionPosToken
      • exceptionStringRegExp

        protected boolean exceptionStringRegExp
      • exceptionStringNegation

        protected boolean exceptionStringNegation
      • exceptionStringInflected

        protected boolean exceptionStringInflected
      • exceptionPosNegation

        protected boolean exceptionPosNegation
      • exceptionPosRegExp

        protected boolean exceptionPosRegExp
      • exceptionValidNext

        protected boolean exceptionValidNext
      • exceptionValidPrev

        protected boolean exceptionValidPrev
      • exceptionSet

        protected boolean exceptionSet
      • exceptionSpaceBefore

        protected boolean exceptionSpaceBefore
      • exceptionSpaceBeforeSet

        protected boolean exceptionSpaceBeforeSet
      • exceptionLevelCaseSensitive

        protected java.lang.Boolean exceptionLevelCaseSensitive
      • exceptionLevelCaseSet

        protected boolean exceptionLevelCaseSet
      • patternTokens

        protected java.util.List<PatternToken> patternTokens
        List of elements as specified by tokens.
      • lastPhrase

        protected boolean lastPhrase
        true when phraseref is the last element in the rule.
      • phraseIdRef

        protected java.lang.String phraseIdRef
        ID reference to the phrase.
      • phraseId

        protected java.lang.String phraseId
        Current phrase ID.
      • skipPos

        protected int skipPos
      • minOccurrence

        protected int minOccurrence
      • maxOccurrence

        protected int maxOccurrence
      • ruleGroupId

        protected java.lang.String ruleGroupId
      • id

        protected java.lang.String id
      • tokenReference

        protected Match tokenReference
      • suggestionMatches

        protected java.util.List<Match> suggestionMatches
      • suggestionMatchesOutMsg

        protected java.util.List<Match> suggestionMatchesOutMsg
      • pLocator

        protected org.xml.sax.Locator pLocator
      • startPositionCorrection

        protected int startPositionCorrection
      • endPositionCorrection

        protected int endPositionCorrection
      • tokenCounter

        protected int tokenCounter
      • phraseMap

        protected java.util.Map<java.lang.String,​java.util.List<java.util.List<PatternToken>>> phraseMap
        Phrase store - elementLists keyed by phraseIds.
      • phrasePatternTokens

        protected java.util.List<java.util.ArrayList<PatternToken>> phrasePatternTokens
        Logically forking element list, used for including multiple phrases in the current one.
      • andGroupCounter

        protected int andGroupCounter
      • orGroupCounter

        protected int orGroupCounter
      • inUrl

        protected boolean inUrl
      • inUrlForRuleGroup

        protected boolean inUrlForRuleGroup
      • url

        protected java.lang.StringBuilder url
      • urlForRuleGroup

        protected java.lang.StringBuilder urlForRuleGroup
      • inRegex

        protected boolean inRegex
      • regex

        protected java.lang.StringBuilder regex
      • regexCaseSensitive

        protected boolean regexCaseSensitive
      • regexpMark

        protected int regexpMark
      • inShortMessage

        protected boolean inShortMessage
      • inShortMessageForRuleGroup

        protected boolean inShortMessageForRuleGroup
      • shortMessage

        protected java.lang.StringBuilder shortMessage
      • shortMessageForRuleGroup

        protected java.lang.StringBuilder shortMessageForRuleGroup
      • inUnification

        protected boolean inUnification
      • inMarker

        protected boolean inMarker
      • inUnificationDef

        protected boolean inUnificationDef
      • uniNegation

        protected boolean uniNegation
      • inUnificationNeutral

        protected boolean inUnificationNeutral
      • uFeature

        protected java.lang.String uFeature
      • uType

        protected java.lang.String uType
      • uTypeList

        protected java.util.List<java.lang.String> uTypeList
      • equivalenceFeatures

        protected java.util.Map<java.lang.String,​java.util.List<java.lang.String>> equivalenceFeatures
    • Constructor Detail

      • XMLRuleHandler

        public XMLRuleHandler()
    • Method Detail

      • warning

        public void warning​(org.xml.sax.SAXParseException e)
                     throws org.xml.sax.SAXException
        Specified by:
        warning in interface org.xml.sax.ErrorHandler
        Overrides:
        warning in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • error

        public void error​(org.xml.sax.SAXParseException e)
                   throws org.xml.sax.SAXException
        Specified by:
        error in interface org.xml.sax.ErrorHandler
        Overrides:
        error in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • setDocumentLocator

        public void setDocumentLocator​(org.xml.sax.Locator locator)
        Specified by:
        setDocumentLocator in interface org.xml.sax.ContentHandler
        Overrides:
        setDocumentLocator in class org.xml.sax.helpers.DefaultHandler
      • resetToken

        protected void resetToken()
      • resetException

        protected void resetException()
      • preparePhrase

        protected void preparePhrase​(org.xml.sax.Attributes attrs)
      • finalizePhrase

        protected void finalizePhrase()
      • startPattern

        protected void startPattern​(org.xml.sax.Attributes attrs)
                             throws org.xml.sax.SAXException
        Throws:
        org.xml.sax.SAXException
      • processElement

        protected void processElement​(java.util.List<PatternToken> patternTokens)
        Calculates the offset of the match reference (if any) in case the match element has been used in the group.
        Parameters:
        patternTokens - token list where the match element was used. It is directly changed.
      • setMatchElement

        protected void setMatchElement​(org.xml.sax.Attributes attrs)
                                throws org.xml.sax.SAXException
        Throws:
        org.xml.sax.SAXException
      • checkNumber

        private void checkNumber​(org.xml.sax.Attributes attrs)
                          throws org.xml.sax.SAXException
        Throws:
        org.xml.sax.SAXException
      • checkRefNumber

        private void checkRefNumber​(int refNumber)
                             throws org.xml.sax.SAXException
        Throws:
        org.xml.sax.SAXException
      • setExceptions

        protected void setExceptions​(org.xml.sax.Attributes attrs)
      • finalizeExceptions

        protected void finalizeExceptions()
      • setToken

        protected void setToken​(org.xml.sax.Attributes attrs)
      • addLegacyMatches

        @Nullable
        protected @Nullable java.util.List<Match> addLegacyMatches​(java.util.List<Match> existingSugMatches,
                                                                   java.lang.String messageStr,
                                                                   boolean inMessage)
        Adds Match objects for all references to tokens (including '\1' and the like).
      • finalizeTokens

        protected void finalizeTokens()
                               throws org.xml.sax.SAXException
        Throws:
        org.xml.sax.SAXException
      • setRuleFilter

        protected void setRuleFilter​(java.lang.String filterClassName,
                                     java.lang.String filterArgs,
                                     AbstractPatternRule rule)