bwLehrpool Masterserver
Manages authentication and sharing of virtual machines between participating institutions
Static Public Member Functions | Static Private Attributes | List of all members
org.openslx.imagemaster.util.Util Class Reference

Some utilities to make our lives easier. More...

+ Collaboration diagram for org.openslx.imagemaster.util.Util:

Static Public Member Functions

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 Private Attributes

static Logger LOGGER = LogManager.getLogger( Util.class )
 
static final Random random = new Random()
 Static Random instance. More...
 

Detailed Description

Some utilities to make our lives easier.

Definition at line 18 of file Util.java.

Member Function Documentation

static void org.openslx.imagemaster.util.Util.deleteFolder ( File  folder)
static

Remove a folder and all contents.

Parameters
folder

Definition at line 108 of file Util.java.

static int org.openslx.imagemaster.util.Util.getNumberOfBlocks ( long  fileSize,
int  blockSize 
)
static

Definition at line 178 of file Util.java.

static String org.openslx.imagemaster.util.Util.getRelativePath ( File  absolutePath,
File  parentDir 
)
static

Definition at line 222 of file Util.java.

+ Here is the caller graph for this function:

static boolean org.openslx.imagemaster.util.Util.isEmpty ( String  str)
static

Definition at line 123 of file Util.java.

+ Here is the caller graph for this function:

static boolean org.openslx.imagemaster.util.Util.isEmpty ( String  str,
String  message,
Logger  logger 
)
static

Definition at line 128 of file Util.java.

static boolean org.openslx.imagemaster.util.Util.isUUID ( String  id)
static

Definition at line 238 of file Util.java.

+ Here is the caller graph for this function:

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
k1first key
k2second key
Returns
true if equal

Definition at line 202 of file Util.java.

+ Here is the caller graph for this function:

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
somethingthe object to compare to null
messagethe 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
somethingthe object to compare to null
messagethe 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
somethingThe string you want to check
messageThe 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
nthe upper bound (exclusive)
Returns
number between 0 (inclusive) and n (exclusive)

Definition at line 98 of file Util.java.

+ Here is the caller graph for this function:

static String org.openslx.imagemaster.util.Util.sanitizeFileName ( String  fileName)
static

Definition at line 186 of file Util.java.

static BigInteger org.openslx.imagemaster.util.Util.tryToParseBigInt ( String  s)
static

Tries to parse a bigint.

Returns null on error.

Parameters
sThe strig to parse
Returns
The parsed bigint

Definition at line 169 of file Util.java.

+ Here is the caller graph for this function:

static int org.openslx.imagemaster.util.Util.tryToParseInt ( String  s)
static

Tries to parse an int.

Returns 0 on error.

Parameters
sThe strig to parse
Returns
The parsed int or 0 on error

Definition at line 142 of file Util.java.

+ Here is the caller graph for this function:

static int org.openslx.imagemaster.util.Util.tryToParseInt ( String  s,
int  defaultValue 
)
static

Tries to parse an int.

Returns defaultValue on error.

Parameters
sThe strig to parse
defaultValuevalue to be returned if s is not parsable
Returns
The parsed int

Definition at line 154 of file Util.java.

Member Data Documentation

Logger org.openslx.imagemaster.util.Util.LOGGER = LogManager.getLogger( Util.class )
staticprivate

Definition at line 21 of file Util.java.

final Random org.openslx.imagemaster.util.Util.random = new Random()
staticprivate

Static Random instance.

Definition at line 88 of file Util.java.


The documentation for this class was generated from the following file: