Class BaseUnitFormatter

  • All Implemented Interfaces:
    UnitFormat, UnitFormatter

    public class BaseUnitFormatter
    extends SimpleUnitFormat
    implements UnitFormatter
    This class encapsulates the required machinations to initialize the unit formatter implementation of a certain third-party unit library.

    GeoTools' unit formatters should be implemented by calling the provided constructors.

    • Constructor Detail

      • BaseUnitFormatter

        public BaseUnitFormatter​(UnitDefinition... unitDefinitions)
        Create a new BaseUnitFormatter instance, initialized with provided the unit definitions.
        Parameters:
        unitDefinitions - unit definitions used to initialize this new instance
      • BaseUnitFormatter

        public BaseUnitFormatter​(List<UnitDefinition> unitDefinitions)
        Create a new BaseUnitFormatter instance, initialized with provided the unit definitions.
        Parameters:
        unitDefinitions - a list of unit definitions used to initialize this new instance
    • Method Detail

      • getUnitToSymbolMap

        @Deprecated
        public Map<Unit<?>,​String> getUnitToSymbolMap()
        Deprecated.
        Returns:
        an immutable map that shows the units (associated with their symbols) that this unit formatter contains
      • getSymbolToUnitMap

        @Deprecated
        public Map<String,​Unit<?>> getSymbolToUnitMap()
        Deprecated.
        Returns:
        an immutable map that shows the symbols (associated with their units) that this unit formatter contains
      • addUnit

        protected void addUnit​(Unit<?> unit)
        Defaults to being a no-op, subclasses can override
      • parseProductUnit

        public Unit<? extends Quantity> parseProductUnit​(CharSequence csq,
                                                         ParsePosition pos)
                                                  throws MeasurementParseException
        Specified by:
        parseProductUnit in class SimpleUnitFormat
        Throws:
        MeasurementParseException
      • parseSingleUnit

        public Unit<? extends Quantity> parseSingleUnit​(CharSequence csq,
                                                        ParsePosition pos)
                                                 throws MeasurementParseException
        Specified by:
        parseSingleUnit in class SimpleUnitFormat
        Throws:
        MeasurementParseException
      • label

        public void label​(Unit<?> unit,
                          String label)
        Specified by:
        label in interface UnitFormat
        Specified by:
        label in class SimpleUnitFormat
      • parse

        public Unit<?> parse​(CharSequence csq)
                      throws MeasurementParseException
        Specified by:
        parse in interface UnitFormat
        Specified by:
        parse in interface UnitFormatter
        Throws:
        MeasurementParseException
      • alias

        public void alias​(Unit<?> unit,
                          String alias)
        Specified by:
        alias in class SimpleUnitFormat
      • isValidIdentifier

        protected boolean isValidIdentifier​(String name)
        Copy from DefaultFormatter
        Specified by:
        isValidIdentifier in class SimpleUnitFormat
      • isUnitIdentifierPart

        protected static boolean isUnitIdentifierPart​(char ch)