com.fatwire.gst.foundation
Class DebugHelper

java.lang.Object
  extended by com.fatwire.gst.foundation.DebugHelper

public final class DebugHelper
extends Object

Various helper methods for debugging.

Author:
Dolf Dijkstra

Field Summary
static String TIME_LOGGER
           
 
Method Summary
static void dumpSSVars(COM.FutureTense.Interfaces.ICS ics, PrintWriter pw)
           
static void dumpVars(COM.FutureTense.Interfaces.ICS ics)
           
static void dumpVars(COM.FutureTense.Interfaces.ICS ics, org.apache.commons.logging.Log log)
           
static void dumpVars(COM.FutureTense.Interfaces.ICS ics, PrintWriter pw)
           
static Throwable findRootCause(Throwable e)
          Retrieves the root exception of a Throwable.
static String microToHuman(long elapsed)
          Converts an elapsed time in micro seconds to a human readable string with seconds and milliseconds precision on larger elapsed times.
static String milliToHuman(long elapsed)
          Converts an elapsed time in nano seconds to a human readable string with microseconds, seconds and milliseconds precision on larger elapsed times.
static String nanoToHuman(long elapsed)
          Converts an elapsed time in milli seconds to a human readable string with minutes and seconds precision on larger elapsed times.
static String printAsset(com.fatwire.assetapi.data.AssetData ad)
          Print the AssetData to a string for debugging purposes.
static void printStackTrace(Writer writer, Throwable t)
          Prints the StackTrace of the Throwable to the Writer.
static String printState(COM.FutureTense.Interfaces.ICS ics)
          Dumps to current ICS state (Content Server variables, session variables,ICS objects,elementname,page url and stacktrace) as a String.
static void printTime(org.apache.commons.logging.Log log, String msg, long start)
          Print the elapsed time since the start to the provided Log.
static void printTime(org.apache.commons.logging.Log log, String msg, long start, long end)
          Print the elapsed time between the start and end to the provided logger in a human readable form.
static void printTime(String msg, long start)
          Print the elapsed time since the start to the default time logger TIME_LOGGER.
static String toString(com.fatwire.assetapi.data.AssetId assetId)
          Returns the assetid in as a human readable string in the format of type:id.
static String toString(Throwable t)
          Creates a String from the Throwable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TIME_LOGGER

public static final String TIME_LOGGER
Method Detail

dumpVars

public static void dumpVars(COM.FutureTense.Interfaces.ICS ics)

dumpVars

public static void dumpVars(COM.FutureTense.Interfaces.ICS ics,
                            org.apache.commons.logging.Log log)

dumpVars

public static void dumpVars(COM.FutureTense.Interfaces.ICS ics,
                            PrintWriter pw)

dumpSSVars

public static void dumpSSVars(COM.FutureTense.Interfaces.ICS ics,
                              PrintWriter pw)

findRootCause

public static Throwable findRootCause(Throwable e)
Retrieves the root exception of a Throwable.

Parameters:
e - the exception with nested exceptions (causes)
Returns:
the root cause

microToHuman

public static String microToHuman(long elapsed)
Converts an elapsed time in micro seconds to a human readable string with seconds and milliseconds precision on larger elapsed times.

Parameters:
elapsed - the elapsed time in micro seconds (us)
Returns:
A human readable string for the elapsed micro seconds

milliToHuman

public static String milliToHuman(long elapsed)
Converts an elapsed time in nano seconds to a human readable string with microseconds, seconds and milliseconds precision on larger elapsed times. Precision is dropped to microseconds precision.

Parameters:
elapsed - the elapsed time in nano seconds (us)
Returns:
A human readable string for the elapsed micro seconds

nanoToHuman

public static String nanoToHuman(long elapsed)
Converts an elapsed time in milli seconds to a human readable string with minutes and seconds precision on larger elapsed times.

Parameters:
elapsed - the elapsed time in nano seconds (us)
Returns:
A human readable string for the elapsed micro seconds

printTime

public static void printTime(org.apache.commons.logging.Log log,
                             String msg,
                             long start,
                             long end)
Print the elapsed time between the start and end to the provided logger in a human readable form.

Parameters:
log - The logger where the message will be printed to.
msg - The message as an indicator of the operation that was monitored.
start - time in nanoseconds System.nanoTime()
end - time in nanoseconds System.nanoTime()
See Also:
microToHuman(long)

printTime

public static void printTime(org.apache.commons.logging.Log log,
                             String msg,
                             long start)
Print the elapsed time since the start to the provided Log.

Parameters:
log - The logger where the message will be printed to.
msg - The message as an indicator of the operation that was monitored.
start - time in nanoseconds System.nanoTime()
See Also:
microToHuman(long)

printTime

public static void printTime(String msg,
                             long start)
Print the elapsed time since the start to the default time logger TIME_LOGGER.

Parameters:
msg - The message as an indicator of the operation that was monitored.
start - time in nanoseconds System.nanoTime()
See Also:
microToHuman(long)

printAsset

public static String printAsset(com.fatwire.assetapi.data.AssetData ad)
                         throws com.fatwire.assetapi.common.AssetAccessException
Print the AssetData to a string for debugging purposes.

Parameters:
ad - the asset date
Returns:
String with asset attributes etc
Throws:
com.fatwire.assetapi.common.AssetAccessException

toString

public static String toString(com.fatwire.assetapi.data.AssetId assetId)
Returns the assetid in as a human readable string in the format of type:id.

Parameters:
assetId - the asset id.
Returns:
a String concatenated with type and id.

toString

public static String toString(Throwable t)
Creates a String from the Throwable.

Parameters:
t - the throwable to print.
Returns:
a string with the message and the stacktrace.

printStackTrace

public static void printStackTrace(Writer writer,
                                   Throwable t)
Prints the StackTrace of the Throwable to the Writer.

Parameters:
writer - writer to write to.
t - the Throwable to print the stacktrace of.

printState

public static String printState(COM.FutureTense.Interfaces.ICS ics)
Dumps to current ICS state (Content Server variables, session variables,ICS objects,elementname,page url and stacktrace) as a String.

Parameters:
ics -
Returns:
the state of ICS.


Copyright © 2010-2013 Oracle Corporation. All Rights Reserved.