Package org.languagetool.rules.patterns
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
XML rule handler that loads rules from XML and throws
exceptions on errors and warnings.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final String
protected int
protected static final String
protected static final String
protected boolean
protected ChunkTag
protected static final String
protected StringBuilder
protected List<CorrectExample>
protected static final String
protected StringBuilder
protected int
protected StringBuilder
protected List<ErrorTriggeringExample>
protected static final String
protected StringBuilder
protected static final String
protected Boolean
protected boolean
protected boolean
protected boolean
protected String
protected StringBuilder
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected static final String
protected String
static final String
protected static final String
protected boolean
protected StringBuilder
protected boolean
protected List<IncorrectExample>
protected boolean
protected boolean
protected static final String
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected Language
protected boolean
true when phraseref is the last element in the rule.protected static final String
protected static final String
protected StringBuilder
protected static final String
protected static final String
protected int
protected StringBuilder
protected static final String
protected static final String
protected int
static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected int
protected static final String
protected PatternToken
protected List<PatternToken>
List of elements as specified by tokens.protected String
Current phrase ID.protected String
ID reference to the phrase.protected Map<String,
List<List<PatternToken>>> Phrase store - elementLists keyed by phraseIds.protected List<ArrayList<PatternToken>>
Logically forking element list, used for including multiple phrases in the current one.protected static final String
protected Locator
protected boolean
protected boolean
protected static final String
protected static final String
protected String
protected StringBuilder
protected boolean
protected XMLRuleHandler.RegexpMode
protected static final String
protected int
protected boolean
protected static final String
protected static final String
protected String
protected List<AbstractPatternRule>
protected static final String
protected static final String
protected StringBuilder
protected StringBuilder
protected static final String
protected int
protected static final String
protected int
protected static final String
protected StringBuilder
protected static final String
protected static final String
protected static final String
protected int
protected boolean
protected boolean
protected boolean
protected boolean
protected Match
protected boolean
protected boolean
protected static final String
protected String
protected static final String
protected static final String
protected static final String
protected boolean
protected StringBuilder
protected StringBuilder
protected String
protected static final String
Definitions of values in XML files. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddLegacyMatches
(List<Match> existingSugMatches, String messageStr, boolean inMessage) Adds Match objects for all references to tokens (including '\1' and the like).private void
checkNumber
(Attributes attrs) private void
checkRefNumber
(int refNumber) void
protected void
protected void
protected void
getRules()
protected void
preparePhrase
(Attributes attrs) protected void
processElement
(List<PatternToken> patternTokens) Calculates the offset of the match reference (if any) in case the match element has been used in the group.protected void
protected void
void
setDocumentLocator
(Locator locator) protected void
setExceptions
(Attributes attrs) protected void
setMatchElement
(Attributes attrs) protected void
setRuleFilter
(String filterClassName, String filterArgs, AbstractPatternRule rule) protected void
setToken
(Attributes attrs) protected void
startPattern
(Attributes attrs) void
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.xml.sax.ContentHandler
declaration
-
Field Details
-
ID
- See Also:
-
NAME
- See Also:
-
YES
Definitions of values in XML files.- See Also:
-
OFF
- See Also:
-
TEMP_OFF
- See Also:
-
ON
- See Also:
-
POSTAG
- See Also:
-
CHUNKTAG
- See Also:
-
POSTAG_REGEXP
- See Also:
-
REGEXP
- See Also:
-
NEGATE
- See Also:
-
INFLECTED
- See Also:
-
NEGATE_POS
- See Also:
-
MARKER
- See Also:
-
DEFAULT
- See Also:
-
TYPE
- See Also:
-
SPACEBEFORE
- See Also:
-
EXAMPLE
- See Also:
-
SCOPE
- See Also:
-
IGNORE
- See Also:
-
SKIP
- See Also:
-
MIN
- See Also:
-
MAX
- See Also:
-
TOKEN
- See Also:
-
FEATURE
- See Also:
-
UNIFY
- See Also:
-
UNIFY_IGNORE
- See Also:
-
AND
- See Also:
-
OR
- See Also:
-
EXCEPTION
- See Also:
-
CASE_SENSITIVE
- See Also:
-
MARK
- See Also:
-
PATTERN
- See Also:
-
ANTIPATTERN
- See Also:
-
MATCH
- See Also:
-
UNIFICATION
- See Also:
-
RULE
- See Also:
-
RULES
- See Also:
-
RULEGROUP
- See Also:
-
NO
- See Also:
-
PHRASES
- See Also:
-
MESSAGE
- See Also:
-
SUGGESTION
- See Also:
-
TABNAME
- See Also:
-
rules
-
language
-
correctExample
-
incorrectExample
-
errorTriggerExample
-
exampleCorrection
-
message
-
suggestionsOutMsg
-
match
-
elements
-
exceptions
-
correctExamples
-
incorrectExamples
-
errorTriggeringExamples
-
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
-
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 -
tokenLevelCaseSensitive
protected boolean tokenLevelCaseSensitive -
tokenLevelCaseSet
protected boolean tokenLevelCaseSet -
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
-
exceptionLevelCaseSet
protected boolean exceptionLevelCaseSet -
patternTokens
List of elements as specified by tokens. -
lastPhrase
protected boolean lastPhrasetrue when phraseref is the last element in the rule. -
phraseIdRef
ID reference to the phrase. -
phraseId
Current phrase ID. -
skipPos
protected int skipPos -
minOccurrence
protected int minOccurrence -
maxOccurrence
protected int maxOccurrence -
ruleGroupId
-
id
-
patternToken
-
tokenReference
-
suggestionMatches
-
suggestionMatchesOutMsg
-
pLocator
-
startPositionCorrection
protected int startPositionCorrection -
endPositionCorrection
protected int endPositionCorrection -
tokenCounter
protected int tokenCounter -
phraseMap
Phrase store - elementLists keyed by phraseIds. -
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
-
urlForRuleGroup
-
inRegex
protected boolean inRegex -
regex
-
regexMode
-
regexCaseSensitive
protected boolean regexCaseSensitive -
regexpMark
protected int regexpMark -
inShortMessage
protected boolean inShortMessage -
inShortMessageForRuleGroup
protected boolean inShortMessageForRuleGroup -
shortMessage
-
shortMessageForRuleGroup
-
inUnification
protected boolean inUnification -
inMarker
protected boolean inMarker -
inUnificationDef
protected boolean inUnificationDef -
uniNegation
protected boolean uniNegation -
inUnificationNeutral
protected boolean inUnificationNeutral -
uFeature
-
uType
-
uTypeList
-
equivalenceFeatures
-
-
Constructor Details
-
XMLRuleHandler
public XMLRuleHandler()
-
-
Method Details
-
getRules
-
warning
- Specified by:
warning
in interfaceErrorHandler
- Overrides:
warning
in classDefaultHandler
- Throws:
SAXException
-
error
- Specified by:
error
in interfaceErrorHandler
- Overrides:
error
in classDefaultHandler
- Throws:
SAXException
-
setDocumentLocator
- Specified by:
setDocumentLocator
in interfaceContentHandler
- Overrides:
setDocumentLocator
in classDefaultHandler
-
resetToken
protected void resetToken() -
resetException
protected void resetException() -
preparePhrase
-
finalizePhrase
protected void finalizePhrase() -
startPattern
- Throws:
SAXException
-
processElement
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
- Throws:
SAXException
-
checkNumber
- Throws:
SAXException
-
checkRefNumber
- Throws:
SAXException
-
setExceptions
-
finalizeExceptions
protected void finalizeExceptions() -
setToken
-
addLegacyMatches
@Nullable protected @Nullable List<Match> addLegacyMatches(List<Match> existingSugMatches, String messageStr, boolean inMessage) Adds Match objects for all references to tokens (including '\1' and the like). -
finalizeTokens
- Throws:
SAXException
-
setRuleFilter
-