Package com.jk.core.util
Class JKDebugUtil
java.lang.Object
com.jk.core.util.JKDebugUtil
This class is a utility class used for debugging and logging purposes.
- Version:
- 1.0
- Author:
- Dr. Jalal H. Kiswani
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
This method retrieves the caller of the method where this is called.static Class<?>
This method retrieves the class that triggered the exception in the stack trace.static String
This method retrieves the main class name of the current thread's stack trace.static void
This main method makes a time block for a sleeping operation that takes3000
milliseconds and tests to see if thetimeBlock(Runnable)
method shows the time accurately by printing its results.static void
printCurrentTime
(Object label) This method prints the current time along with a label.static void
This method prints the stack trace of the current thread.static long
This method measures the time it takes to execute a Runnable block of code.static String
This method converts an exception's stack trace to a string.
-
Constructor Details
-
JKDebugUtil
public JKDebugUtil()
-
-
Method Details
-
getExceptionCallerClass
This method retrieves the class that triggered the exception in the stack trace.- Parameters:
t
- Specifies the throwable object (exception).- Returns:
- the class that triggered the exception.
-
printCurrentTime
This method prints the current time along with a label.- Parameters:
label
- Specifies the label to be printed.
-
printStackTrace
public static void printStackTrace()This method prints the stack trace of the current thread. -
getCaller
This method retrieves the caller of the method where this is called.- Returns:
- the caller's information.
-
getMainClassName
This method retrieves the main class name of the current thread's stack trace.- Returns:
- the main class name.
-
toString
This method converts an exception's stack trace to a string.- Parameters:
e
- Specifies the exception to be converted.- Returns:
- the stack trace as a string.
-
timeBlock
This method measures the time it takes to execute a Runnable block of code.- Parameters:
runnable
- Specifies the code block to be executed.- Returns:
- the time taken in milliseconds.
-
main
This main method makes a time block for a sleeping operation that takes3000
milliseconds and tests to see if thetimeBlock(Runnable)
method shows the time accurately by printing its results.- Parameters:
args
- the command-line arguments.
-