Class JKDebugUtil

java.lang.Object
com.jk.core.util.JKDebugUtil

public class JKDebugUtil extends Object
This class is a utility class used for debugging and logging purposes.
Version:
1.0
Author:
Dr. Jalal H. Kiswani
  • Constructor Details

    • JKDebugUtil

      public JKDebugUtil()
  • Method Details

    • getExceptionCallerClass

      public static Class<?> getExceptionCallerClass(Throwable t)
      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

      public static void printCurrentTime(Object label)
      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

      public static String getCaller()
      This method retrieves the caller of the method where this is called.
      Returns:
      the caller's information.
    • getMainClassName

      public static String getMainClassName()
      This method retrieves the main class name of the current thread's stack trace.
      Returns:
      the main class name.
    • toString

      public static String toString(Exception e)
      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

      public static long timeBlock(Runnable runnable)
      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

      public static void main(String[] args)
      This main method makes a time block for a sleeping operation that takes 3000 milliseconds and tests to see if the timeBlock(Runnable) method shows the time accurately by printing its results.
      Parameters:
      args - the command-line arguments.