Package app.babylon.text
Class BigDecimals
java.lang.Object
app.babylon.text.BigDecimals
Parsing and extraction helpers for decimal text values.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classPrepared decimal text together with formatting flags discovered during normalisation. -
Method Summary
Modifier and TypeMethodDescriptionstatic BigDecimalextract(CharSequence sentence) Extracts a single decimal value from a sentence-like string.static DoubleextractDouble(CharSequence sentence) Extracts a single double value from a sentence-like string.static booleanReturns whether the supplied text could represent a decimal.static BigDecimalParses a decimal value from the supplied text.static DoubleParses aDoublefrom the supplied text.static BigDecimals.PreparedDecimalNormalises a decimal candidate before final parsing.static StringRemoves commas from a simple numeric string, leaving other text unchanged.
-
Method Details
-
isDecimal
Returns whether the supplied text could represent a decimal.- Parameters:
s- text to inspect- Returns:
truewhen the text can be normalised as a decimal
-
removeCommas
Removes commas from a simple numeric string, leaving other text unchanged.- Parameters:
s- text to normalise- Returns:
- comma-free text or the original value when no safe cleanup applies
-
parse
Parses a decimal value from the supplied text.- Parameters:
s- text to parse- Returns:
- parsed decimal or
null
-
parseDouble
Parses aDoublefrom the supplied text.- Parameters:
s- text to parse- Returns:
- parsed double or
null
-
extract
Extracts a single decimal value from a sentence-like string.- Parameters:
sentence- source text- Returns:
- parsed decimal or
nullif none or more than one are found
-
extractDouble
Extracts a single double value from a sentence-like string.- Parameters:
sentence- source text- Returns:
- parsed double or
nullif none or more than one are found
-
prepare
Normalises a decimal candidate before final parsing.- Parameters:
s- text to prepare- Returns:
- prepared decimal metadata or
null
-