| Modifier and Type | Field and Description |
|---|---|
| private static final Logger | |
| private static final Random | |
| private static final char[] | SYMBOLS
Characters used for random strings |
| private static final String |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static String | Returns: abbreviated string, original string if string length is lower or equal then desired length or null if input was nullstring to abbrivate _str, int max length _length)Abbreviates a String using ellipses. |
| public static int | Returns: given value if in rangevalue to check _check, int minimum allowed value (including) _min, int maximum allowed value (including) _max)Checks if given value is greater or equal to the given minimum and less or equal to the given maximum. |
| public static < type T> boolean | Returns: true if any value found, false if any parameter null or no matching value foundcollection to check _haystack, Collection<T> values to find _needles)Checks if any of the 'needle' values are found in 'haystack'. |
| public static String | Returns: address Stringtrue if the address should be used for a listing socket _listeningSocket, boolean true to create an abstract socket _abstract)Creates a unix socket address using. |
| public static String | Returns: input string or defaultinput string _input, String default to use if input is null _default)Return a default String if input is null. |
| public static String | |
| public static < type of input class C> Constructor | Returns: constructor matching given pattern ornullclass to query for constructor _clz, Class<?>... parameter classes used in constructor _args)Tries to find a constructor of the given class with the given signature. |
| public static String | |
| public static String | |
| public static int | |
| public static List | Returns: list of string or null on errorurl providing the file to read _url, Charset charset to use _charset, boolean true to not log exceptions, false otherwise _silent)Reads a text file from the given URL using the provided charset. |
| public static boolean | |
| public static boolean | |
| public static boolean | |
| public static boolean | |
| public static boolean | Returns: true if MacOS (or MacOS X), false otherwiseChecks if the running OS is a MacOS/MacOS X. |
| public static boolean | Returns: true if int is a valid network port, false otherwise'port' to check _port, boolean allow ports below 1024 (aka reserved well known ports) _allowWellKnown)Check if the given value is a valid network port (1 - 65535). |
| public static boolean | Returns: true if valid port, false otherwisestring to check _str, boolean allow well known port _allowWellKnown)
|
| public static boolean | |
| public static String | Returns: random string or empty string if _length <= 0length of random string _length)Generate a simple (cryptographic insecure) random string. |
| public static List | Returns: list containing textfile to read _fileName)Reads a file to a List<String> (each line is one entry in list). |
| public static String | Returns: String containing content, maybe nullfile to read _file)Reads a file to a String. |
| public static Properties | Returns: Properties Object or nullproperty file to read _file)Trys to read a properties file. |
| public static Properties | Returns: properties object/nullinput stream providing property file content _stream)Tries to read a properties file from an inputstream. |
| public static List | Returns: List of string or null on errorstream to read _input, Charset charset to use _charset, boolean true to disable exception logging, false otherwise _silent)Reads a text file from given |
| public static void | setFilePermissions(Path
path to file which where permissions should be set _path, String new owner for the file _fileOwner, String new group for the file _fileGroup, Set<PosixFilePermission> unix permissions to set on file _fileUnixPermissions)Setup the unix socket file permissions. |
| public static String | Returns: camel case string or input if nothing todo. Returns null if input was null.string _input)Converts a snake-case-string to camel case string. |
| public static boolean | |
| public static Object[] | Returns: object arrayobject of arbitrary type _obj)Convert a object of arbitrary type to an object array. |
| public static Type | Returns: Type used in TypeRef if class is extending TypeRef interface, null otherwiseclass to unwrap _type)Gets the type wrapped by a |
| public static String | Returns: uppercased stringstring _str)Upper case the first letter of the given string. |
| public static < exception type which might be thrown T extends Throwable> void | waitFor(String
name for the lock (used in exception text and logging) _lockName, IThrowingSupplier<Boolean, T> supplier to wait for _wait, long timeout in milliseconds when wait will fail _timeoutMs, long sleep time between each retries _sleepTime)Waits for the provided supplier to return true or throws an exception. |
| public static boolean | Returns: true on successful write, false otherwisethe file to write _fileName, String the content to write _fileContent, Charset the charset to use _charset, boolean append content to file, if false file will be overwritten if existing _append)Write String to file with the given charset. |
| LOGGER | back to summary |
|---|---|
| private static final Logger LOGGER | |
| RANDOM | back to summary |
|---|---|
| private static final Random RANDOM | |
| SYMBOLS | back to summary |
|---|---|
| private static final char[] SYMBOLS Characters used for random strings | |
| SYSPROP_OS_NAME | back to summary |
|---|---|
| private static final String SYSPROP_OS_NAME | |
| Util | back to summary |
|---|---|
| private Util() | |
| abbreviate | back to summary |
|---|---|
| public static String abbreviate(String _str, int _length) Abbreviates a String using ellipses. | |
| checkIntInRange | back to summary |
|---|---|
| public static int checkIntInRange(int _check, int _min, int _max) Checks if given value is greater or equal to the given minimum and less or equal to the given maximum.
| |
| collectionContainsAny | back to summary |
|---|---|
| public static <T> boolean collectionContainsAny(Collection<T> _haystack, Collection<T> _needles) Checks if any of the 'needle' values are found in 'haystack'.
| |
| createDynamicSessionAddress | back to summary |
|---|---|
| public static String createDynamicSessionAddress(boolean _listeningSocket, boolean _abstract) Creates a unix socket address using.
| |
| defaultString | back to summary |
|---|---|
| public static String defaultString(String _input, String _default) Return a default String if input is null. | |
| genGUID | back to summary |
|---|---|
| public static String genGUID() Create a random GUID (used for connection addresses).
| |
| getConstructor | back to summary |
|---|---|
| public static <C> Constructor Tries to find a constructor of the given class with the given signature.
Will catch all exceptions and return
| |
| getCurrentUser | back to summary |
|---|---|
| public static String getCurrentUser() Determines the current logged on user.
| |
| getHostName | back to summary |
|---|---|
| public static String getHostName() Gets the host name of the local machine.
| |
| getJavaVersion | back to summary |
|---|---|
| public static int getJavaVersion() Get the java version of the current running JRE.
| |
| getTextfileFromUrl | back to summary |
|---|---|
| public static List Reads a text file from the given URL using the provided charset. Using the _silent argument optionally disables all error logging. | |
| isBlank | back to summary |
|---|---|
| public static boolean isBlank(String _str) Checks if the given String is either null or blank.
Blank means: " " - true "" - true null - true " xx" - false
| |
| isEmpty | back to summary |
|---|---|
| public static boolean isEmpty(String _str) Checks if the given String is either null or empty.
Blank means: " " - false "" - true null - true " xx" - false
| |
| isFreeBsd | back to summary |
|---|---|
| public static boolean isFreeBsd() | |
| isInteger | back to summary |
|---|---|
| public static boolean isInteger(String _str, boolean _allowNegative) Check if string is an either positive or negative integer.
| |
| isMacOs | back to summary |
|---|---|
| public static boolean isMacOs() Checks if the running OS is a MacOS/MacOS X.
| |
| isValidNetworkPort | back to summary |
|---|---|
| public static boolean isValidNetworkPort(int _port, boolean _allowWellKnown) Check if the given value is a valid network port (1 - 65535).
| |
| isValidNetworkPort | back to summary |
|---|---|
public static boolean isValidNetworkPort(String _str, boolean _allowWellKnown)
| |
| isWindows | back to summary |
|---|---|
| public static boolean isWindows() Checks if the running OS is a MS Windows OS.
| |
| randomString | back to summary |
|---|---|
| public static String randomString(int _length) Generate a simple (cryptographic insecure) random string.
| |
| readFileToList | back to summary |
|---|---|
| public static List Reads a file to a List<String> (each line is one entry in list). Line endings (line feed/carriage return) are NOT removed! | |
| readFileToString | back to summary |
|---|---|
| public static String readFileToString(File _file) Reads a file to a String. Line endings (line feed/carriage return) are NOT removed! | |
| readProperties | back to summary |
|---|---|
| public static Properties readProperties(File _file) Trys to read a properties file. Returns null if properties file could not be loaded
| |
| readProperties | back to summary |
|---|---|
| public static Properties readProperties(InputStream _stream) Tries to read a properties file from an inputstream.
| |
| readTextFileFromStream | back to summary |
|---|---|
| public static List Reads a text file from given
| |
| setFilePermissions | back to summary |
|---|---|
| public static void setFilePermissions(Path _path, String _fileOwner, String _fileGroup, Set<PosixFilePermission> _fileUnixPermissions) Setup the unix socket file permissions. User and group can always be set, file permissions are only set on non-windows OSes.
| |
| snakeToCamelCase | back to summary |
|---|---|
| public static String snakeToCamelCase(String _input) Converts a snake-case-string to camel case string.
| |
| strEquals | back to summary |
|---|---|
| public static boolean strEquals(String _str1, String _str2) Null-safe equals for two strings. | |
| toObjectArray | back to summary |
|---|---|
| public static Object[] toObjectArray(Object _obj) Convert a object of arbitrary type to an object array. | |
| unwrapTypeRef | back to summary |
|---|---|
| public static Type unwrapTypeRef(Class<?> _type) Gets the type wrapped by a | |
| upperCaseFirstChar | back to summary |
|---|---|
| public static String upperCaseFirstChar(String _str) Upper case the first letter of the given string. | |
| waitFor | back to summary |
|---|---|
| public static <T extends Throwable> void waitFor(String _lockName, IThrowingSupplier<Boolean, T> _wait, long _timeoutMs, long _sleepTime) throws IThrowingConsumer:T Waits for the provided supplier to return true or throws an exception.
This method will call the provided supplier every _sleepTime milliseconds to check
if the supplier returns true.
| |
| writeTextFile | back to summary |
|---|---|
| public static boolean writeTextFile(String _fileName, String _fileContent, Charset _charset, boolean _append) Write String to file with the given charset. Optionally appends the data to the file. | |