com.sun.syndication.feed.impl

Class CloneableBean

public class CloneableBean extends Object implements Serializable, Cloneable

Provides deep Bean clonning support.

It works on all read/write properties, recursively. It support all primitive types, Strings, Collections, Cloneable objects and multi-dimensional arrays of any of them.

Author: Alejandro Abdelnur

Field Summary
static SetBASIC_TYPES
static MapCONSTRUCTOR_BASIC_TYPES
static Object[]NO_PARAMS
static Class[]NO_PARAMS_DEF
Set_ignoreProperties
Object_obj
Constructor Summary
protected CloneableBean()
Default constructor.
CloneableBean(Object obj)
Creates a CloneableBean to be used in a delegation pattern.
CloneableBean(Object obj, Set ignoreProperties)
Creates a CloneableBean to be used in a delegation pattern.
Method Summary
ObjectbeanClone()
Makes a deep bean clone of the object passed in the constructor.
Objectclone()
Makes a deep bean clone of the object.
ObjectcloneArray(Object array)
ObjectcloneCollection(Collection collection)
ObjectcloneMap(Map map)
ObjectdoClone(Object value)
booleanisBasicType(Class vClass)

Field Detail

BASIC_TYPES

private static final Set BASIC_TYPES

CONSTRUCTOR_BASIC_TYPES

private static final Map CONSTRUCTOR_BASIC_TYPES

NO_PARAMS

private static final Object[] NO_PARAMS

NO_PARAMS_DEF

private static final Class[] NO_PARAMS_DEF

_ignoreProperties

private Set _ignoreProperties

_obj

private Object _obj

Constructor Detail

CloneableBean

protected CloneableBean()
Default constructor.

To be used by classes extending CloneableBean only.

CloneableBean

public CloneableBean(Object obj)
Creates a CloneableBean to be used in a delegation pattern.

For example:

public class Foo implements Cloneable { private CloneableBean _cloneableBean; public Foo() { _cloneableBean = new CloneableBean(this); } public Object clone() throws CloneNotSupportedException { return _cloneableBean.beanClone(); } }

Parameters: obj object bean to clone.

CloneableBean

public CloneableBean(Object obj, Set ignoreProperties)
Creates a CloneableBean to be used in a delegation pattern.

The property names in the ignoreProperties Set will not be copied into the cloned instance. This is useful for cases where the Bean has convenience properties (properties that are actually references to other properties or properties of properties). For example SyndFeed and SyndEntry beans have convenience properties, publishedDate, author, copyright and categories all of them mapped to properties in the DC Module.

Parameters: obj object bean to clone. ignoreProperties properties to ignore when cloning.

Method Detail

beanClone

public Object beanClone()
Makes a deep bean clone of the object passed in the constructor.

To be used by classes using CloneableBean in a delegation pattern,

Returns: a clone of the object bean.

Throws: CloneNotSupportedException thrown if the object bean could not be cloned.

See Also: constructor.

clone

public Object clone()
Makes a deep bean clone of the object.

To be used by classes extending CloneableBean. Although it works also for classes using CloneableBean in a delegation pattern, for correctness those classes should use the

Returns: a clone of the object bean.

Throws: CloneNotSupportedException thrown if the object bean could not be cloned.

See Also: beanClone method.

cloneArray

private Object cloneArray(Object array)

cloneCollection

private Object cloneCollection(Collection collection)

cloneMap

private Object cloneMap(Map map)

doClone

private Object doClone(Object value)

isBasicType

private boolean isBasicType(Class vClass)
Copyright © Sun Microsystems. All Rights Reserved.