com.p6spy.engine.common

Class P6Util

public class P6Util extends Object

Description: Utility classes $Author: cheechq $ $Revision: 1.15 $ $Date: 2003/06/03 19:20:20 $ $Id: P6Util.java,v 1.15 2003/06/03 19:20:20 cheechq Exp $ $Log: P6Util.java,v $ Revision 1.15 2003/06/03 19:20:20 cheechq removed unused imports Revision 1.14 2003/04/15 02:49:09 cheechq bug fix for jdk 1.2 support Revision 1.13 2003/04/15 02:10:54 cheechq jdk 1.2 support mod Revision 1.12 2003/02/28 07:28:10 jeffgoke added bug fix to enable jdk 1.2 support Revision 1.11 2003/02/12 15:32:14 jeffgoke Fixed bug where space in the realdriver name was causing the system to crash Revision 1.10 2003/01/29 05:38:42 jeffgoke added fix to not close reader if it is null Revision 1.9 2003/01/28 17:00:58 jeffgoke rewrote options to the ability for a module to have its own option set Revision 1.8 2003/01/23 23:43:51 jeffgoke try the thread and classloader system resources if we can't find the class loader Revision 1.7 2003/01/23 01:40:45 jeffgoke added code to try to use the classpath loader first, and if that fails, try our manual method Revision 1.6 2003/01/15 22:09:41 aarvesen Don't crap out if you can't find a context loader, press on Revision 1.5 2003/01/10 21:39:43 jeffgoke removed p6util.warn and moved warn handling to logging. this gives a consistent log file. Revision 1.4 2003/01/08 18:11:13 aarvesen Trap the no more element exception to avoid a stupid crashing bug. Revision 1.3 2003/01/03 21:14:54 aarvesen added the (unused) removeDots method added the (widely used) forName method to implement better class loading Revision 1.2 2002/10/06 18:21:37 jeffgoke no message Revision 1.1 2002/05/24 07:32:01 jeffgoke version 1 rewrite Revision 1.7 2002/05/18 06:39:52 jeffgoke Peter Laird added Outage detection. Added junit tests for outage detection. Fixed multi-driver tests. Revision 1.6 2002/05/16 04:58:40 jeffgoke Viktor Szathmary added multi-driver support. Rewrote P6SpyOptions to be easier to manage. Fixed several bugs. Revision 1.5 2002/05/05 00:43:00 jeffgoke Added Philip's reload code. Revision 1.4 2002/04/15 05:13:32 jeffgoke Simon Sadedin added timing support. Fixed bug where batch execute was not getting logged. Added result set timing. Updated the log format to include categories, and updated options to control the categories. Updated documentation. Revision 1.3 2002/04/10 06:49:26 jeffgoke added more debug information and a new property for setting the log's date format Revision 1.2 2002/04/07 20:43:59 jeffgoke fixed bug that caused null connection to return an empty connection instead of null. added an option allowing the user to truncate. added a release target to the build to create the release files. Revision 1.1.1.1 2002/04/07 04:52:26 jeffgoke no message Revision 1.4 2001-08-05 09:16:03-05 andy version on the website Revision 1.3 2001-08-02 07:52:43-05 andy <> Revision 1.2 2001-07-30 23:37:24-05 andy <> Revision 1.1 2001-07-30 23:03:32-05 andy <> Revision 1.0 2001-07-30 17:49:09-05 andy Initial revision
Method Summary
static intatoi(Object s)
static FileclassLoadPropertyFile(URL purl)
static StringclassPathFile(String file)
Here we attempt to find the file in the current dir and the classpath If we can't find it then we return null
static StringdynamicGet(Class klass, String property)
A utility for dynamically getting the value of a given static class method
static CollectiondynamicGetOptions(Class klass)
static voiddynamicSet(Class klass, String property, String value)
A utility for dynamically setting the value of a given static class method
static longelapsed(Date start)
static ArrayListfindAllMethods(Class klass)
static ClassforName(String name)
A utiltity for using the current class loader (rather than the system class loader) when instantiating a new class.
static Objectget(Class klass, String method)
protected static StringgetCheckedPath()
protected static StringgetClassPathAsString(ClassLoader classLoader)
static StringgetPath(URL theURL)
static PrintStreamgetPrintStream(String file, boolean append)
static booleanisTrue(String s, boolean defaultValue)
static PropertiesloadProperties(String file)
static ArrayListloadProperties(String file, String prefix)
static intparseInt(String i, int defaultValue)
static longparseLong(String l, long defaultValue)
protected static voidremoveDots(Properties props)
static ArrayListreverseArrayList(ArrayList arraylist)
static voidset(Class klass, String method, Object[] args)
static DatetimeNow()
static StringtimeTaken(Date start, String msg)

Method Detail

atoi

public static int atoi(Object s)

classLoadPropertyFile

public static File classLoadPropertyFile(URL purl)

classPathFile

public static String classPathFile(String file)
Here we attempt to find the file in the current dir and the classpath If we can't find it then we return null

dynamicGet

public static String dynamicGet(Class klass, String property)
A utility for dynamically getting the value of a given static class method

dynamicGetOptions

public static Collection dynamicGetOptions(Class klass)

dynamicSet

public static void dynamicSet(Class klass, String property, String value)
A utility for dynamically setting the value of a given static class method

elapsed

public static long elapsed(Date start)

findAllMethods

public static ArrayList findAllMethods(Class klass)

forName

public static Class forName(String name)
A utiltity for using the current class loader (rather than the system class loader) when instantiating a new class.

The idea is that the thread's current loader might have an obscure notion of what your class path is (e.g. an app server) that will not be captured properly by the system class loader.

taken from http://sourceforge.net/forum/message.php?msg_id=1720229

Parameters: name class name to load

Returns: the newly loaded class

get

public static Object get(Class klass, String method)

getCheckedPath

protected static String getCheckedPath()

getClassPathAsString

protected static String getClassPathAsString(ClassLoader classLoader)

getPath

public static String getPath(URL theURL)

getPrintStream

public static PrintStream getPrintStream(String file, boolean append)

isTrue

public static boolean isTrue(String s, boolean defaultValue)

loadProperties

public static Properties loadProperties(String file)

loadProperties

public static ArrayList loadProperties(String file, String prefix)

parseInt

public static int parseInt(String i, int defaultValue)

parseLong

public static long parseLong(String l, long defaultValue)

removeDots

protected static void removeDots(Properties props)

reverseArrayList

public static ArrayList reverseArrayList(ArrayList arraylist)

set

public static void set(Class klass, String method, Object[] args)

timeNow

public static Date timeNow()

timeTaken

public static String timeTaken(Date start, String msg)