public class ParsedNumber extends Object
| Modifier and Type | Field and Description |
|---|---|
int |
charEnd
The index of the last char consumed during parsing.
|
static Comparator<ParsedNumber> |
COMPARATOR
A Comparator that favors ParsedNumbers with the most chars consumed.
|
String |
currencyCode
The currency that got consumed.
|
static int |
FLAG_FAIL |
static int |
FLAG_HAS_DECIMAL_SEPARATOR |
static int |
FLAG_HAS_EXPONENT |
static int |
FLAG_INFINITY |
static int |
FLAG_NAN |
static int |
FLAG_NEGATIVE |
static int |
FLAG_PERCENT |
static int |
FLAG_PERMILLE |
int |
flags
Boolean flags (see constants below).
|
String |
prefix
The pattern string corresponding to the prefix that got consumed.
|
DecimalQuantity_DualStorageBCD |
quantity
The numerical value that was parsed.
|
String |
suffix
The pattern string corresponding to the suffix that got consumed.
|
| Constructor and Description |
|---|
ParsedNumber() |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears the data from this ParsedNumber, in effect failing the current parse.
|
void |
copyFrom(ParsedNumber other) |
Number |
getNumber() |
Number |
getNumber(int parseFlags) |
void |
postProcess()
Apply certain number-related flags to the DecimalQuantity.
|
boolean |
seenNumber() |
void |
setCharsConsumed(StringSegment segment)
Call this method to register that a "strong" char was consumed.
|
boolean |
success()
Returns whether this the parse was successful.
|
public DecimalQuantity_DualStorageBCD quantity
public int charEnd
public int flags
public String prefix
public String suffix
public String currencyCode
public static final int FLAG_NEGATIVE
public static final int FLAG_PERCENT
public static final int FLAG_PERMILLE
public static final int FLAG_HAS_EXPONENT
public static final int FLAG_HAS_DECIMAL_SEPARATOR
public static final int FLAG_NAN
public static final int FLAG_INFINITY
public static final int FLAG_FAIL
public static final Comparator<ParsedNumber> COMPARATOR
public void clear()
public void copyFrom(ParsedNumber other)
public void setCharsConsumed(StringSegment segment)
StringSegment.setOffset(int) or StringSegment.adjustOffset(int) except when the char is
"weak", like whitespace.
What is a strong versus weak char? The behavior of number parsing is to "stop" after reading the number, even if there is other content following the number. For example, after parsing the string "123 " (123 followed by a space), the cursor should be set to 3, not 4, even though there are matchers that accept whitespace. In this example, the digits are strong, whereas the whitespace is weak. Grouping separators are weak, whereas decimal separators are strong. Most other chars are strong.
segment - The current StringSegment, usually immediately following a call to setOffset.public void postProcess()
public boolean success()
public boolean seenNumber()
public Number getNumber()
public Number getNumber(int parseFlags)
parseFlags - Configuration settings from ParsingUtils.java