org.infinispan.util
Class Util

java.lang.Object
  extended by org.infinispan.util.Util

public final class Util
extends Object

General utility methods used throughout the JBC code base.

Since:
4.0
Author:
Brian Stansberry, Galder ZamarreƱo

Nested Class Summary
static class Util.MapModifications
          Static inner class that holds 3 maps - for data added, removed and modified.
 
Method Summary
static void closeInput(ObjectInput i)
           
static void closeStream(InputStream i)
           
static void flushAndCloseOutput(ObjectOutput o)
           
static void flushAndCloseStream(OutputStream o)
           
static String formatString(Object message, Object... params)
           
static
<T> T
getInstance(Class<T> clazz)
           
static Object getInstance(String classname)
           
static Class loadClass(String classname)
          Loads the specified class using this class's classloader, or, if it is null (i.e.
static InputStream loadResourceAsStream(String resource)
           
static String prettyPrintTime(long millis)
          Prints a time for display
static String prettyPrintTime(long time, TimeUnit unit)
           
static boolean safeEquals(Object a, Object b)
          Null-safe equality test.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadClass

public static Class loadClass(String classname)
                       throws ClassNotFoundException
Loads the specified class using this class's classloader, or, if it is null (i.e. this class was loaded by the bootstrap classloader), the system classloader.

If loadtime instrumentation via GenerateInstrumentedClassLoader is used, this class may be loaded by the bootstrap classloader.

Parameters:
classname - name of the class to load
Returns:
the class
Throws:
ClassNotFoundException

getInstance

public static <T> T getInstance(Class<T> clazz)
                     throws IllegalAccessException,
                            InstantiationException
Throws:
IllegalAccessException
InstantiationException

getInstance

public static Object getInstance(String classname)
                          throws ClassNotFoundException,
                                 IllegalAccessException,
                                 InstantiationException
Throws:
ClassNotFoundException
IllegalAccessException
InstantiationException

safeEquals

public static boolean safeEquals(Object a,
                                 Object b)
Null-safe equality test.

Parameters:
a - first object to compare
b - second object to compare
Returns:
true if the objects are equals or both null, false otherwise.

loadResourceAsStream

public static InputStream loadResourceAsStream(String resource)

prettyPrintTime

public static String prettyPrintTime(long time,
                                     TimeUnit unit)

prettyPrintTime

public static String prettyPrintTime(long millis)
Prints a time for display

Parameters:
millis - time in millis
Returns:
the time, represented as millis, seconds, minutes or hours as appropriate, with suffix

closeStream

public static void closeStream(InputStream i)

closeInput

public static void closeInput(ObjectInput i)

flushAndCloseStream

public static void flushAndCloseStream(OutputStream o)

flushAndCloseOutput

public static void flushAndCloseOutput(ObjectOutput o)

formatString

public static String formatString(Object message,
                                  Object... params)

Google Analytics

Copyright © 2010 JBoss, a division of Red Hat. All Rights Reserved.