Class NetCDFUnitFormat

  • All Implemented Interfaces:
    UnitFormatter

    public final class NetCDFUnitFormat
    extends BaseUnitFormatter
    Parser/Encoder for units expressed in the NetCDF CF syntax, with ability to configure the unit syntax transformation and allow setting up custom aliases just for the NetCDF case.
    • Field Detail

      • NETCDF_UNIT_ALIASES

        public static final String NETCDF_UNIT_ALIASES
        Unit aliases config file name (normally looked up in the classpath)
        See Also:
        Constant Field Values
      • NETCDF_UNIT_REPLACEMENTS

        public static final String NETCDF_UNIT_REPLACEMENTS
        Unit replacements config file name (normally looked up in the classpath)
        See Also:
        Constant Field Values
    • Method Detail

      • createWithBuiltInConfig

        public static NetCDFUnitFormat createWithBuiltInConfig()
        Creates a NetCDFUnitFormat with the built-in defaults.
      • builtInReplacements

        public static Map<String,​String> builtInReplacements()
      • loadPropertiesOrdered

        public static LinkedHashMap<String,​String> loadPropertiesOrdered​(InputStream is)
        Loads a properties file preserving its internal order
        Parameters:
        is - The input stream to be read
        Returns:
        The contents as a LinkedHashMap preserving the file contents
      • setReplacements

        public void setReplacements​(Map<String,​String> replacements)
        Configures the string replacements to be performed before trying to parse the units.
        Parameters:
        replacements - The replacements to be used. It is strongly advised to use a LinkedHashMap as replacements are run from top to bottom, in order, and the order might influence the results
      • setAliases

        public void setAliases​(Map<String,​String> aliases)
        Configures the aliases to be used on the unit parser. An alias is a different name for a unit.
      • parse

        public Unit<?> parse​(String spec)
        Parses a unit applying the configured set of replacements and aliases