org.ofbiz.base.util
Class UtilObject

java.lang.Object
  extended by org.ofbiz.base.util.UtilObject

public final class UtilObject
extends java.lang.Object

UtilObject


Field Summary
static java.lang.String module
           
 
Method Summary
static
<T> int
compareToHelper(java.lang.Comparable<T> o1, T o2)
           
static int doHashCode(java.lang.Object o1)
           
static boolean equalsHelper(java.lang.Object o1, java.lang.Object o2)
           
static long getByteCount(java.lang.Object obj)
          Returns the size of a serializable object.
static byte[] getBytes(java.io.InputStream is)
           
static byte[] getBytes(java.lang.Object obj)
          Serialize an object to a byte array
static java.lang.Object getObject(byte[] bytes)
          Deserialize a byte array back to an object; if there is an error, it is logged, and null is returned.
static java.lang.Object getObjectException(byte[] bytes)
          Deserialize a byte array back to an object
static
<A,R> R
getObjectFromFactory(java.lang.Class<? extends Factory<R,A>> factoryInterface, A obj)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

module

public static final java.lang.String module
Method Detail

getBytes

public static byte[] getBytes(java.io.InputStream is)

getBytes

public static byte[] getBytes(java.lang.Object obj)
Serialize an object to a byte array


getByteCount

public static long getByteCount(java.lang.Object obj)
                         throws java.io.IOException
Returns the size of a serializable object. Non-serializable objects will throw an IOException.

It is important to note that the returned value is length of the byte stream after the object has been serialized. The returned value does not represent the amount of memory the object uses. There is no accurate way to determine the size of an object in memory.

Parameters:
obj -
Returns:
the number of bytes in the serialized object
Throws:
java.io.IOException

getObject

public static java.lang.Object getObject(byte[] bytes)
Deserialize a byte array back to an object; if there is an error, it is logged, and null is returned.


getObjectException

public static java.lang.Object getObjectException(byte[] bytes)
                                           throws java.lang.ClassNotFoundException,
                                                  java.io.IOException
Deserialize a byte array back to an object

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

equalsHelper

public static boolean equalsHelper(java.lang.Object o1,
                                   java.lang.Object o2)

compareToHelper

public static <T> int compareToHelper(java.lang.Comparable<T> o1,
                                      T o2)

doHashCode

public static int doHashCode(java.lang.Object o1)

getObjectFromFactory

public static <A,R> R getObjectFromFactory(java.lang.Class<? extends Factory<R,A>> factoryInterface,
                                           A obj)
                              throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException