Package org.kigalisim.lang.localization
Class OnlyPeriodsParseStrategy
java.lang.Object
org.kigalisim.lang.localization.SingleDelimiterTemplate
org.kigalisim.lang.localization.OnlyPeriodsParseStrategy
- All Implemented Interfaces:
NumberParseUtilStrategy
Parse strategy for numbers with only period separators.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermine if this strategy can handle the given separator pattern.protected charGet the separator character used by this strategy.protected intgetSeparatorCount(int commaCount, int periodCount) Get the count of this strategy's separator from the total counts.protected StringGet the name of this strategy for error messages.protected FlexibleNumberParseResulthandleAmbiguousCase(String numberStr, char separator, int separatorIndex, int digitsBefore) Handle ambiguous case where exactly 3 digits follow a single separator.protected FlexibleNumberParseResulthandleLeadingSeparator(String numberStr) Handle numbers with a leading separator.protected FlexibleNumberParseResulthandleMultipleSeparators(String numberStr, char separator) Handle numbers with multiple separators.protected FlexibleNumberParseResulthandleSingleNonAmbiguous(String numberStr) Handle numbers where the separator separates digits in a non-3-digit pattern.Methods inherited from class org.kigalisim.lang.localization.SingleDelimiterTemplate
handleSingleSeparatorType, isLikelyThousandsSeparator, parseNumber, validateThousandsSeparatorPositions
-
Constructor Details
-
OnlyPeriodsParseStrategy
public OnlyPeriodsParseStrategy()Constructs a new OnlyPeriodsParseStrategy.
-
-
Method Details
-
canHandle
Description copied from interface:NumberParseUtilStrategyDetermine if this strategy can handle the given separator pattern.- Parameters:
numberStr- The number string to analyzecommaCount- Number of commas in the stringperiodCount- Number of periods in the string- Returns:
- true if this strategy can handle the pattern
-
getSeparator
protected char getSeparator()Description copied from class:SingleDelimiterTemplateGet the separator character used by this strategy.- Specified by:
getSeparatorin classSingleDelimiterTemplate- Returns:
- The separator character (',' or '.')
-
getStrategyName
Description copied from class:SingleDelimiterTemplateGet the name of this strategy for error messages.- Specified by:
getStrategyNamein classSingleDelimiterTemplate- Returns:
- The strategy name
-
getSeparatorCount
protected int getSeparatorCount(int commaCount, int periodCount) Description copied from class:SingleDelimiterTemplateGet the count of this strategy's separator from the total counts.- Specified by:
getSeparatorCountin classSingleDelimiterTemplate- Parameters:
commaCount- Number of commas in the stringperiodCount- Number of periods in the string- Returns:
- The count relevant to this strategy
-
handleMultipleSeparators
Description copied from class:SingleDelimiterTemplateHandle numbers with multiple separators.- Specified by:
handleMultipleSeparatorsin classSingleDelimiterTemplate- Parameters:
numberStr- The number stringseparator- The separator character- Returns:
- FlexibleNumberParseResult containing either parsed number or error
-
handleLeadingSeparator
Description copied from class:SingleDelimiterTemplateHandle numbers with a leading separator.- Specified by:
handleLeadingSeparatorin classSingleDelimiterTemplate- 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:SingleDelimiterTemplateHandle ambiguous case where exactly 3 digits follow a single separator.- Specified by:
handleAmbiguousCasein classSingleDelimiterTemplate- Parameters:
numberStr- The number stringseparator- The separator characterseparatorIndex- The index of the separatordigitsBefore- Number of digits before the separator- Returns:
- FlexibleNumberParseResult containing either parsed number or error
-
handleSingleNonAmbiguous
Description copied from class:SingleDelimiterTemplateHandle numbers where the separator separates digits in a non-3-digit pattern.- Specified by:
handleSingleNonAmbiguousin classSingleDelimiterTemplate- Parameters:
numberStr- The number string- Returns:
- FlexibleNumberParseResult containing either parsed number or error
-