Class OnlyCommasParseStrategy

java.lang.Object
org.kigalisim.lang.localization.SingleDelimiterTemplate
org.kigalisim.lang.localization.OnlyCommasParseStrategy
All Implemented Interfaces:
NumberParseUtilStrategy

public class OnlyCommasParseStrategy extends SingleDelimiterTemplate
Parse strategy for numbers with only comma separators.
  • Constructor Details

    • OnlyCommasParseStrategy

      public OnlyCommasParseStrategy()
      Constructs a new OnlyCommasParseStrategy.
  • Method Details

    • canHandle

      public boolean canHandle(String numberStr, int commaCount, int periodCount)
      Description copied from interface: NumberParseUtilStrategy
      Determine if this strategy can handle the given separator pattern.
      Parameters:
      numberStr - The number string to analyze
      commaCount - Number of commas in the string
      periodCount - Number of periods in the string
      Returns:
      true if this strategy can handle the pattern
    • getSeparator

      protected char getSeparator()
      Description copied from class: SingleDelimiterTemplate
      Get the separator character used by this strategy.
      Specified by:
      getSeparator in class SingleDelimiterTemplate
      Returns:
      The separator character (',' or '.')
    • getStrategyName

      protected String getStrategyName()
      Description copied from class: SingleDelimiterTemplate
      Get the name of this strategy for error messages.
      Specified by:
      getStrategyName in class SingleDelimiterTemplate
      Returns:
      The strategy name
    • getSeparatorCount

      protected int getSeparatorCount(int commaCount, int periodCount)
      Description copied from class: SingleDelimiterTemplate
      Get the count of this strategy's separator from the total counts.
      Specified by:
      getSeparatorCount in class SingleDelimiterTemplate
      Parameters:
      commaCount - Number of commas in the string
      periodCount - Number of periods in the string
      Returns:
      The count relevant to this strategy
    • handleMultipleSeparators

      protected FlexibleNumberParseResult handleMultipleSeparators(String numberStr, char separator)
      Description copied from class: SingleDelimiterTemplate
      Handle numbers with multiple separators.
      Specified by:
      handleMultipleSeparators in class SingleDelimiterTemplate
      Parameters:
      numberStr - The number string
      separator - The separator character
      Returns:
      FlexibleNumberParseResult containing either parsed number or error
    • handleLeadingSeparator

      protected FlexibleNumberParseResult handleLeadingSeparator(String numberStr)
      Description copied from class: SingleDelimiterTemplate
      Handle numbers with a leading separator.
      Specified by:
      handleLeadingSeparator in class SingleDelimiterTemplate
      Parameters:
      numberStr - The number string starting with separator
      Returns:
      FlexibleNumberParseResult containing either parsed number or error
    • handleAmbiguousCase

      protected FlexibleNumberParseResult handleAmbiguousCase(String numberStr, char separator, int separatorIndex, int digitsBefore)
      Description copied from class: SingleDelimiterTemplate
      Handle ambiguous case where exactly 3 digits follow a single separator.
      Specified by:
      handleAmbiguousCase in class SingleDelimiterTemplate
      Parameters:
      numberStr - The number string
      separator - The separator character
      separatorIndex - The index of the separator
      digitsBefore - Number of digits before the separator
      Returns:
      FlexibleNumberParseResult containing either parsed number or error
    • handleSingleNonAmbiguous

      protected FlexibleNumberParseResult handleSingleNonAmbiguous(String numberStr)
      Description copied from class: SingleDelimiterTemplate
      Handle numbers where the separator separates digits in a non-3-digit pattern.
      Specified by:
      handleSingleNonAmbiguous in class SingleDelimiterTemplate
      Parameters:
      numberStr - The number string
      Returns:
      FlexibleNumberParseResult containing either parsed number or error