Class UnitFormat.Operation

java.lang.Object
org.apache.sis.measure.UnitFormat.Operation
Enclosing class:
UnitFormat

private static final class UnitFormat.Operation extends Object
Represents an operation to be applied between two terms parsed by UnitFormat.parseTerm(CharSequence, int, int, Operation).
  • Field Details

    • NOOP

      static final int NOOP
      Meaning of some characters parsed by UnitFormat.parse(CharSequence). The IMPLICIT case is a multiplication without symbol, which can be overridden by an explicit × or / symbol.
      See Also:
    • IMPLICIT

      static final int IMPLICIT
      Meaning of some characters parsed by UnitFormat.parse(CharSequence). The IMPLICIT case is a multiplication without symbol, which can be overridden by an explicit × or / symbol.
      See Also:
    • MULTIPLY

      static final int MULTIPLY
      Meaning of some characters parsed by UnitFormat.parse(CharSequence). The IMPLICIT case is a multiplication without symbol, which can be overridden by an explicit × or / symbol.
      See Also:
    • DIVIDE

      static final int DIVIDE
      Meaning of some characters parsed by UnitFormat.parse(CharSequence). The IMPLICIT case is a multiplication without symbol, which can be overridden by an explicit × or / symbol.
      See Also:
    • EXPONENT

      static final int EXPONENT
      Meaning of some characters parsed by UnitFormat.parse(CharSequence). The IMPLICIT case is a multiplication without symbol, which can be overridden by an explicit × or / symbol.
      See Also:
    • code

      int code
      The operation as one of the NOOP, IMPLICIT, MULTIPLY or DIVIDE values.
    • symbols

      private final CharSequence symbols
      The symbols being parsed. Used only for formatting error message if needed.
    • finished

      boolean finished
      true if the parsed terms may be one or more words, possibly containing white spaces. In such case, the parsing should not continue after those words.
      See Also:
  • Constructor Details

    • Operation

      Operation(CharSequence symbols)
      Creates an operation initialized to NOOP.
  • Method Details

    • apply

      javax.measure.Unit<?> apply(javax.measure.Unit<?> unit, javax.measure.Unit<?> term, int position)
      Applies a multiplication or division operation between the given units.
      Parameters:
      unit - the left operand, which is the unit parsed so far.
      term - the right operation, which is the newly parsed unit.
      position - the parse position to report if parsing fail.
    • invert

      boolean invert()
      If this operation is a multiplication, replaces by division. Otherwise do nothing (we do not replace division by multiplication). The intent is to replace units like "m⋅s-1" by "m/s".
      Returns:
      whether the operation has been inverted.