|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openbp.common.util.CopyUtil
public final class CopyUtil
Various static utility methods for copying objects. All based on usage of the Clonable interface.
| Field Summary | |
|---|---|
static int |
CLONE_ALL
copyCollection(java.util.Collection, int)/copyMap(java.util.Map, int) copy mode: Copy keys and values. |
static int |
CLONE_KEYS
copyMap(java.util.Map, int) copy mode: Copy keys. |
static int |
CLONE_NONE
copyCollection(java.util.Collection, int)/copyMap(java.util.Map, int) copy mode: No copy, reference only. |
static int |
CLONE_VALUES
copyCollection(java.util.Collection, int)/copyMap(java.util.Map, int) copy mode: Copy values. |
| Method Summary | |
|---|---|
static java.util.Collection |
copyCollection(java.util.Collection source,
int copyMode)
Creates a copy of a collection object. |
static java.util.Map |
copyMap(java.util.Map source,
int copyMode)
Creates a copy of a map object. |
static java.lang.Object |
copyObject(java.lang.Object object,
int copyMode,
java.lang.ClassLoader classLoader)
Creates a copy of an arbitrary object if it supports the clone interface. |
static java.lang.Object |
createNew(java.lang.Object object)
Returns a new of the same type as the given object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int CLONE_NONE
copyCollection(java.util.Collection, int)/copyMap(java.util.Map, int) copy mode: No copy, reference only.
The new map will refer to the same objects as the original.
public static final int CLONE_KEYS
copyMap(java.util.Map, int) copy mode: Copy keys.
The new map will contain deep clones of the original.
public static final int CLONE_VALUES
copyCollection(java.util.Collection, int)/copyMap(java.util.Map, int) copy mode: Copy values.
The new map will contain deep clones of the original.
public static final int CLONE_ALL
copyCollection(java.util.Collection, int)/copyMap(java.util.Map, int) copy mode: Copy keys and values.
The new map will contain deep clones of the original.
| Method Detail |
|---|
public static java.lang.Object createNew(java.lang.Object object)
throws java.lang.CloneNotSupportedException
object - Object to create an empty clone for or null
java.lang.CloneNotSupportedException - On error
public static java.lang.Object copyObject(java.lang.Object object,
int copyMode,
java.lang.ClassLoader classLoader)
throws java.lang.CloneNotSupportedException
object - The object to copy or nullcopyMode - Determines if a deep copy, a first level copy or a shallow copy is to be
performed (Copyable.COPY_SHALLOW/Copyable.COPY_FIRST_LEVEL/Copyable.COPY_DEEP).Copyable interface.
If COPY_DEEP is specified, we will use the object's clone method (is is defined to use
deep copy mode). Otherwise, we try to construct a new object using the default constructor
and apply the Copyable.copyFrom(java.lang.Object, int) method on it.classLoader - Class loader if the serialize/deserialize approach (last fallback) will be used
java.lang.CloneNotSupportedException - If the object cannot be cloned
public static java.util.Collection copyCollection(java.util.Collection source,
int copyMode)
throws java.lang.CloneNotSupportedException
source - The collection to copy or nullcopyMode - Determines if a first level copy or a deep copy is to be
performed (CLONE_NONE/CLONE_VALUES/CLONE_ALL)
java.lang.CloneNotSupportedException - If either the collection object or one of its value cannot be cloned
public static java.util.Map copyMap(java.util.Map source,
int copyMode)
throws java.lang.CloneNotSupportedException
source - The map to copy or nullcopyMode - Determines if a first level copy or a deep copy is to be
performed (CLONE_NONE/CLONE_KEYS/CLONE_VALUES/CLONE_ALL)
java.lang.CloneNotSupportedException - If either the map object or one of its keys or value cannot be cloned
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||