首页

关于apache的commons-imaging中Debug调试类封装打印各种场景格式要求显示类型输出情况

标签:调试类,commons-imaging,apache     发布时间:2018-02-17   

一、前言

关于apachecommons-imaging包中org.apache.commons.imaging.util.Debug调试类,对各种类型的输出格式进行调试的应用常见进行封装输出统一规范风格的日志。

二、源码说明

package org.apache.commons.imaging.util;@b@@b@import java.awt.Dimension;@b@import java.awt.Point;@b@import java.awt.Rectangle;@b@import java.awt.color.ICC_Profile;@b@import java.io.File;@b@import java.io.PrintStream;@b@import java.text.DateFormat;@b@import java.text.SimpleDateFormat;@b@import java.util.ArrayList;@b@import java.util.Calendar;@b@import java.util.Date;@b@import java.util.List;@b@import java.util.Map;@b@import java.util.Map.Entry;@b@@b@public final class Debug@b@{@b@  private static final boolean DEBUG = 0;@b@  private static long counter = 0L;@b@  public static final String newline = "\r\n";@b@@b@  public static void debug(String message)@b@  {@b@  }@b@@b@  public static void debug(Object o)@b@  {@b@  }@b@@b@  public static String getDebug(String message)@b@  {@b@    return message;@b@  }@b@@b@  public static void debug() {@b@    newline();@b@  }@b@@b@  public static void newline()@b@  {@b@  }@b@@b@  public static String getDebug(String message, int value)@b@  {@b@    return getDebug(message + ": " + value);@b@  }@b@@b@  public static String getDebug(String message, double value) {@b@    return getDebug(message + ": " + value);@b@  }@b@@b@  public static String getDebug(String message, String value) {@b@    return getDebug(message + " " + value);@b@  }@b@@b@  public static String getDebug(String message, long value) {@b@    return getDebug(message + " " + Long.toString(value));@b@  }@b@@b@  public static String getDebug(String message, int[] v) {@b@    StringBuilder result = new StringBuilder();@b@@b@    if (v == null) {@b@      result.append(message + " (" + null + ")" + "\r\n");@b@    } else {@b@      result.append(message + " (" + v.length + ")" + "\r\n");@b@      int[] arr$ = v; int len$ = arr$.length; for (int i$ = 0; i$ < len$; ++i$) { int element = arr$[i$];@b@        result.append("\t" + element + "\r\n");@b@      }@b@      result.append("\r\n");@b@    }@b@    return result.toString();@b@  }@b@@b@  public static String getDebug(String message, byte[] v) {@b@    int max = 250;@b@    return getDebug(message, v, 250);@b@  }@b@@b@  public static String getDebug(String message, byte[] v, int max)@b@  {@b@    StringBuilder result = new StringBuilder();@b@@b@    if (v == null) {@b@      result.append(message + " (" + null + ")" + "\r\n");@b@    } else {@b@      result.append(message + " (" + v.length + ")" + "\r\n");@b@      for (int i = 0; (i < max) && (i < v.length); ++i) {@b@        char c;@b@        int b = 0xFF & v[i];@b@@b@        if ((b == 0) || (b == 10) || (b == 11) || (b == 13))@b@          c = ' ';@b@        else {@b@          c = (char)b;@b@        }@b@@b@        result.append("\t" + i + ": " + b + " (" + c + ", 0x" + Integer.toHexString(b) + ")" + "\r\n");@b@      }@b@@b@      if (v.length > max) {@b@        result.append("\t...\r\n");@b@      }@b@@b@      result.append("\r\n");@b@    }@b@    return result.toString();@b@  }@b@@b@  public static String getDebug(String message, char[] v) {@b@    StringBuilder result = new StringBuilder();@b@@b@    if (v == null) {@b@      result.append(getDebug(new StringBuilder().append(message).append(" (").append(null).append(")").toString()) + "\r\n");@b@    } else {@b@      result.append(getDebug(new StringBuilder().append(message).append(" (").append(v.length).append(")").toString()) + "\r\n");@b@      char[] arr$ = v; int len$ = arr$.length; for (int i$ = 0; i$ < len$; ++i$) { char element = arr$[i$];@b@        result.append(getDebug(new StringBuilder().append("\t").append(element).append(" (").append(0xFF & element).toString()) + ")" + "\r\n");@b@      }@b@@b@      result.append("\r\n");@b@    }@b@    return result.toString();@b@  }@b@@b@  public static String getDebug(String message, List<?> v)@b@  {@b@    StringBuilder result = new StringBuilder();@b@@b@    String suffix = " [" + (counter++) + "]";@b@@b@    result.append(getDebug(new StringBuilder().append(message).append(" (").append(v.size()).append(")").append(suffix).toString()) + "\r\n");@b@@b@    for (int i = 0; i < v.size(); ++i) {@b@      result.append(getDebug(new StringBuilder().append("\t").append(v.get(i).toString()).append(suffix).toString()) + "\r\n");@b@    }@b@@b@    result.append("\r\n");@b@@b@    return result.toString();@b@  }@b@@b@  public static void debug(String message, Map<?, ?> map) {@b@    debug(getDebug(message, map));@b@  }@b@@b@  public static String getDebug(String message, Map<?, ?> map) {@b@    StringBuilder result = new StringBuilder();@b@@b@    if (map == null) {@b@      return getDebug(message + " map: " + null);@b@    }@b@@b@    List keys = new ArrayList(map.keySet());@b@    result.append(getDebug(new StringBuilder().append(message).append(" map: ").append(keys.size()).toString()) + "\r\n");@b@    for (int i = 0; i < keys.size(); ++i) {@b@      Object key = keys.get(i);@b@      Object value = map.get(key);@b@      result.append(getDebug(new StringBuilder().append("\t").append(i).append(": '").append(key).append("' -> '").append(value).append("'").toString()) + "\r\n");@b@    }@b@@b@    result.append("\r\n");@b@@b@    return result.toString();@b@  }@b@@b@  public static boolean compare(String prefix, Map<?, ?> a, Map<?, ?> b) {@b@    return compare(prefix, a, b, null, null);@b@  }@b@@b@  private static void log(StringBuilder buffer, String s)@b@  {@b@    debug(s);@b@    if (buffer != null)@b@      buffer.append(s + "\r\n");@b@  }@b@@b@  public static boolean compare(String prefix, Map<?, ?> a, Map<?, ?> b, List<?> ignore, StringBuilder buffer)@b@  {@b@    Object key;@b@    if ((a == null) && (b == null)) {@b@      log(buffer, prefix + " both maps null");@b@      return true;@b@    }@b@    if (a == null) {@b@      log(buffer, prefix + " map a: null, map b: map");@b@      return false;@b@    }@b@    if (b == null) {@b@      log(buffer, prefix + " map a: map, map b: null");@b@      return false;@b@    }@b@@b@    List keys_a = new ArrayList(a.keySet());@b@    List keys_b = new ArrayList(b.keySet());@b@@b@    if (ignore != null) {@b@      keys_a.removeAll(ignore);@b@      keys_b.removeAll(ignore);@b@    }@b@@b@    boolean result = true;@b@@b@    for (int i = 0; i < keys_a.size(); ++i) {@b@      key = keys_a.get(i);@b@      if (!(keys_b.contains(key))) {@b@        log(buffer, prefix + "b is missing key '" + key + "' from a");@b@        result = false;@b@      } else {@b@        keys_b.remove(key);@b@        Object value_a = a.get(key);@b@        Object value_b = b.get(key);@b@        if (!(value_a.equals(value_b))) {@b@          log(buffer, prefix + "key(" + key + ") value a: " + value_a + ") !=  b: " + value_b + ")");@b@@b@          result = false;@b@        }@b@      }@b@    }@b@    for (i = 0; i < keys_b.size(); ++i) {@b@      key = keys_b.get(i);@b@@b@      log(buffer, prefix + "a is missing key '" + key + "' from b");@b@      result = false;@b@    }@b@@b@    if (result) {@b@      log(buffer, prefix + "a is the same as  b");@b@    }@b@@b@    return result;@b@  }@b@@b@  private static String byteQuadToString(int bytequad) {@b@    byte b1 = (byte)(bytequad >> 24 & 0xFF);@b@    byte b2 = (byte)(bytequad >> 16 & 0xFF);@b@    byte b3 = (byte)(bytequad >> 8 & 0xFF);@b@    byte b4 = (byte)(bytequad >> 0 & 0xFF);@b@@b@    char c1 = (char)b1;@b@    char c2 = (char)b2;@b@    char c3 = (char)b3;@b@    char c4 = (char)b4;@b@@b@    StringBuilder fStringBuffer = new StringBuilder();@b@    fStringBuffer.append(new String(new char[] { c1, c2, c3, c4 }));@b@    fStringBuffer.append(" bytequad: " + bytequad);@b@    fStringBuffer.append(" b1: " + b1);@b@    fStringBuffer.append(" b2: " + b2);@b@    fStringBuffer.append(" b3: " + b3);@b@    fStringBuffer.append(" b4: " + b4);@b@@b@    return fStringBuffer.toString();@b@  }@b@@b@  public static String getDebug(String message, ICC_Profile value)@b@  {@b@    StringBuilder result = new StringBuilder();@b@@b@    result.append(getDebug(new StringBuilder().append("ICC_Profile ").append(message).append(": ").append((value == null) ? "null" : value.toString()).toString()) + "\r\n");@b@@b@    if (value != null) {@b@      result.append(getDebug(new StringBuilder().append("\t getProfileClass: ").append(byteQuadToString(value.getProfileClass())).toString()) + "\r\n");@b@@b@      result.append(getDebug(new StringBuilder().append("\t getPCSType: ").append(byteQuadToString(value.getPCSType())).toString()) + "\r\n");@b@@b@      result.append(getDebug(new StringBuilder().append("\t getColorSpaceType() : ").append(byteQuadToString(value.getColorSpaceType())).toString()) + "\r\n");@b@    }@b@@b@    return result.toString();@b@  }@b@@b@  public static String getDebug(String message, boolean value)@b@  {@b@    return getDebug(message + " " + ((value) ? "true" : "false"));@b@  }@b@@b@  public static String getDebug(String message, File file) {@b@    return getDebug(message + ": " + ((file == null) ? "null" : file.getPath()));@b@  }@b@@b@  public static String getDebug(String message, Date value)@b@  {@b@    DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");@b@    return getDebug(message, (value == null) ? "null" : df.format(value));@b@  }@b@@b@  public static String getDebug(String message, Calendar value) {@b@    DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");@b@    return getDebug(message, (value == null) ? "null" : df.format(value.getTime()));@b@  }@b@@b@  public static void debug(String message, Object value)@b@  {@b@    if (value == null)@b@      debug(message, "null");@b@    else if (value instanceof char[])@b@      debug(message, (char[])(char[])value);@b@    else if (value instanceof byte[])@b@      debug(message, (byte[])(byte[])value);@b@    else if (value instanceof int[])@b@      debug(message, (int[])(int[])value);@b@    else if (value instanceof String)@b@      debug(message, (String)value);@b@    else if (value instanceof List)@b@      debug(message, (List)value);@b@    else if (value instanceof Map) {@b@      debug(message, (Map)value);@b@    }@b@    else if (value instanceof ICC_Profile)@b@      debug(message, (ICC_Profile)value);@b@    else if (value instanceof File)@b@      debug(message, (File)value);@b@    else if (value instanceof Date)@b@      debug(message, (Date)value);@b@    else if (value instanceof Calendar)@b@      debug(message, (Calendar)value);@b@    else@b@      debug(message, value.toString());@b@  }@b@@b@  public static void debug(String message, Object[] value)@b@  {@b@    if (value == null) {@b@      debug(message, "null");@b@    } else {@b@      debug(message, value.length);@b@      int max = 10;@b@      for (int i = 0; (i < value.length) && (i < 10); ++i)@b@        debug("\t" + i, value[i]);@b@@b@      if (value.length > 10)@b@        debug("\t...");@b@    }@b@@b@    debug();@b@  }@b@@b@  public static String getDebug(String message, Object value) {@b@    if (value == null)@b@      return getDebug(message, "null");@b@    if (value instanceof Calendar)@b@      return getDebug(message, (Calendar)value);@b@    if (value instanceof Date)@b@      return getDebug(message, (Date)value);@b@    if (value instanceof File)@b@      return getDebug(message, (File)value);@b@    if (value instanceof ICC_Profile)@b@      return getDebug(message, (ICC_Profile)value);@b@    if (value instanceof Map)@b@      return getDebug(message, (Map)value);@b@    if (value instanceof Map) {@b@      return getDebug(message, (Map)value);@b@    }@b@@b@    if (value instanceof String)@b@      return getDebug(message, (String)value);@b@    if (value instanceof byte[])@b@      return getDebug(message, (byte[])(byte[])value);@b@    if (value instanceof char[])@b@      return getDebug(message, (char[])(char[])value);@b@    if (value instanceof int[])@b@      return getDebug(message, (int[])(int[])value);@b@    if (value instanceof List)@b@      return getDebug(message, (List)value);@b@@b@    return getDebug(message, value.toString());@b@  }@b@@b@  public static String getType(Object value)@b@  {@b@    if (value == null)@b@      return "null";@b@    if (value instanceof Object[])@b@      return "[Object[]: " + ((Object[])(Object[])value).length + "]";@b@    if (value instanceof char[])@b@      return "[char[]: " + ((char[])(char[])value).length + "]";@b@    if (value instanceof byte[])@b@      return "[byte[]: " + ((byte[])(byte[])value).length + "]";@b@    if (value instanceof short[])@b@      return "[short[]: " + ((short[])(short[])value).length + "]";@b@    if (value instanceof int[])@b@      return "[int[]: " + ((int[])(int[])value).length + "]";@b@    if (value instanceof long[])@b@      return "[long[]: " + ((long[])(long[])value).length + "]";@b@    if (value instanceof float[])@b@      return "[float[]: " + ((float[])(float[])value).length + "]";@b@    if (value instanceof double[])@b@      return "[double[]: " + ((double[])(double[])value).length + "]";@b@    if (value instanceof boolean[])@b@      return "[boolean[]: " + ((boolean[])(boolean[])value).length + "]";@b@@b@    return value.getClass().getName();@b@  }@b@@b@  public static boolean isArray(Object value)@b@  {@b@    if (value == null)@b@      return false;@b@    if (value instanceof Object[])@b@      return true;@b@    if (value instanceof char[])@b@      return true;@b@    if (value instanceof byte[])@b@      return true;@b@    if (value instanceof short[])@b@      return true;@b@    if (value instanceof int[])@b@      return true;@b@    if (value instanceof long[])@b@      return true;@b@    if (value instanceof float[])@b@      return true;@b@    if (value instanceof double[])@b@      return true;@b@@b@    return (value instanceof boolean[]);@b@  }@b@@b@  public static String getDebug(String message, Object[] value)@b@  {@b@    StringBuilder result = new StringBuilder();@b@@b@    if (value == null) {@b@      result.append(getDebug(message, "null") + "\r\n");@b@    } else {@b@      result.append(getDebug(message, value.length));@b@      int max = 10;@b@      for (int i = 0; (i < value.length) && (i < 10); ++i)@b@        result.append(getDebug(new StringBuilder().append("\t").append(i).toString(), value[i]) + "\r\n");@b@@b@      if (value.length > 10)@b@        result.append(getDebug("\t...") + "\r\n");@b@    }@b@@b@    result.append("\r\n");@b@@b@    return result.toString();@b@  }@b@@b@  public static String getDebug(Class<?> fClass, Throwable e) {@b@    return getDebug((fClass == null) ? "[Unknown]" : fClass.getName(), e);@b@  }@b@@b@  public static void debug(Class<?> fClass, Throwable e) {@b@    debug(fClass.getName(), e);@b@  }@b@@b@  public static void debug(String message, boolean value) {@b@    debug(message + " " + ((value) ? "true" : "false"));@b@  }@b@@b@  public static void debug(String message, byte[] v) {@b@    debug(getDebug(message, v));@b@  }@b@@b@  public static void debug(String message, char[] v) {@b@    debug(getDebug(message, v));@b@  }@b@@b@  public static void debug(String message, Calendar value) {@b@    DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");@b@    debug(message, (value == null) ? "null" : df.format(value.getTime()));@b@  }@b@@b@  public static void debug(String message, Date value) {@b@    DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");@b@    debug(message, (value == null) ? "null" : df.format(value));@b@  }@b@@b@  public static void debug(String message, double value) {@b@    debug(message + ": " + value);@b@  }@b@@b@  public static void debug(String message, File file) {@b@    debug(message + ": " + ((file == null) ? "null" : file.getPath()));@b@  }@b@@b@  public static void debug(String message, ICC_Profile value)@b@  {@b@    debug("ICC_Profile " + message + ": " + ((value == null) ? "null" : value.toString()));@b@@b@    if (value != null) {@b@      debug("\t getProfileClass: " + byteQuadToString(value.getProfileClass()));@b@@b@      debug("\t getPCSType: " + byteQuadToString(value.getPCSType()));@b@      debug("\t getColorSpaceType() : " + byteQuadToString(value.getColorSpaceType()));@b@    }@b@  }@b@@b@  public static void debug(String message, int value)@b@  {@b@    debug(message + ": " + value);@b@  }@b@@b@  public static void debug(String message, int[] v) {@b@    debug(getDebug(message, v));@b@  }@b@@b@  public static void debug(String message, byte[] v, int max) {@b@    debug(getDebug(message, v, max));@b@  }@b@@b@  public static void debug(String message, List<?> v) {@b@    String suffix = " [" + (counter++) + "]";@b@@b@    debug(message + " (" + v.size() + ")" + suffix);@b@    for (int i = 0; i < v.size(); ++i)@b@      debug("\t" + v.get(i).toString() + suffix);@b@@b@    debug();@b@  }@b@@b@  public static void debug(String message, long value) {@b@    debug(message + " " + Long.toString(value));@b@  }@b@@b@  public static void debug(String prefix, Point p) {@b@    System.out.println(prefix + ": " + ((p == null) ? "null" : new StringBuilder().append(p.x).append(", ").append(p.y).toString()));@b@  }@b@@b@  public static void debug(String prefix, Rectangle r)@b@  {@b@    debug(getDebug(prefix, r));@b@  }@b@@b@  public static void debug(String message, String value) {@b@    debug(message + " " + value);@b@  }@b@@b@  public static void debug(String message, Throwable e) {@b@    debug(getDebug(message, e));@b@  }@b@@b@  public static void debug(Throwable e) {@b@    debug(getDebug(e));@b@  }@b@@b@  public static void debug(Throwable e, int value) {@b@    debug(getDebug(e, value));@b@  }@b@@b@  public static void dumpStack() {@b@    debug(getStackTrace(new Exception("Stack trace"), -1, 1));@b@  }@b@@b@  public static void dumpStack(int limit) {@b@    debug(getStackTrace(new Exception("Stack trace"), limit, 1));@b@  }@b@@b@  public static String getDebug(String message, Throwable e) {@b@    return message + "\r\n" + getDebug(e);@b@  }@b@@b@  public static String getDebug(Throwable e) {@b@    return getDebug(e, -1);@b@  }@b@@b@  public static String getDebug(Throwable e, int max) {@b@    StringBuilder result = new StringBuilder();@b@@b@    SimpleDateFormat timestamp = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss:SSS");@b@@b@    String datetime = timestamp.format(new Date()).toLowerCase();@b@@b@    result.append("\r\n");@b@    result.append("Throwable: " + ((e == null) ? "" : new StringBuilder().append("(").append(e.getClass().getName()).append(")").toString()) + ":" + datetime + "\r\n");@b@@b@    result.append("Throwable: " + ((e == null) ? "null" : e.getLocalizedMessage()) + "\r\n");@b@@b@    result.append("\r\n");@b@@b@    result.append(getStackTrace(e, max));@b@@b@    result.append("Caught here:\r\n");@b@    result.append(getStackTrace(new Exception(), max, 1));@b@@b@    result.append("\r\n");@b@    return result.toString();@b@  }@b@@b@  public static String getStackTrace(Throwable e) {@b@    return getStackTrace(e, -1);@b@  }@b@@b@  public static String getStackTrace(Throwable e, int limit) {@b@    return getStackTrace(e, limit, 0);@b@  }@b@@b@  public static String getStackTrace(Throwable e, int limit, int skip) {@b@    StringBuilder result = new StringBuilder();@b@@b@    if (e != null) {@b@      StackTraceElement[] stes = e.getStackTrace();@b@      if (stes != null) {@b@        for (int i = skip; (i < stes.length) && (((limit < 0) || (i < limit))); ++i) {@b@          StackTraceElement ste = stes[i];@b@@b@          result.append("\tat " + ste.getClassName() + "." + ste.getMethodName() + "(" + ste.getFileName() + ":" + ste.getLineNumber() + ")" + "\r\n");@b@        }@b@@b@        if ((limit >= 0) && (stes.length > limit)) {@b@          result.append("\t...\r\n");@b@        }@b@@b@      }@b@@b@      result.append("\r\n");@b@    }@b@@b@    return result.toString();@b@  }@b@@b@  public static void debugByteQuad(String message, int i) {@b@    int alpha = i >> 24 & 0xFF;@b@    int red = i >> 16 & 0xFF;@b@    int green = i >> 8 & 0xFF;@b@    int blue = i >> 0 & 0xFF;@b@@b@    System.out.println(message + ": " + "alpha: " + alpha + ", " + "red: " + red + ", " + "green: " + green + ", " + "blue: " + blue);@b@  }@b@@b@  public static void debugIPQuad(String message, int i)@b@  {@b@    int b1 = i >> 24 & 0xFF;@b@    int b2 = i >> 16 & 0xFF;@b@    int b3 = i >> 8 & 0xFF;@b@    int b4 = i >> 0 & 0xFF;@b@@b@    System.out.println(message + ": " + "b1: " + b1 + ", " + "b2: " + b2 + ", " + "b3: " + b3 + ", " + "b4: " + b4);@b@  }@b@@b@  public static void debugIPQuad(String message, byte[] bytes)@b@  {@b@    int i;@b@    System.out.print(message + ": ");@b@    if (bytes == null)@b@      System.out.print("null");@b@    else@b@      for (i = 0; i < bytes.length; ++i) {@b@        if (i > 0)@b@          System.out.print(".");@b@@b@        System.out.print(0xFF & bytes[i]);@b@      }@b@@b@    System.out.println();@b@  }@b@@b@  public static String getDebug(String prefix, Dimension r) {@b@    String s_ar1 = "null";@b@    String s_ar2 = "null";@b@@b@    if (r != null) {@b@      double aspect_ratio = r.width / r.height;@b@      double aspect_ratio2 = 1.0D / aspect_ratio;@b@@b@      s_ar1 = "" + aspect_ratio;@b@      s_ar2 = "" + aspect_ratio2;@b@@b@      if (s_ar1.length() > 7)@b@        s_ar1 = s_ar1.substring(0, 7);@b@@b@      if (s_ar2.length() > 7)@b@        s_ar2 = s_ar2.substring(0, 7);@b@@b@    }@b@@b@    return prefix + ": " + ((r == null) ? "null" : new StringBuilder().append(r.width).append("x").append(r.height).toString()) + " aspect_ratio: " + s_ar1 + " (" + s_ar2 + ")";@b@  }@b@@b@  public static void debug(String prefix, Dimension r)@b@  {@b@    debug(getDebug(prefix, r));@b@  }@b@@b@  public static String getDebug(String prefix, Rectangle r) {@b@    String s_ar1 = "null";@b@    String s_ar2 = "null";@b@@b@    if (r != null) {@b@      double aspect_ratio = r.width / r.height;@b@      double aspect_ratio2 = 1.0D / aspect_ratio;@b@@b@      s_ar1 = "" + aspect_ratio;@b@      s_ar2 = "" + aspect_ratio2;@b@@b@      if (s_ar1.length() > 7)@b@        s_ar1 = s_ar1.substring(0, 7);@b@@b@      if (s_ar2.length() > 7)@b@        s_ar2 = s_ar2.substring(0, 7);@b@@b@    }@b@@b@    return prefix + ": " + ((r == null) ? "null" : new StringBuilder().append(r.x).append("x").append(r.y).append(",").append(r.width).append("x").append(r.height).toString()) + " aspect_ratio: " + s_ar1 + " (" + s_ar2 + ")";@b@  }@b@@b@  public static String getDebug(String prefix, Point p)@b@  {@b@    return prefix + ": " + ((p == null) ? "null" : new StringBuilder().append(p.x).append(", ").append(p.y).toString());@b@  }@b@@b@  public static void dump(String prefix, Object value) {@b@    if (value == null) {@b@      debug(prefix, "null"); } else {@b@      Object[] array;@b@      int i;@b@      if (value instanceof Object[]) {@b@        array = (Object[])(Object[])value;@b@        debug(prefix, array);@b@        for (i = 0; i < array.length; ++i)@b@          dump(prefix + "\t" + i + ": ", array[i]);@b@      } else {@b@        int[] array;@b@        if (value instanceof int[]) {@b@          array = (int[])(int[])value;@b@          debug(prefix, array);@b@          for (i = 0; i < array.length; ++i)@b@            debug(prefix + "\t" + i + ": ", array[i]);@b@        }@b@        else if (value instanceof char[]) {@b@          char[] array = (char[])(char[])value;@b@          debug(prefix, "[" + new String(array) + "]"); } else {@b@          long[] array;@b@          if (value instanceof long[]) {@b@            array = (long[])(long[])value;@b@            debug(prefix, array);@b@            for (i = 0; i < array.length; ++i)@b@              debug(prefix + "\t" + i + ": ", array[i]);@b@          } else {@b@            boolean[] array;@b@            if (value instanceof boolean[]) {@b@              array = (boolean[])(boolean[])value;@b@              debug(prefix, array);@b@              for (i = 0; i < array.length; ++i)@b@                debug(prefix + "\t" + i + ": ", array[i]);@b@            } else {@b@              byte[] array;@b@              if (value instanceof byte[]) {@b@                array = (byte[])(byte[])value;@b@                debug(prefix, array);@b@                for (i = 0; i < array.length; ++i)@b@                  debug(prefix + "\t" + i + ": ", array[i]);@b@              } else {@b@                float[] array;@b@                if (value instanceof float[]) {@b@                  array = (float[])(float[])value;@b@                  debug(prefix, array);@b@                  for (i = 0; i < array.length; ++i)@b@                    debug(prefix + "\t" + i + ": ", array[i]);@b@                } else {@b@                  double[] array;@b@                  if (value instanceof double[]) {@b@                    array = (double[])(double[])value;@b@                    debug(prefix, array);@b@                    for (i = 0; i < array.length; ++i)@b@                      debug(prefix + "\t" + i + ": ", array[i]);@b@                  } else {@b@                    List list;@b@                    if (value instanceof List) {@b@                      list = (List)value;@b@                      debug(prefix, "list");@b@                      for (i = 0; i < list.size(); ++i)@b@                        dump(prefix + "\t" + "list: " + i + ": ", list.get(i));@b@                    }@b@                    else if (value instanceof Map) {@b@                      Map map = (Map)value;@b@                      debug(prefix, "map");@b@                      for (Map.Entry entry : map.entrySet())@b@                        dump(prefix + "\t" + "map: " + entry.getKey() + " -> ", entry.getValue());@b@@b@                    }@b@                    else@b@                    {@b@                      debug(prefix, value.toString());@b@                      debug(prefix + "\t", value.getClass().getName());@b@                    }@b@                  }@b@                }@b@              }@b@            }@b@          }@b@        }@b@      }@b@    }@b@  }@b@@b@  public static void purgeMemory()@b@  {@b@  }@b@}