public class NumberFormatParser
extends java.lang.Object
parse(String)
method is responsible for checking the
Progress date format validity.
Also this class provides a set of callback methods,
each callback is called when the corresponding format component is parsed.
By default, all callbacks do nothing, they are expected to be re-defined in subclasses.Modifier and Type | Field and Description |
---|---|
private static java.util.regex.Pattern |
RIGHT_SPACES_PATTERN
Pre-compiled regex pattern to right trim format string
|
Constructor and Description |
---|
NumberFormatParser() |
Modifier and Type | Method and Description |
---|---|
private static void |
genNoDigitsError(java.lang.String fmt)
Generate an error if no digits were found in a numeric format string.
|
void |
parse(java.lang.String format)
Parse number format, call callbacks while parsing.
|
protected void |
visitFillChar(char c)
A fill character was parsed.
|
protected void |
visitLeftDigits(int startIdx,
int endIdx)
Non-empty left digits section was parsed.
|
protected void |
visitRightDigits(int startIdx,
int endIdx,
int separators)
Right digits section was parsed (may be empty).
|
protected void |
visitSign(int startIdx,
int endIdx)
A sign spec was parsed.
|
private static final java.util.regex.Pattern RIGHT_SPACES_PATTERN
public void parse(java.lang.String format) throws ErrorConditionException
format
- the format string to parseErrorConditionException
- in case the number format is invalidprotected void visitLeftDigits(int startIdx, int endIdx)
The default implementation does nothing.
startIdx
- the section start index in format string, zero-based, inclusiveendIdx
- the section end index in format string, zero-based, exclusiveprotected void visitRightDigits(int startIdx, int endIdx, int separators)
The default implementation does nothing.
startIdx
- the section start index in format string, zero-based, inclusiveendIdx
- the section end index in format string, zero-based, exclusiveseparators
- the number of digit separator ',' character in right digitsprotected void visitSign(int startIdx, int endIdx)
Sign specs are: '+', '-', '(', ')', DR, CR and DB.
The default implementation does nothing.
startIdx
- the section start index in format string, zero-based, inclusiveendIdx
- the section end index in format string, zero-based, exclusiveprotected void visitFillChar(char c)
The default implementation does nothing.
c
- the fill characterprivate static void genNoDigitsError(java.lang.String fmt) throws ErrorConditionException
fmt
- The incorrect format string.ErrorConditionException