Class Utils

java.lang.Object
org.sentrysoftware.ssh.Utils

public class Utils extends Object
Utility Class (static), to be used anywhere in Matsya, including in standalone JARs (in CLI mode)
Author:
Bertrand
  • Method Details

    • getCharsetFromLocale

      public static Charset getCharsetFromLocale(String locale, Charset defaultCharset)
      Returns the proper Charset that can decode/encode the specified locale
      Parameters:
      locale - The locale we're dealing with, as formatted in the LANG environment variable (e.g. zh_CN.utf8)
      defaultCharset - The default Charset to use if the specified locale doesn't match any supported Charset
      Returns:
      The appropriate Charset instance
    • getCharsetFromLocale

      public static Charset getCharsetFromLocale(String locale)
      Returns the proper Charset that can decode/encode the specified locale, or UTF-8 if specified locale cannot be converted to a Charset.
      Parameters:
      locale - The locale we're dealing with, as formatted in the LANG environment variable (e.g. zh_CN.utf8)
      Returns:
      The appropriate Charset instance
    • checkNonNullField

      public static <T> void checkNonNullField(T field, String name)
      Check if the required field is not null.
      Parameters:
      field -
      name -
      Throws:
      IllegalStateException - if the argument is null
    • checkArgumentNotZeroOrNegative

      public static void checkArgumentNotZeroOrNegative(long argument, String name)
      Check if the required argument is not negative or zero.
      Parameters:
      argument -
      name -
      Throws:
      IllegalArgumentException - if the argument is null