Class NumericFormatModel
java.lang.Object
dev.frostlake.functions.scalar.conversion.NumericFormatModel
A numeric INPUT format model — the format argument of TO_NUMBER / TO_DECIMAL / TO_NUMERIC, TO_DOUBLE and
TO_DECFLOAT over a text, and of their TRY_ twins — scanned into its alternatives and checked the way the
account checks it, before the text is read. A model that is not one is refused naming the whole model
and the TARGET in the account's own word — FIXED for TO_NUMBER, REAL for TO_DOUBLE, DECFLOAT for
TO_DECFLOAT — and the TRY_ twins answer NULL instead (all live-verified):
TO_NUMBER('1', '9e9') invalid numeric format keyword: 'e9' letters, digits, _ $ % in a run
TO_NUMBER('1', '9+') invalid character in the format string: '+' a tab shown as '\011'
TO_NUMBER('1', '9"') missing closing " in the literal: '9"'
TO_NUMBER('1', '9SS') format element occurs more than once: 'S'
TO_NUMBER('1', '9D9.9') format element conflicts with preceding element(s): '.'
TO_NUMBER('1', '9EE.9') digit position after an exponent format element: '9EE.9'
TO_NUMBER('1', '9X') cannot mix hexadecimal and decimal format elements: '9X'
TO_NUMBER('1', 'TM99') cannot mix TM and digit-based numeric format elements: 'TM99'
TO_NUMBER('1', '$') no digit format elements in a numeric format: '$'
TO_NUMBER('1', ',') missing required input format element(s) '' and '|9' alike
TO_DOUBLE('ff', 'XX') missing required input format element(s) hexadecimal is FIXED's alone
| separates alternatives, each checked in turn and the first that reads the text answering;
one trailing | is ignored. AUTO alone is an alternative reading any number, and TM9 takes
(digits[,group]). A text the model cannot read is refused by readOrRefuse(java.lang.String, java.lang.String, java.lang.String) with the
text exactly as written. Scanning a model is data handling, not SQL: the model is a string VALUE.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic NumericFormatModelScan and check a model.The value the first alternative that reads the text gives.static BigDecimalreadOrRefuse(String text, String format, String target) A text read under a model, refused as the account refuses it when no alternative reads it — the text echoed exactly as written, its spaces included:TO_NUMBER(' 123 ', '99')is "Can't parse ' 123 ' as number with format '99'".
-
Field Details
-
FIXED
The target TO_NUMBER, TO_DECIMAL and TO_NUMERIC convert to, in the refusal's own word.- See Also:
-
REAL
TO_DOUBLE's target, in the refusal's own word.- See Also:
-
DECFLOAT
TO_DECFLOAT's target, in the refusal's own word.- See Also:
-
-
Method Details
-
parse
Scan and check a model. -
readOrRefuse
A text read under a model, refused as the account refuses it when no alternative reads it — the text echoed exactly as written, its spaces included:TO_NUMBER(' 123 ', '99')is "Can't parse ' 123 ' as number with format '99'".- Parameters:
text- the textformat- the model as writtentarget- the target a refusal of the model names- Returns:
- the value the text spells
-
read
The value the first alternative that reads the text gives.- Parameters:
text- the text- Returns:
- the value, or null when no alternative reads it
-