com.sun.syndication.feed.impl

Class ToStringBean

public class ToStringBean extends Object implements Serializable

Provides deep Bean toString support.

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

Author: Alejandro Abdelnur

Field Summary
static Object[]NO_PARAMS
static ThreadLocalPREFIX_TL
Class_beanClass
Object_obj
Constructor Summary
protected ToStringBean(Class beanClass)
Default constructor.
ToStringBean(Class beanClass, Object obj)
Creates a ToStringBean to be used in a delegation pattern.
Method Summary
voidprintArrayProperty(StringBuffer sb, String prefix, Object array)
voidprintProperty(StringBuffer sb, String prefix, Object value)
StringtoString()
Returns the String representation of the bean given in the constructor.
StringtoString(String prefix)
Returns the String representation of the bean given in the constructor.

Field Detail

NO_PARAMS

private static final Object[] NO_PARAMS

PREFIX_TL

private static final ThreadLocal PREFIX_TL

_beanClass

private Class _beanClass

_obj

private Object _obj

Constructor Detail

ToStringBean

protected ToStringBean(Class beanClass)
Default constructor.

To be used by classes extending ToStringBean only.

Parameters: beanClass indicates the class to scan for properties, normally an interface class.

ToStringBean

public ToStringBean(Class beanClass, Object obj)
Creates a ToStringBean to be used in a delegation pattern.

For example:

public class Foo implements ToString { public String toString(String prefix) { ToStringBean tsb = new ToStringBean(this); return tsb.toString(prefix); } public String toString() { return toString("Foo"); } }

Parameters: beanClass indicates the class to scan for properties, normally an interface class. obj object bean to create String representation.

Method Detail

printArrayProperty

private void printArrayProperty(StringBuffer sb, String prefix, Object array)

printProperty

private void printProperty(StringBuffer sb, String prefix, Object value)

toString

public String toString()
Returns the String representation of the bean given in the constructor.

It uses the Class name as the prefix.

Returns: bean object String representation.

toString

private String toString(String prefix)
Returns the String representation of the bean given in the constructor.

Parameters: prefix to use for bean properties.

Returns: bean object String representation.

Copyright © Sun Microsystems. All Rights Reserved.