Package org.sentrysoftware.ssh
Class Utils
java.lang.Object
org.sentrysoftware.ssh.Utils
Utility Class (static), to be used anywhere in Matsya, including in
standalone JARs (in CLI mode)
- Author:
- Bertrand
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkArgumentNotZeroOrNegative
(long argument, String name) Check if the required argument is not negative or zero.static <T> void
checkNonNullField
(T field, String name) Check if the required field is not null.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.static Charset
getCharsetFromLocale
(String locale, Charset defaultCharset) Returns the proper Charset that can decode/encode the specified locale
-
Method Details
-
getCharsetFromLocale
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
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
Check if the required field is not null.- Parameters:
field
-name
-- Throws:
IllegalStateException
- if the argument is null
-
checkArgumentNotZeroOrNegative
Check if the required argument is not negative or zero.- Parameters:
argument
-name
-- Throws:
IllegalArgumentException
- if the argument is null
-