Top Description Fields Constructors Methods
com.ibm.icu.impl.number.parse

public Class ParsedNumber

extends Object
Class Inheritance
Imports
java.util.Comparator, com.ibm.icu.impl.StringSegment, com.ibm.icu.impl.number.DecimalQuantity_DualStorageBCD

Struct-like class to hold the results of a parsing routine.
Author
sffc

Field Summary

Modifier and TypeField and Description
public int
charEnd

The index of the last char consumed during parsing.

public static final Comparator<ParsedNumber>
COMPARATOR

A Comparator that favors ParsedNumbers with the most chars consumed.

public String
currencyCode

The currency that got consumed.

public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public int
flags

Boolean flags (see constants below).

public String
prefix

The pattern string corresponding to the prefix that got consumed.

public DecimalQuantity_DualStorageBCD
quantity

The numerical value that was parsed.

public String
suffix

The pattern string corresponding to the suffix that got consumed.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Clears the data from this ParsedNumber, in effect failing the current parse.

public void
public Number
public Number
getNumber(int
Configuration settings from ParsingUtils.java
parseFlags
)

pack-priv boolean
public void
postProcess()

Apply certain number-related flags to the DecimalQuantity.

public boolean
public void
setCharsConsumed(StringSegment
The current StringSegment, usually immediately following a call to setOffset.
segment
)

Call this method to register that a "strong" char was consumed.

public boolean
success()

Returns whether this the parse was successful.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

charEndback to summary
public int charEnd

The index of the last char consumed during parsing. If parsing started at index 0, this is equal to the number of chars consumed. This is NOT necessarily the same as the StringSegment offset; "weak" chars, like whitespace, change the offset, but the charsConsumed is not touched until a "strong" char is encountered.

COMPARATORback to summary
public static final Comparator<ParsedNumber> COMPARATOR

A Comparator that favors ParsedNumbers with the most chars consumed.

currencyCodeback to summary
public String currencyCode

The currency that got consumed.

FLAG_FAILback to summary
public static final int FLAG_FAIL
FLAG_HAS_DECIMAL_SEPARATORback to summary
public static final int FLAG_HAS_DECIMAL_SEPARATOR
FLAG_HAS_EXPONENTback to summary
public static final int FLAG_HAS_EXPONENT
FLAG_INFINITYback to summary
public static final int FLAG_INFINITY
FLAG_NANback to summary
public static final int FLAG_NAN
FLAG_NEGATIVEback to summary
public static final int FLAG_NEGATIVE
FLAG_PERCENTback to summary
public static final int FLAG_PERCENT
FLAG_PERMILLEback to summary
public static final int FLAG_PERMILLE
flagsback to summary
public int flags

Boolean flags (see constants below).

prefixback to summary
public String prefix

The pattern string corresponding to the prefix that got consumed.

quantityback to summary
public DecimalQuantity_DualStorageBCD quantity

Deprecated

as a consequence of DecimalQuantity_DualStorageBCD being deprecated. See corresponding docs for further information.

The numerical value that was parsed.

suffixback to summary
public String suffix

The pattern string corresponding to the suffix that got consumed.

Constructor Detail

ParsedNumberback to summary
public ParsedNumber()

Method Detail

clearback to summary
public void clear()

Clears the data from this ParsedNumber, in effect failing the current parse.

copyFromback to summary
public void copyFrom(ParsedNumber other)
getNumberback to summary
public Number getNumber()
getNumberback to summary
public Number getNumber(int parseFlags)
Parameters
parseFlags:int

Configuration settings from ParsingUtils.java

isBetterThanback to summary
pack-priv boolean isBetterThan(ParsedNumber other)
postProcessback to summary
public void postProcess()

Apply certain number-related flags to the DecimalQuantity.

seenNumberback to summary
public boolean seenNumber()
setCharsConsumedback to summary
public void setCharsConsumed(StringSegment segment)

Call this method to register that a "strong" char was consumed. This should be done after calling StringSegment#setOffset or StringSegment#adjustOffset 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.

Parameters
segment:StringSegment

The current StringSegment, usually immediately following a call to setOffset.

successback to summary
public boolean success()

Returns whether this the parse was successful. To be successful, at least one char must have been consumed, and the failure flag must not be set.