fabric.common
Class Util

java.lang.Object
  extended by fabric.common.Util

public final class Util
extends java.lang.Object


Constructor Summary
Util()
           
 
Method Summary
static
<T> java.lang.Iterable<T>
chain(java.lang.Iterable<T>... iters)
           Returns an iterable that iterates over the elements of the iterables passed in.
static java.lang.Object deserialize(byte[] bytes)
          Turns an array of bytes into an object using Java serialization.
static byte[] hash(java.lang.Class<?> c)
          Generates a cryptographically secure hash of the given class.
static byte[] hashClass(Codebase codebase, java.lang.String className)
           
static java.net.URL locateClass(Codebase codebase, java.lang.String className)
           
static byte[] serialize(java.lang.Object obj)
          Turns an object into an array of bytes using Java serialization.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

hash

public static byte[] hash(java.lang.Class<?> c)
                   throws java.io.IOException
Generates a cryptographically secure hash of the given class.

Throws:
java.io.IOException

hashClass

public static byte[] hashClass(Codebase codebase,
                               java.lang.String className)
                        throws java.io.IOException,
                               java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException

locateClass

public static java.net.URL locateClass(Codebase codebase,
                                       java.lang.String className)
                                throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

chain

public static <T> java.lang.Iterable<T> chain(java.lang.Iterable<T>... iters)

Returns an iterable that iterates over the elements of the iterables passed in. The common use is:

 for (T o : Utils.chain(a, b, c))
  o.f()
 
which will call f() on each element of a, then each element of b, then each element of c.

This is intended to be more efficient and easier than creating a new collection containing the contents.

Type Parameters:
T - the types of the elements of the iterables
Parameters:
iters - the iterables to chain
Returns:
an object that can be used to traverse iters in order

serialize

public static byte[] serialize(java.lang.Object obj)
                        throws java.io.IOException
Turns an object into an array of bytes using Java serialization.

Throws:
java.io.IOException

deserialize

public static java.lang.Object deserialize(byte[] bytes)
                                    throws java.io.IOException,
                                           java.lang.ClassNotFoundException
Turns an array of bytes into an object using Java serialization.

Throws:
java.io.IOException
java.lang.ClassNotFoundException