Class XMLRuleHandler

java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.languagetool.rules.patterns.XMLRuleHandler
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler
Direct Known Subclasses:
DisambiguationRuleHandler, FalseFriendRuleHandler, PatternRuleHandler

public class XMLRuleHandler extends DefaultHandler
XML rule handler that loads rules from XML and throws exceptions on errors and warnings.
  • Field Details

    • ID

      public static final String ID
      See Also:
    • NAME

      public static final String NAME
      See Also:
    • PREMIUM

      protected static final String PREMIUM
      Definitions of values in XML files.
      See Also:
    • YES

      protected static final String YES
      See Also:
    • OFF

      protected static final String OFF
      See Also:
    • GOAL_SPECIFIC

      protected static final String GOAL_SPECIFIC
      See Also:
    • TRUE

      protected static final String TRUE
      See Also:
    • FALSE

      protected static final String FALSE
      See Also:
    • TEMP_OFF

      protected static final String TEMP_OFF
      See Also:
    • ON

      protected static final String ON
      See Also:
    • POSTAG

      protected static final String POSTAG
      See Also:
    • CHUNKTAG

      protected static final String CHUNKTAG
      See Also:
    • CHUNKTAG_REGEXP

      protected static final String CHUNKTAG_REGEXP
      See Also:
    • POSTAG_REGEXP

      protected static final String POSTAG_REGEXP
      See Also:
    • REGEXP

      protected static final String REGEXP
      See Also:
    • NEGATE

      protected static final String NEGATE
      See Also:
    • INFLECTED

      protected static final String INFLECTED
      See Also:
    • NEGATE_POS

      protected static final String NEGATE_POS
      See Also:
    • MARKER

      protected static final String MARKER
      See Also:
    • DEFAULT

      protected static final String DEFAULT
      See Also:
    • TYPE

      protected static final String TYPE
      See Also:
    • SPACEBEFORE

      protected static final String SPACEBEFORE
      See Also:
    • EXAMPLE

      protected static final String EXAMPLE
      See Also:
    • SCOPE

      protected static final String SCOPE
      See Also:
    • IGNORE

      protected static final String IGNORE
      See Also:
    • SKIP

      protected static final String SKIP
      See Also:
    • MIN

      protected static final String MIN
      See Also:
    • MAX

      protected static final String MAX
      See Also:
    • TOKEN

      protected static final String TOKEN
      See Also:
    • FEATURE

      protected static final String FEATURE
      See Also:
    • UNIFY

      protected static final String UNIFY
      See Also:
    • UNIFY_IGNORE

      protected static final String UNIFY_IGNORE
      See Also:
    • AND

      protected static final String AND
      See Also:
    • OR

      protected static final String OR
      See Also:
    • EXCEPTION

      protected static final String EXCEPTION
      See Also:
    • CASE_SENSITIVE

      protected static final String CASE_SENSITIVE
      See Also:
    • MARK

      protected static final String MARK
      See Also:
    • PATTERN

      protected static final String PATTERN
      See Also:
    • ANTIPATTERN

      protected static final String ANTIPATTERN
      See Also:
    • MATCH

      protected static final String MATCH
      See Also:
    • UNIFICATION

      protected static final String UNIFICATION
      See Also:
    • RULE

      protected static final String RULE
      See Also:
    • RULES

      protected static final String RULES
      See Also:
    • RULEGROUP

      protected static final String RULEGROUP
      See Also:
    • NO

      protected static final String NO
      See Also:
    • PHRASES

      protected static final String PHRASES
      See Also:
    • MESSAGE

      protected static final String MESSAGE
      See Also:
    • SUGGESTION

      protected static final String SUGGESTION
      See Also:
    • TABNAME

      protected static final String TABNAME
      See Also:
    • MINPREVMATCHES

      protected static final String MINPREVMATCHES
      See Also:
    • DISTANCETOKENS

      protected static final String DISTANCETOKENS
      See Also:
    • PRIO

      protected static final String PRIO
      See Also:
    • rules

      protected List<AbstractPatternRule> rules
    • language

      protected Language language
    • messages

      protected ResourceBundle messages
    • correctExample

      protected StringBuilder correctExample
    • antiPatternExample

      protected StringBuilder antiPatternExample
    • antiPatternForRuleGroupExample

      protected StringBuilder antiPatternForRuleGroupExample
    • incorrectExample

      protected StringBuilder incorrectExample
    • errorTriggerExample

      protected StringBuilder errorTriggerExample
    • exampleCorrection

      protected StringBuilder exampleCorrection
    • message

      protected StringBuilder message
    • suggestionsOutMsg

      protected StringBuilder suggestionsOutMsg
    • match

      protected StringBuilder match
    • elements

      protected StringBuilder elements
    • exceptions

      protected StringBuilder exceptions
    • correctExamples

      protected List<CorrectExample> correctExamples
    • antipatternExamples

      protected List<CorrectExample> antipatternExamples
    • antipatternForRuleGroupsExamples

      protected List<CorrectExample> antipatternForRuleGroupsExamples
    • incorrectExamples

      protected List<IncorrectExample> incorrectExamples
    • errorTriggeringExamples

      protected List<ErrorTriggeringExample> errorTriggeringExamples
    • inPattern

      protected boolean inPattern
    • inCorrectExample

      protected boolean inCorrectExample
    • inIncorrectExample

      protected boolean inIncorrectExample
    • inErrorTriggerExample

      protected boolean inErrorTriggerExample
    • inAntiPatternExample

      protected boolean inAntiPatternExample
    • inAntiPatternForRuleGroupExample

      protected boolean inAntiPatternForRuleGroupExample
    • 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 String posToken
    • chunkTag

      protected ChunkTag chunkTag
    • posNegation

      protected boolean posNegation
    • posRegExp

      protected boolean posRegExp
    • caseSensitive

      protected boolean caseSensitive
    • regExpression

      protected boolean regExpression
    • tokenNegated

      protected boolean tokenNegated
    • tokenInflected

      protected boolean tokenInflected
    • premiumRuleGroupAttribute

      protected String premiumRuleGroupAttribute
    • premiumCategoryAttribute

      protected String premiumCategoryAttribute
    • premiumFileAttribute

      protected String premiumFileAttribute
    • isPremiumRule

      protected boolean isPremiumRule
    • categoryTags

      protected List<String> categoryTags
    • ruleGroupTags

      protected List<String> ruleGroupTags
    • ruleGroupToneTags

      protected List<String> ruleGroupToneTags
    • categoryToneTags

      protected List<String> categoryToneTags
    • ruleTags

      protected List<String> ruleTags
    • ruleToneTags

      protected List<String> ruleToneTags
    • isGoalSpecificCategoryAttribute

      protected String isGoalSpecificCategoryAttribute
    • isGoalSpecificRuleGroupAttribute

      protected String isGoalSpecificRuleGroupAttribute
    • isGoalSpecific

      protected boolean isGoalSpecific
    • prioCategoryAttribute

      protected int prioCategoryAttribute
    • prioRuleGroupAttribute

      protected int prioRuleGroupAttribute
    • prioRuleAttribute

      protected int prioRuleAttribute
    • tokenLevelCaseSensitive

      protected boolean tokenLevelCaseSensitive
    • tokenLevelCaseSet

      protected boolean tokenLevelCaseSet
    • exceptionPosToken

      protected 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 Boolean exceptionLevelCaseSensitive
    • exceptionLevelCaseSet

      protected boolean exceptionLevelCaseSet
    • patternTokens

      protected 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 String phraseIdRef
      ID reference to the phrase.
    • phraseId

      protected String phraseId
      Current phrase ID.
    • skipPos

      protected int skipPos
    • minOccurrence

      protected int minOccurrence
    • maxOccurrence

      protected int maxOccurrence
    • ruleGroupId

      protected String ruleGroupId
    • id

      protected String id
    • patternToken

      protected PatternToken patternToken
    • tokenReference

      protected Match tokenReference
    • suggestionMatches

      protected List<Match> suggestionMatches
    • suggestionMatchesOutMsg

      protected List<Match> suggestionMatchesOutMsg
    • pLocator

      protected Locator pLocator
    • xmlLineNumber

      protected int xmlLineNumber
    • xmlLineNumberAntiPattern

      protected int xmlLineNumberAntiPattern
    • startPositionCorrection

      protected int startPositionCorrection
    • endPositionCorrection

      protected int endPositionCorrection
    • tokenCounter

      protected int tokenCounter
    • phraseMap

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

      protected List<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 StringBuilder url
    • urlForRuleGroup

      protected StringBuilder urlForRuleGroup
    • inRegex

      protected boolean inRegex
    • regex

      protected StringBuilder regex
    • regexMode

      protected XMLRuleHandler.RegexpMode regexMode
    • regexCaseSensitive

      protected boolean regexCaseSensitive
    • regexpMark

      protected int regexpMark
    • inShortMessage

      protected boolean inShortMessage
    • inShortMessageForRuleGroup

      protected boolean inShortMessageForRuleGroup
    • shortMessage

      protected StringBuilder shortMessage
    • shortMessageForRuleGroup

      protected StringBuilder shortMessageForRuleGroup
    • inUnification

      protected boolean inUnification
    • inMarker

      protected boolean inMarker
    • inUnificationDef

      protected boolean inUnificationDef
    • uniNegation

      protected boolean uniNegation
    • inUnificationNeutral

      protected boolean inUnificationNeutral
    • uFeature

      protected String uFeature
    • uType

      protected String uType
    • uTypeList

      protected List<String> uTypeList
    • equivalenceFeatures

      protected Map<String,List<String>> equivalenceFeatures
    • internedMatchers

      private final Map<org.apache.commons.lang3.tuple.Triple<String,Boolean,Boolean>,StringMatcher> internedMatchers
    • internedPos

      private final Map<org.apache.commons.lang3.tuple.Triple<String,Boolean,Boolean>,PatternToken.PosToken> internedPos
  • Constructor Details

    • XMLRuleHandler

      public XMLRuleHandler()
  • Method Details