org.apache.wicket.util.lang
Class WicketObjects

java.lang.Object
  extended by org.apache.wicket.util.lang.WicketObjects

public class WicketObjects
extends Object


Nested Class Summary
static interface WicketObjects.IObjectSizeOfStrategy
          Interface that enables users to plugin the way object sizes are calculated with Wicket.
static class WicketObjects.SerializingObjectSizeOfStrategy
          WicketObjects.IObjectSizeOfStrategy that works by serializing the object to an instance of ByteCountingOutputStream, which records the number of bytes written to it.
 
Method Summary
static Object byteArrayToObject(byte[] data)
          De-serializes an object from a byte array.
static Object cloneModel(Object object)
          Makes a deep clone of an object by serializing and deserializing it.
static Object cloneObject(Object object)
          Makes a deep clone of an object by serializing and deserializing it.
static Object newInstance(String className)
          Creates a new instance using the current application's class resolver.
static byte[] objectToByteArray(Object object)
          Serializes an object into a byte array.
static byte[] objectToByteArray(Object object, String applicationName)
          Serializes an object into a byte array.
static
<T> Class<T>
resolveClass(String className)
           
static void setObjectSizeOfStrategy(WicketObjects.IObjectSizeOfStrategy objectSizeOfStrategy)
          Sets the strategy for determining the sizes of objects.
static void setObjectStreamFactory(IObjectStreamFactory objectStreamFactory)
          Configure this utility class to use the provided IObjectStreamFactory instance.
static long sizeof(Object object)
          Computes the size of an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

resolveClass

public static <T> Class<T> resolveClass(String className)
Type Parameters:
T - class type
Parameters:
className - Class to resolve
Returns:
Resolved class

byteArrayToObject

public static Object byteArrayToObject(byte[] data)
De-serializes an object from a byte array.

Parameters:
data - The serialized object
Returns:
The object

cloneModel

public static Object cloneModel(Object object)
Makes a deep clone of an object by serializing and deserializing it. The object must be fully serializable to be cloned. This method will not clone wicket Components, it will just reuse those instances so that the complete component tree is not copied over only the model data.

Parameters:
object - The object to clone
Returns:
A deep copy of the object

cloneObject

public static Object cloneObject(Object object)
Makes a deep clone of an object by serializing and deserializing it. The object must be fully serializable to be cloned. No extra debug info is gathered.

Parameters:
object - The object to clone
Returns:
A deep copy of the object
See Also:
cloneModel(Object)

newInstance

public static Object newInstance(String className)
Creates a new instance using the current application's class resolver. Returns null if className is null.

Parameters:
className - The full class name
Returns:
The new object instance

objectToByteArray

public static byte[] objectToByteArray(Object object,
                                       String applicationName)
Serializes an object into a byte array.

Parameters:
object - The object
applicationName - The name of application - required when serialization and deserialisation happen outside thread in which application thread local is set
Returns:
The serialized object

objectToByteArray

public static byte[] objectToByteArray(Object object)
Serializes an object into a byte array.

Parameters:
object - The object
Returns:
The serialized object

setObjectSizeOfStrategy

public static void setObjectSizeOfStrategy(WicketObjects.IObjectSizeOfStrategy objectSizeOfStrategy)
Sets the strategy for determining the sizes of objects.

Parameters:
objectSizeOfStrategy - the strategy. Pass null to reset to the default.

setObjectStreamFactory

public static void setObjectStreamFactory(IObjectStreamFactory objectStreamFactory)
Configure this utility class to use the provided IObjectStreamFactory instance.

Parameters:
objectStreamFactory - The factory instance to use. If you pass in null, the default will be set (again). Pass null to reset to the default.

sizeof

public static long sizeof(Object object)
Computes the size of an object. Note that this is an estimation, never an absolute accurate size.

Parameters:
object - Object to compute size of
Returns:
The size of the object in bytes


Copyright © 2004-2010 Apache Software Foundation. All Rights Reserved.