com.p6spy.engine.common
Class P6Util

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

public class P6Util
extends Object


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

parseLong

public static long parseLong(String l,
                             long defaultValue)

isTrue

public static boolean isTrue(String s,
                             boolean defaultValue)

atoi

public static int atoi(Object s)

loadProperties

public static Properties loadProperties(String file)

removeDots

protected static void removeDots(Properties props)

getCheckedPath

protected static String getCheckedPath()

getClassPathAsString

protected static String getClassPathAsString(ClassLoader classLoader)

loadProperties

public static ArrayList loadProperties(String file,
                                       String prefix)

reverseArrayList

public static ArrayList reverseArrayList(ArrayList arraylist)

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


classLoadPropertyFile

public static File classLoadPropertyFile(URL purl)

timeNow

public static Date timeNow()

getPrintStream

public static PrintStream getPrintStream(String file,
                                         boolean append)
                                  throws IOException
Throws:
IOException

timeTaken

public static String timeTaken(Date start,
                               String msg)

elapsed

public static long elapsed(Date start)

forName

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

dynamicSet

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


set

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

dynamicGet

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


get

public static Object get(Class klass,
                         String method)
                  throws IntrospectionException,
                         IllegalAccessException,
                         NoSuchMethodException,
                         InvocationTargetException
Throws:
IntrospectionException
IllegalAccessException
NoSuchMethodException
InvocationTargetException

dynamicGetOptions

public static Collection dynamicGetOptions(Class klass)

findAllMethods

public static ArrayList findAllMethods(Class klass)
                                throws IntrospectionException
Throws:
IntrospectionException

getPath

public static String getPath(URL theURL)