public class Tools
extends java.lang.Object
As an example, our logger system can easily be used to print colored log/debug messages to the standard output:
Tools.log("Hello world", Tools.Color.ANSI_RED); Tools.debug("Hello world", Tools.Color.ANSI_BLUE);
You can easily disable thoses logs/debugs with the following static methods:
Tools.disableLogs(); Tools.disableDebugs();
Note that you can also easily disable the use of the colors for the logs. Indeed, some standard outputs don't like this kind of ANSI codes:
Tools.disableColors();
Modifier and Type | Class and Description |
---|---|
static class |
Tools.Color
Colors that can be used to print log and debug messages to standard output.
|
Modifier and Type | Method and Description |
---|---|
static void |
debug(java.lang.Object obj)
Print a new debug message to the standard output, if the debugs are enabled.
|
static void |
debug(java.lang.Object obj,
Tools.Color color)
Print a new colored debug message to the standard output, if the debugs are enabled.
|
static void |
debug(java.lang.String message)
Print a new debug message to the standard output, if the debugs are enabled.
|
static void |
debug(java.lang.String message,
Tools.Color color)
Print a new colored debug message to the standard output, if the debugs are enabled.
|
static int |
decodeInt(int bitLength,
byte[] incoming,
int startingBitLocation)
Decode an int value from the input byte array.
|
static void |
disableColors()
Disable the use of colors to print log/debug messages.
|
static void |
disableDebugs()
Disable printing debug messages to the standard output.
|
static void |
disableLogs()
Disable printing log messages to the standard output.
|
static void |
enableColors()
Enable the use of colors to print log/debug messages.
|
static void |
enableDebugs()
Enable printing debug messages to the standard output.
|
static void |
enableLogs()
Enable printing log messages to the standard output.
|
static java.util.BitSet |
extractBitSet(int bitLength,
byte[] incoming,
int startingBitLocation)
Extracts a BitSet from the incoming byte array.
|
static java.lang.String |
getBinaryString(byte[] byteArray)
Returns the String representation of the byte array given in input.
|
static void |
log(java.lang.Object obj)
Print a new log message to the standard output, if the logs are enabled.
|
static void |
log(java.lang.Object obj,
Tools.Color color)
Print a new colored log message to the standard output, if the logs are enabled.
|
static void |
log(java.lang.String message)
Print a new log message to the standard output, if the logs are enabled.
|
static void |
log(java.lang.String message,
Tools.Color color)
Print a new colored log message to the standard output, if the logs are enabled.
|
static void |
sleepMilliseconds(long millis)
Causes the currently executing thread to sleep (temporarily cease execution) for
the specified number of milliseconds, subject to the precision and accuracy of
system timers and schedulers.
|
public static void log(java.lang.Object obj, Tools.Color color)
obj
- the object to print in the log content (obj.toString()).color
- the color used to print the log.enableLogs()
,
enableColors()
,
disableLogs()
,
disableColors()
public static void log(java.lang.String message, Tools.Color color)
message
- the String message to print in the log content.color
- the color used to print the log.enableLogs()
,
enableColors()
,
disableLogs()
,
disableColors()
public static void log(java.lang.Object obj)
obj
- the object to print in the log content (obj.toString()).enableLogs()
,
disableLogs()
public static void log(java.lang.String message)
message
- the String message to print in the log content.enableLogs()
,
disableLogs()
public static void debug(java.lang.Object obj, Tools.Color color)
obj
- the object to print in the debug content (obj.toString()).color
- the color used to print the debug.enableDebugs()
,
enableColors()
,
disableDebugs()
,
disableColors()
public static void debug(java.lang.String message, Tools.Color color)
message
- the String message to print in the debug content.color
- the color used to print the debug.enableDebugs()
,
enableColors()
,
disableDebugs()
,
disableColors()
public static void debug(java.lang.Object obj)
obj
- the object to print in the debug content (obj.toString()).enableDebugs()
,
disableDebugs()
public static void debug(java.lang.String message)
message
- the String message to print in the debug content.enableDebugs()
,
disableDebugs()
public static void enableLogs()
public static void disableLogs()
public static void enableDebugs()
public static void disableDebugs()
public static void enableColors()
public static void disableColors()
public static java.lang.String getBinaryString(byte[] byteArray)
byteArray
- the byteArray to analyze.public static int decodeInt(int bitLength, byte[] incoming, int startingBitLocation)
bitLength
- the number of bits to decode.incoming
- the byte array to decode from.startingBitLocation
- the starting bit location in the byte array.public static java.util.BitSet extractBitSet(int bitLength, byte[] incoming, int startingBitLocation)
If bitLength == -1
, extracts from startingBitLocation to the end of the BitSet.
bitLength
- the number of bits to extract.incoming
- the byte array from where the BitSet is extracted.startingBitLocation
- the starting location from which the BitSet is extracted.public static void sleepMilliseconds(long millis)
Allows to properly catch the InterruptedException.
millis
- the number of milliseconds to wait.