com.p6spy.engine.common
Class P6Util

java.lang.Object
  extended bycom.p6spy.engine.common.P6Util

public class P6Util
extends java.lang.Object


Constructor Summary
P6Util()
           
 
Method Summary
static int atoi(java.lang.Object s)
           
static java.io.File classLoadPropertyFile(java.net.URL purl)
           
static java.lang.String classPathFile(java.lang.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 java.lang.String dynamicGet(java.lang.Class klass, java.lang.String property)
          A utility for dynamically getting the value of a given static class method
static java.util.Collection dynamicGetOptions(java.lang.Class klass)
           
static void dynamicSet(java.lang.Class klass, java.lang.String property, java.lang.String value)
          A utility for dynamically setting the value of a given static class method
static long elapsed(java.util.Date start)
           
static java.util.ArrayList findAllMethods(java.lang.Class klass)
           
static java.lang.Class forName(java.lang.String name)
          A utiltity for using the current class loader (rather than the system class loader) when instantiating a new class.
static java.lang.Object get(java.lang.Class klass, java.lang.String method)
           
protected static java.lang.String getCheckedPath()
           
protected static java.lang.String getClassPathAsString(java.lang.ClassLoader classLoader)
           
static java.lang.String getPath(java.net.URL theURL)
           
static java.io.PrintStream getPrintStream(java.lang.String file, boolean append)
           
static boolean isTrue(java.lang.String s, boolean defaultValue)
           
static java.util.Properties loadProperties(java.lang.String file)
           
static java.util.ArrayList loadProperties(java.lang.String file, java.lang.String prefix)
           
static int parseInt(java.lang.String i, int defaultValue)
           
static long parseLong(java.lang.String l, long defaultValue)
           
protected static void removeDots(java.util.Properties props)
           
static java.util.ArrayList reverseArrayList(java.util.ArrayList arraylist)
           
static void set(java.lang.Class klass, java.lang.String method, java.lang.Object[] args)
           
static java.util.Date timeNow()
           
static java.lang.String timeTaken(java.util.Date start, java.lang.String msg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

P6Util

public P6Util()
Method Detail

parseInt

public static int parseInt(java.lang.String i,
                           int defaultValue)

parseLong

public static long parseLong(java.lang.String l,
                             long defaultValue)

isTrue

public static boolean isTrue(java.lang.String s,
                             boolean defaultValue)

atoi

public static int atoi(java.lang.Object s)

loadProperties

public static java.util.Properties loadProperties(java.lang.String file)

removeDots

protected static void removeDots(java.util.Properties props)

getCheckedPath

protected static java.lang.String getCheckedPath()

getClassPathAsString

protected static java.lang.String getClassPathAsString(java.lang.ClassLoader classLoader)

loadProperties

public static java.util.ArrayList loadProperties(java.lang.String file,
                                                 java.lang.String prefix)

reverseArrayList

public static java.util.ArrayList reverseArrayList(java.util.ArrayList arraylist)

classPathFile

public static java.lang.String classPathFile(java.lang.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


classLoadPropertyFile

public static java.io.File classLoadPropertyFile(java.net.URL purl)

timeNow

public static java.util.Date timeNow()

getPrintStream

public static java.io.PrintStream getPrintStream(java.lang.String file,
                                                 boolean append)
                                          throws java.io.IOException
Throws:
java.io.IOException

timeTaken

public static java.lang.String timeTaken(java.util.Date start,
                                         java.lang.String msg)

elapsed

public static long elapsed(java.util.Date start)

forName

public static java.lang.Class forName(java.lang.String name)
                               throws java.lang.ClassNotFoundException
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
Throws:
java.lang.ClassNotFoundException

dynamicSet

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


set

public static void set(java.lang.Class klass,
                       java.lang.String method,
                       java.lang.Object[] args)
                throws java.beans.IntrospectionException,
                       java.lang.IllegalAccessException,
                       java.lang.NoSuchMethodException,
                       java.lang.reflect.InvocationTargetException
Throws:
java.beans.IntrospectionException
java.lang.IllegalAccessException
java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException

dynamicGet

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


get

public static java.lang.Object get(java.lang.Class klass,
                                   java.lang.String method)
                            throws java.beans.IntrospectionException,
                                   java.lang.IllegalAccessException,
                                   java.lang.NoSuchMethodException,
                                   java.lang.reflect.InvocationTargetException
Throws:
java.beans.IntrospectionException
java.lang.IllegalAccessException
java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException

dynamicGetOptions

public static java.util.Collection dynamicGetOptions(java.lang.Class klass)

findAllMethods

public static java.util.ArrayList findAllMethods(java.lang.Class klass)
                                          throws java.beans.IntrospectionException
Throws:
java.beans.IntrospectionException

getPath

public static java.lang.String getPath(java.net.URL theURL)