com.benfante.utils.string
Class DefaultToStringWorker

java.lang.Object
  extended by com.benfante.utils.string.DefaultToStringWorker
All Implemented Interfaces:
ToStringWorker
Direct Known Subclasses:
AnnotatedFieldsToStringWorker

public class DefaultToStringWorker
extends java.lang.Object
implements ToStringWorker

A ToStringWorker that returns the String rappresentation of an object using reflection on its attributes.

Version:
$Id$
Author:
Lucio Benfante lucio@benfante.com

Constructor Summary
DefaultToStringWorker()
          Creates a DefaultStringWorker using defaults values.
DefaultToStringWorker(java.lang.String indentationString)
          Creates a DefaultStringWorker.
 
Method Summary
protected  boolean isExposed(java.lang.reflect.Field f)
          Test if the field must be exposed by the toString method.
 java.lang.String toString(java.lang.Object o)
          Returns the String rappresentation of the passed object using reflection on its attributes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultToStringWorker

public DefaultToStringWorker()
Creates a DefaultStringWorker using defaults values. The default value for the indentation string can be changed setting the com.benfante.utils.string.DefaultToStringWorker.indentationString system property.


DefaultToStringWorker

public DefaultToStringWorker(java.lang.String indentationString)
Creates a DefaultStringWorker.

Parameters:
indentationString - The string used for indenting the output. If null, it is used the default value.
Method Detail

toString

public java.lang.String toString(java.lang.Object o)
Returns the String rappresentation of the passed object using reflection on its attributes.

Specified by:
toString in interface ToStringWorker
Parameters:
o - The object to be rappresented in String.
Returns:
The String rappresentation of the passed object.

isExposed

protected boolean isExposed(java.lang.reflect.Field f)
Test if the field must be exposed by the toString method. This method exists for subclasses. In this class it returns always true.

Parameters:
f - The field to test
Returns:
true


Copyright © 2007. All Rights Reserved.