Class UtilObject

java.lang.Object
org.apache.ofbiz.base.util.UtilObject

public final class UtilObject extends Object
UtilObject
  • Method Details

    • getBytes

      public static byte[] getBytes(Object obj)
      Serialize an object to a byte array
    • getByteCount

      public static long getByteCount(Object obj) throws 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:
      IOException
    • getObject

      public static 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 Object getObjectException(byte[] bytes) throws ClassCastException, ClassNotFoundException, IOException
      Deserializes a byte array back to an object.
      Parameters:
      bytes - the array of bytes
      Returns:
      the deserialized object.
      Throws:
      ClassNotFoundException - when the class can not be deserialized.
      IOException - when a general Input/Output error happen.
      ClassCastException
    • doHashCode

      public static int doHashCode(Object o1)
    • getObjectFromFactory

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