Class AbstractNewYearDateFilter


  • public abstract class AbstractNewYearDateFilter
    extends RuleFilter
    Accepts rule matches if we are in the first days of a new year and the user may have entered a date with the old year (but not a date in December).
    Since:
    4.3
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.regex.Pattern DAY_OF_MONTH_PATTERN  
    • 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, or null if the rule match is filtered out.
      protected abstract java.util.Calendar getCalendar()  
      protected int getCurrentYear()  
      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" returns 1, second returns 2 etc.
      private int getDayOfMonthFromArguments​(java.util.Map<java.lang.String,​java.lang.String> args)  
      protected abstract int getMonth​(java.lang.String localizedMonth)
      Implement so that January returns 1, February 2 etc.
      private int getMonthFromArguments​(java.util.Map<java.lang.String,​java.lang.String> args)  
      protected boolean isJanuary()
      Return true if the year recently changed (= it is January)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DAY_OF_MONTH_PATTERN

        private static final java.util.regex.Pattern DAY_OF_MONTH_PATTERN
    • Constructor Detail

      • AbstractNewYearDateFilter

        public AbstractNewYearDateFilter()
    • Method Detail

      • isJanuary

        protected boolean isJanuary()
        Return true if the year recently changed (= it is January)
      • getCurrentYear

        protected int getCurrentYear()
      • getMonth

        protected abstract int getMonth​(java.lang.String localizedMonth)
        Implement so that January returns 1, February 2 etc.
        Parameters:
        localizedMonth - name of a month or abbreviation thereof
      • getCalendar

        protected abstract java.util.Calendar getCalendar()
      • getDayOfMonth

        protected int getDayOfMonth​(java.lang.String localizedDayOfMonth)
        Implement so that "first" returns 1, second returns 2 etc.
        Parameters:
        localizedDayOfMonth - name of day of the month or abbreviation thereof
      • 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, or null if the rule match is filtered out.
        Specified by:
        acceptRuleMatch in class RuleFilter
        Parameters:
        args - a map with values for year, month, day (day of month)
        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)