Package org.languagetool.rules
Class AbstractDateCheckFilter
- java.lang.Object
-
- org.languagetool.rules.patterns.RuleFilter
-
- org.languagetool.rules.AbstractDateCheckFilter
-
public abstract class AbstractDateCheckFilter extends RuleFilter
Accepts rule matches if a date doesn't match the accompanying weekday, e.g. ifMonday, 8 November 2003
isn't actually a Monday. Replaces{realDay}
with the real day of the date in the rule's message, and{day}
with the claimed day from the text (might be useful in case the text uses an abbreviation).- Since:
- 2.7
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.regex.Pattern
DAY_OF_MONTH_PATTERN
-
Constructor Summary
Constructors Constructor Description AbstractDateCheckFilter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description RuleMatch
acceptRuleMatch(RuleMatch match, java.util.Map<java.lang.String,java.lang.String> args, int patternTokenPos, AnalyzedTokenReadings[] patternTokens)
Returns the original rule match or a modified one, ornull
if the rule match is filtered out.protected abstract java.util.Calendar
getCalendar()
private java.util.Calendar
getDate(java.util.Map<java.lang.String,java.lang.String> args)
protected int
getDayOfMonth(java.lang.String localizedDayOfMonth)
Implement so that "first" returns1
, second returns2
etc.private int
getDayOfMonthFromArguments(java.util.Map<java.lang.String,java.lang.String> args)
protected abstract int
getDayOfWeek(java.lang.String localizedWeekDayString)
Implement so that Sunday returns1
, Monday2
etc.protected abstract java.lang.String
getDayOfWeek(java.util.Calendar date)
Get the localized name of the day of week for the given date.protected abstract int
getMonth(java.lang.String localizedMonth)
Implement so that January returns1
, February2
etc.private int
getMonthFromArguments(java.util.Map<java.lang.String,java.lang.String> args)
-
Methods inherited from class org.languagetool.rules.patterns.RuleFilter
getRequired, matches
-
-
-
-
Method Detail
-
getDayOfWeek
protected abstract int getDayOfWeek(java.lang.String localizedWeekDayString)
Implement so that Sunday returns1
, Monday2
etc.- Parameters:
localizedWeekDayString
- a week day name or abbreviation thereof
-
getDayOfWeek
protected abstract java.lang.String getDayOfWeek(java.util.Calendar date)
Get the localized name of the day of week for the given date.
-
getDayOfMonth
protected int getDayOfMonth(java.lang.String localizedDayOfMonth)
Implement so that "first" returns1
, second returns2
etc.- Parameters:
localizedDayOfMonth
- name of day of the month or abbreviation thereof
-
getMonth
protected abstract int getMonth(java.lang.String localizedMonth)
Implement so that January returns1
, February2
etc.- Parameters:
localizedMonth
- name of a month or abbreviation thereof
-
getCalendar
protected abstract java.util.Calendar getCalendar()
-
acceptRuleMatch
public RuleMatch acceptRuleMatch(RuleMatch match, java.util.Map<java.lang.String,java.lang.String> args, int patternTokenPos, AnalyzedTokenReadings[] patternTokens)
Description copied from class:RuleFilter
Returns the original rule match or a modified one, ornull
if the rule match is filtered out.- Specified by:
acceptRuleMatch
in classRuleFilter
- Parameters:
args
- a map with values foryear
,month
,day
(day of month),weekDay
patternTokens
- those tokens of the text that correspond the matched pattern- Returns:
null
if this rule match should be removed, or any other RuleMatch (e.g. the one from the arguments) that properly describes the detected error
-
getDate
private java.util.Calendar getDate(java.util.Map<java.lang.String,java.lang.String> args)
-
getDayOfMonthFromArguments
private int getDayOfMonthFromArguments(java.util.Map<java.lang.String,java.lang.String> args)
-
getMonthFromArguments
private int getMonthFromArguments(java.util.Map<java.lang.String,java.lang.String> args)
-
-