Class UcumGrammar

java.lang.Object
network.ike.foundation.ike.ucum.UcumGrammar

public final class UcumGrammar extends Object
UCUM's grammar for unit codes, as the specification gives it: a term is components joined by a period for a product or a solidus for a quotient, and may open with a solidus; a component is a unit with an optional exponent, a number, a parenthesized term, or an annotation in braces; a unit is an atom, or a prefix on a metric atom. Reading is by the longest code that matches, an atom before a prefix on an atom when both are as long, so that cd is the candela and not a centi-day. A code the grammar cannot read is refused with its place.
  • Method Details

    • parse

      public static UcumTerm parse(String code, UcumSymbols symbols)
      Reads a unit code.
      Parameters:
      code - the code as written
      symbols - the atoms and prefixes it may use
      Returns:
      the term
      Throws:
      UcumSyntaxException - if the code cannot be read; the place is named