Some utilities to make our lives easier.
More...
|
static void | notNullFatal (Object something, String message) |
| Check if the given object is null, abort program if true. More...
|
|
static void | notNullFatal (int number, String message) |
| Check if the given object is null, abort program if true. More...
|
|
static void | notNullOrEmptyFatal (String something, String message) |
| Check if String is null or empty, abort program if so. More...
|
|
static int | randomInt (int n) |
| Return a random integer in the range of 0 (inclusive) and n (exclusive). More...
|
|
static void | deleteFolder (File folder) |
| Remove a folder and all contents. More...
|
|
static boolean | isEmpty (String str) |
|
static boolean | isEmpty (String str, String message, Logger logger) |
|
static int | tryToParseInt (String s) |
| Tries to parse an int. More...
|
|
static int | tryToParseInt (String s, int defaultValue) |
| Tries to parse an int. More...
|
|
static BigInteger | tryToParseBigInt (String s) |
| Tries to parse a bigint. More...
|
|
static int | getNumberOfBlocks (long fileSize, int blockSize) |
|
static String | sanitizeFileName (String fileName) |
|
static boolean | keysEqual (Key k1, Key k2) |
| Checks whether the two given keys are equal. More...
|
|
static String | getRelativePath (File absolutePath, File parentDir) |
|
static boolean | isUUID (String id) |
|
|
static Logger | LOGGER = LogManager.getLogger( Util.class ) |
|
static final Random | random = new Random() |
| Static Random instance. More...
|
|
Some utilities to make our lives easier.
Definition at line 18 of file Util.java.
static void org.openslx.imagemaster.util.Util.deleteFolder |
( |
File |
folder | ) |
|
|
static |
Remove a folder and all contents.
- Parameters
-
Definition at line 108 of file Util.java.
static int org.openslx.imagemaster.util.Util.getNumberOfBlocks |
( |
long |
fileSize, |
|
|
int |
blockSize |
|
) |
| |
|
static |
static String org.openslx.imagemaster.util.Util.getRelativePath |
( |
File |
absolutePath, |
|
|
File |
parentDir |
|
) |
| |
|
static |
static boolean org.openslx.imagemaster.util.Util.isEmpty |
( |
String |
str | ) |
|
|
static |
static boolean org.openslx.imagemaster.util.Util.isEmpty |
( |
String |
str, |
|
|
String |
message, |
|
|
Logger |
logger |
|
) |
| |
|
static |
static boolean org.openslx.imagemaster.util.Util.isUUID |
( |
String |
id | ) |
|
|
static |
static boolean org.openslx.imagemaster.util.Util.keysEqual |
( |
Key |
k1, |
|
|
Key |
k2 |
|
) |
| |
|
static |
Checks whether the two given keys are equal.
Works for public and private keys.
- Parameters
-
- Returns
- true if equal
Definition at line 202 of file Util.java.
static void org.openslx.imagemaster.util.Util.notNullFatal |
( |
Object |
something, |
|
|
String |
message |
|
) |
| |
|
static |
Check if the given object is null, abort program if true.
An optional message to be printed can be passed. A stack trace will be printed, too. Finally the application terminates with exit code 2.
This comes in handy if something must not be null, and you want user friendly output. A perfect example would be reading settings from a config file. You can use this on mandatory fields.
- Parameters
-
something | the object to compare to null |
message | the message to be printed if something is null |
Definition at line 36 of file Util.java.
static void org.openslx.imagemaster.util.Util.notNullFatal |
( |
int |
number, |
|
|
String |
message |
|
) |
| |
|
static |
Check if the given object is null, abort program if true.
An optional message to be printed can be passed. A stack trace will be printed, too. Finally the application terminates with exit code 2.
This comes in handy if something must not be null, and you want user friendly output. A perfect example would be reading settings from a config file. You can use this on mandatory fields.
- Parameters
-
something | the object to compare to null |
message | the message to be printed if something is null |
Definition at line 58 of file Util.java.
static void org.openslx.imagemaster.util.Util.notNullOrEmptyFatal |
( |
String |
something, |
|
|
String |
message |
|
) |
| |
|
static |
Check if String is null or empty, abort program if so.
An optional message to be printed can be passed. A stack trace will be printed, too. Finally the application terminates with exit code 2.
- Parameters
-
something | The string you want to check |
message | The message to be printed if "something" is null or empty |
Definition at line 76 of file Util.java.
static int org.openslx.imagemaster.util.Util.randomInt |
( |
int |
n | ) |
|
|
static |
Return a random integer in the range of 0 (inclusive) and n (exclusive).
Uses the internal static instance of Random, so you don't have to deal with instances everywhere.
- Parameters
-
n | the upper bound (exclusive) |
- Returns
- number between 0 (inclusive) and n (exclusive)
Definition at line 98 of file Util.java.
static String org.openslx.imagemaster.util.Util.sanitizeFileName |
( |
String |
fileName | ) |
|
|
static |
static BigInteger org.openslx.imagemaster.util.Util.tryToParseBigInt |
( |
String |
s | ) |
|
|
static |
Tries to parse a bigint.
Returns null on error.
- Parameters
-
- Returns
- The parsed bigint
Definition at line 169 of file Util.java.
static int org.openslx.imagemaster.util.Util.tryToParseInt |
( |
String |
s | ) |
|
|
static |
Tries to parse an int.
Returns 0 on error.
- Parameters
-
- Returns
- The parsed int or 0 on error
Definition at line 142 of file Util.java.
static int org.openslx.imagemaster.util.Util.tryToParseInt |
( |
String |
s, |
|
|
int |
defaultValue |
|
) |
| |
|
static |
Tries to parse an int.
Returns defaultValue on error.
- Parameters
-
s | The strig to parse |
defaultValue | value to be returned if s is not parsable |
- Returns
- The parsed int
Definition at line 154 of file Util.java.
Logger org.openslx.imagemaster.util.Util.LOGGER = LogManager.getLogger( Util.class ) |
|
staticprivate |
final Random org.openslx.imagemaster.util.Util.random = new Random() |
|
staticprivate |
The documentation for this class was generated from the following file: