Package com.ibm.icu.impl.units
Class MeasureUnitImpl.UnitsParser
- java.lang.Object
-
- com.ibm.icu.impl.units.MeasureUnitImpl.UnitsParser
-
- Enclosing class:
- MeasureUnitImpl
public static class MeasureUnitImpl.UnitsParser extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
MeasureUnitImpl.UnitsParser.Token
-
Field Summary
Fields Modifier and Type Field Description private boolean
fAfterPer
private int
fIndex
private boolean
fSawAnd
private java.lang.String
fSource
private static MeasureUnit.MeasurePrefix[]
measurePrefixValues
private static CharsTrie
savedTrie
private CharsTrie
trie
-
Constructor Summary
Constructors Modifier Constructor Description private
UnitsParser(java.lang.String identifier)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static MeasureUnit.MeasurePrefix
getPrefixFromTrieIndex(int trieIndex)
private static int
getTrieIndexForPrefix(MeasureUnit.MeasurePrefix prefix)
private boolean
hasNext()
private SingleUnitImpl
nextSingleUnit()
Returns the next "single unit" via result.private MeasureUnitImpl.UnitsParser.Token
nextToken()
private MeasureUnitImpl
parse()
static MeasureUnitImpl
parseForIdentifier(java.lang.String identifier)
Construct a MeasureUnit from a CLDR Unit Identifier, defined in UTS 35.
-
-
-
Field Detail
-
savedTrie
private static volatile CharsTrie savedTrie
-
trie
private final CharsTrie trie
-
fSource
private final java.lang.String fSource
-
fIndex
private int fIndex
-
fAfterPer
private boolean fAfterPer
-
fSawAnd
private boolean fSawAnd
-
measurePrefixValues
private static MeasureUnit.MeasurePrefix[] measurePrefixValues
-
-
Method Detail
-
parseForIdentifier
public static MeasureUnitImpl parseForIdentifier(java.lang.String identifier)
Construct a MeasureUnit from a CLDR Unit Identifier, defined in UTS 35. Validates and canonicalizes the identifier.- Returns:
- MeasureUnitImpl object or null if the identifier is empty.
- Throws:
java.lang.IllegalArgumentException
- in case of invalid identifier.
-
getPrefixFromTrieIndex
private static MeasureUnit.MeasurePrefix getPrefixFromTrieIndex(int trieIndex)
-
getTrieIndexForPrefix
private static int getTrieIndexForPrefix(MeasureUnit.MeasurePrefix prefix)
-
parse
private MeasureUnitImpl parse()
-
nextSingleUnit
private SingleUnitImpl nextSingleUnit()
Returns the next "single unit" via result.If a "-per-" was parsed, the result will have appropriate negative dimensionality.
- Throws:
java.lang.IllegalArgumentException
- if we parse both compound units and "-and-", since mixed compound units are not yet supported - TODO(CLDR-13701).
-
hasNext
private boolean hasNext()
-
nextToken
private MeasureUnitImpl.UnitsParser.Token nextToken()
-
-