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

public Class DecimalMatcher

extends Object
implements NumberParseMatcher
Class Inheritance
All Implemented Interfaces
com.ibm.icu.impl.number.parse.NumberParseMatcher
Imports
com.ibm.icu.impl.StaticUnicodeSets, .StaticUnicodeSets.Key, .StringSegment, com.ibm.icu.impl.number.DecimalQuantity_DualStorageBCD, .Grouper, com.ibm.icu.lang.UCharacter, com.ibm.icu.text.DecimalFormatSymbols, .UnicodeSet

Author
sffc

Field Summary

Modifier and TypeField and Description
private final String
private final UnicodeSet
private final String[]
private final int
private final int
private final boolean
groupingDisabled

If true, do not accept grouping separators at all

private final String
private final UnicodeSet
private final boolean
integerOnly

If true, do not accept numbers in the fraction

private final UnicodeSet
private final boolean
requireGroupingMatch

If true, only accept strings whose grouping sizes match the locale

private final UnicodeSet

Constructor Summary

AccessConstructor and Description
private
DecimalMatcher(DecimalFormatSymbols symbols, Grouper grouper, int parseFlags)

Method Summary

Modifier and TypeMethod and Description
public static DecimalMatcher
getInstance(DecimalFormatSymbols symbols, Grouper grouper, int parseFlags)

public boolean
match(StringSegment
The StringSegment to match against. Matches always start at the beginning of the segment. The segment is guaranteed to contain at least one char.
segment
,
ParsedNumber
The data structure to store results if the match succeeds.
result
)

Implements com.ibm.icu.impl.number.parse.NumberParseMatcher.match.

Runs this matcher starting at the beginning of the given StringSegment.
public boolean
match(StringSegment segment, ParsedNumber result, int
-1 means a negative exponent; +1 means a positive exponent; 0 means NO exponent. If -1 or +1, the number will be saved by scaling the pre-existing DecimalQuantity in the ParsedNumber. If 0, a new DecimalQuantity will be created to store the number.
exponentSign
)

public void
postProcess(ParsedNumber
The data structure to store results.
result
)

Implements com.ibm.icu.impl.number.parse.NumberParseMatcher.postProcess.

Method called at the end of a parse, after all matchers have failed to consume any more chars.
public boolean
smokeTest(StringSegment
The segment to check against.
segment
)

Implements com.ibm.icu.impl.number.parse.NumberParseMatcher.smokeTest.

Performs a fast "smoke check" for whether or not this matcher could possibly match against the given string segment.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
private boolean
validateGroup(int sepType, int count, boolean isPrimary)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

decimalSeparatorback to summary
private final String decimalSeparator
decimalUniSetback to summary
private final UnicodeSet decimalUniSet
digitStringsback to summary
private final String[] digitStrings
grouping1back to summary
private final int grouping1
grouping2back to summary
private final int grouping2
groupingDisabledback to summary
private final boolean groupingDisabled

If true, do not accept grouping separators at all

groupingSeparatorback to summary
private final String groupingSeparator
groupingUniSetback to summary
private final UnicodeSet groupingUniSet
integerOnlyback to summary
private final boolean integerOnly

If true, do not accept numbers in the fraction

leadSetback to summary
private final UnicodeSet leadSet
requireGroupingMatchback to summary
private final boolean requireGroupingMatch

If true, only accept strings whose grouping sizes match the locale

separatorSetback to summary
private final UnicodeSet separatorSet

Constructor Detail

DecimalMatcherback to summary
private DecimalMatcher(DecimalFormatSymbols symbols, Grouper grouper, int parseFlags)

Method Detail

getInstanceback to summary
public static DecimalMatcher getInstance(DecimalFormatSymbols symbols, Grouper grouper, int parseFlags)
matchback to summary
public boolean match(StringSegment segment, ParsedNumber result)

Implements com.ibm.icu.impl.number.parse.NumberParseMatcher.match.

Doc from com.ibm.icu.impl.number.parse.NumberParseMatcher.match.

Runs this matcher starting at the beginning of the given StringSegment. If this matcher finds something interesting in the StringSegment, it should update the offset of the StringSegment corresponding to how many chars were matched.

Parameters
segment:StringSegment

The StringSegment to match against. Matches always start at the beginning of the segment. The segment is guaranteed to contain at least one char.

result:ParsedNumber

The data structure to store results if the match succeeds.

Returns:boolean

Whether this matcher thinks there may be more interesting chars beyond the end of the string segment.

Annotations
@Override
matchback to summary
public boolean match(StringSegment segment, ParsedNumber result, int exponentSign)
Parameters
exponentSign:int

-1 means a negative exponent; +1 means a positive exponent; 0 means NO exponent. If -1 or +1, the number will be saved by scaling the pre-existing DecimalQuantity in the ParsedNumber. If 0, a new DecimalQuantity will be created to store the number.

postProcessback to summary
public void postProcess(ParsedNumber result)

Implements com.ibm.icu.impl.number.parse.NumberParseMatcher.postProcess.

Doc from com.ibm.icu.impl.number.parse.NumberParseMatcher.postProcess.

Method called at the end of a parse, after all matchers have failed to consume any more chars. Allows a matcher to make final modifications to the result given the knowledge that no more matches are possible.

Parameters
result:ParsedNumber

The data structure to store results.

Annotations
@Override
smokeTestback to summary
public boolean smokeTest(StringSegment segment)

Implements com.ibm.icu.impl.number.parse.NumberParseMatcher.smokeTest.

Doc from com.ibm.icu.impl.number.parse.NumberParseMatcher.smokeTest.

Performs a fast "smoke check" for whether or not this matcher could possibly match against the given string segment. The test should be as fast as possible but also as restrictive as possible. For example, matchers can maintain a UnicodeSet of all code points that count possibly start a match. Matchers should use the StringSegment#startsWith method in order to correctly handle case folding.

Parameters
segment:StringSegment

The segment to check against.

Returns:boolean

true if the matcher might be able to match against this segment; false if it definitely will not be able to match.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
validateGroupback to summary
private boolean validateGroup(int sepType, int count, boolean isPrimary)