com.icesoft.pdf.util
Class Debug

java.lang.Object
  extended byjava.lang.Throwable
      extended byjava.lang.Exception
          extended byjava.lang.RuntimeException
              extended bycom.icesoft.pdf.util.Debug
All Implemented Interfaces:
Serializable

public class Debug
extends RuntimeException

Use this class (instead of System.ou) for printing all debuggin information.

Since:
1.0
See Also:
Serialized Form

Field Summary
static boolean all
          Activates all printings / checks.
static boolean check
          Support for design by contract.
static boolean chk
          Triggers exception throwing on code errors.
static boolean ex
          Should print exception stack traces.
static boolean extra
          Enables various additional debug facilities.
static boolean trace
          Should print trace strings.
 
Method Summary
static void bug()
          Throw RuntimeException to indicate broken arguments/state
static void checkOrderLE(int a, int b, int c)
          Check if a ≤ b ≤ c holds and throws an exception if not.
static void checkOrderLE(int a, int b, int c, int d)
          Check if a ≤ b ≤ c ≤ d holds and throws an exception if not.
static void ex(Throwable exception)
          Print exception stack.
static String getStackPrintoutAsString(Throwable ex)
           
static void p(String str)
          Print debug string.
static void s()
          Print stack trace.
static void s(String message)
          Print stack trace annotated with message.
static void trace(String s)
          Print trace text if in trace mode.
static void traceAsIs(String s)
           
static void traceStack(String title)
           
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

all

public static final boolean all
Activates all printings / checks.


trace

public static final boolean trace
Should print trace strings.


ex

public static final boolean ex
Should print exception stack traces.


chk

public static final boolean chk
Triggers exception throwing on code errors.


extra

public static final boolean extra

Enables various additional debug facilities. Currently used properties:


check

public static final boolean check
Support for design by contract. If true, failed consistency/validity checks throw exception

See Also:
bug(), Constant Field Values
Method Detail

getStackPrintoutAsString

public static String getStackPrintoutAsString(Throwable ex)

p

public static void p(String str)
Print debug string. All calls to Debug.p should be commneted out/removed in the production code.


s

public static void s()
Print stack trace. All calls to Debug.s should be commneted out/removed in the production code.


s

public static void s(String message)
Print stack trace annotated with message. All calls to Debug.s should be commneted out/removed in the production code.


trace

public static void trace(String s)
Print trace text if in trace mode. This should be used to monitor important events code/points that useful to analyze bug reports. The output will include method name that calls Debug.trace(...). Usage should always be like:
                if (Debug.trace) Debug.trace(...)


traceAsIs

public static void traceAsIs(String s)

traceStack

public static void traceStack(String title)

ex

public static void ex(Throwable exception)
Print exception stack. Possible usage:
                try {
                        some code
                } catch (IOException ex) {
                        if (Debug.ex) Debug.ex(ex);
                        if (Debug.trace) Debug.trace("Unexpected IO error: "+ex);
                }


bug

public static void bug()
Throw RuntimeException to indicate broken arguments/state
        void setWisth(int width) {
                if (Debug.check && width < 0) Debug.bug();
                ...
        }

See Also:
check

checkOrderLE

public static void checkOrderLE(int a,
                                int b,
                                int c)
Check if a ≤ b ≤ c holds and throws an exception if not.


checkOrderLE

public static void checkOrderLE(int a,
                                int b,
                                int c,
                                int d)
Check if a ≤ b ≤ c ≤ d holds and throws an exception if not.