/* Dbg.java * * Copyright (c) 2001, Ted Nelson and Tuomas Lukka * * This file is part of Fenfire. * * Fenfire is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Fenfire is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General * Public License for more details. * * You should have received a copy of the GNU Lesser General * Public License along with Fenfire; if not, write to the Free * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * * */ /* * Written by Tuomas Lukka */ package org.fenfire.util; import java.util.*; import java.lang.reflect.*; /** Turning on debugging according to gzz conventions. * The GZigZag convention for debuggable classes is that every class must have * a public static member dbg, e.g. as in *
* class Foo { * static public boolean dbg = false; * ... * private final void p(String s) { if(dbg) System.out.println(s); } * ... * ... * void method() { * p("Here"); * ... * if(dbg) * object-<printDebugInfo(); * ... * } * } ** This member can be turned on from outside. *
* Caveats *
* p("AGG "+object+" "+object2+" "+number); ** so that the string is not formed if dbg is false. * This is very unfortunate. * If code like above is inside tight loops, a profiler will * show that your program is spending a good amount of its * time in StringBuffer code, making strings that will never be * used for anything. * Therefore, the above statements, especially in tight loops, * should be changed to *
* if(dbg) p("AGG "+object+" "+object2+" "+number); **