Top Description Inners Methods
com.ibm.icu.impl.number.parse

public Interface NumberParseMatcher

Known Direct Implementers
com.ibm.icu.impl.number.parse.ScientificMatcher, com.ibm.icu.impl.number.parse.SeriesMatcher, com.ibm.icu.impl.number.parse.SymbolMatcher, com.ibm.icu.impl.number.parse.ValidationMatcher, com.ibm.icu.impl.number.parse.AffixMatcher, com.ibm.icu.impl.number.parse.CodePointMatcher, com.ibm.icu.impl.number.parse.CombinedCurrencyMatcher, com.ibm.icu.impl.number.parse.DecimalMatcher
Imports
com.ibm.icu.impl.StringSegment

The core interface implemented by all matchers used for number parsing. Given a string, there should NOT be more than one way to consume the string with the same matcher applied multiple times. If there is, the non-greedy parsing algorithm will be unhappy and may enter an exponential-time loop. For example, consider the "A Matcher" that accepts "any number of As". Given the string "AAAA", there are 2^N = 8 ways to apply the A Matcher to this string: you could have the A Matcher apply 4 times to each character; you could have it apply just once to all the characters; you could have it apply to the first 2 characters and the second 2 characters; and so on. A better version of the "A Matcher" would be for it to accept exactly one A, and allow the algorithm to run it repeatedly to consume a string of multiple As. The A Matcher can implement the Flexible interface below to signal that it can be applied multiple times in a row.
Author
sffc

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
NumberParseMatcher.Flexible

Matchers can implement the Flexible interface to indicate that they are optional and can be run repeatedly.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

Whether this matcher thinks there may be more interesting chars beyond the end of the string segment.
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
)

Runs this matcher starting at the beginning of the given StringSegment.

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

Method called at the end of a parse, after all matchers have failed to consume any more chars.

public boolean

Returns:

true if the matcher might be able to match against this segment; false if it definitely will not be able to match.
smokeTest
(StringSegment
The segment to check against.
segment
)

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

Method Detail

matchback to summary
public boolean match(StringSegment segment, ParsedNumber result)

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.

postProcessback to summary
public void postProcess(ParsedNumber result)

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.

smokeTestback to summary
public boolean smokeTest(StringSegment segment)

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.

com.ibm.icu.impl.number.parse back to summary

public Interface NumberParseMatcher.Flexible

Known Direct Implementers
com.ibm.icu.impl.number.parse.PaddingMatcher, com.ibm.icu.impl.number.parse.IgnorablesMatcher

Matchers can implement the Flexible interface to indicate that they are optional and can be run repeatedly. Used by SeriesMatcher, primarily in the context of IgnorablesMatcher.