Class NetCDFUnitFormat


  • public class NetCDFUnitFormat
    extends Object
    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 Summary

      Fields 
      Modifier and Type Field Description
      static String NETCDF_UNIT_ALIASES
      Unit aliases config file name (normally looked up in the classpath)
      static String NETCDF_UNIT_REPLACEMENTS
      Unit replacements config file name (normally looked up in the classpath)
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static String format​(Unit<?> unit)
      Formats the unit
      static LinkedHashMap<String,​String> loadPropertiesOrdered​(InputStream is)
      Loads a properties file preserving its internal order
      static Unit<?> parse​(String spec)
      Parses a unit applying the configured set of replacements and aliases
      static void reset()
      Resets the format to the built-in defaults
      static void setAliases​(Map<String,​String> aliases)
      Configures the aliases to be used on the unit parser.
      static void setReplacements​(Map<String,​String> replacements)
      Configures the string replacements to be performed before trying to parse the units.
      • Methods inherited from class Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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

      • reset

        public static void reset()
        Resets the format to the built-in defaults
      • setReplacements

        public static 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
      • 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
      • setAliases

        public static 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 static Unit<?> parse​(String spec)
        Parses a unit applying the configured set of replacements and aliases
      • format

        public static String format​(Unit<?> unit)
        Formats the unit
        Parameters:
        unit - The unit to be formatted
        Returns:
        A string representation of the same unit.