Class MeasureUnitImpl.UnitsParser

java.lang.Object
com.ibm.icu.impl.units.MeasureUnitImpl.UnitsParser
Enclosing class:
MeasureUnitImpl

public static class MeasureUnitImpl.UnitsParser extends Object
  • Field Details

    • savedTrie

      private static volatile CharsTrie savedTrie
    • trie

      private final CharsTrie trie
    • fSource

      private final String fSource
    • fIndex

      private int fIndex
    • fAfterPer

      private boolean fAfterPer
    • fSawAnd

      private boolean fSawAnd
    • measurePrefixValues

      private static MeasureUnit.MeasurePrefix[] measurePrefixValues
  • Constructor Details

    • UnitsParser

      private UnitsParser(String identifier)
  • Method Details

    • parseForIdentifier

      public static MeasureUnitImpl parseForIdentifier(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:
      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:
      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()