org.pojomatic.formatter
Class DefaultPojoFormatter

java.lang.Object
  extended by org.pojomatic.formatter.DefaultPojoFormatter
All Implemented Interfaces:
PojoFormatter

public class DefaultPojoFormatter
extends java.lang.Object
implements PojoFormatter

Default formatter for classes that use Pojomatic. This implementation first presents the class name, and then each property in turn, separated by commas, using braces to indicate nesting.

For example, if a class Person has two properties, firstName and LastName, and these properties are using DefaultPropertyFormatter, then the Person instance representing Joe Blow would be represented as "Person{firstName: {Joe}, lastName: {Blow}}"


Constructor Summary
DefaultPojoFormatter()
           
 
Method Summary
 java.lang.String getPropertyPrefix(PropertyElement property)
          Get the String prefix for a given PropertyElement.
 java.lang.String getPropertySuffix(PropertyElement property)
          Get the String suffix for a given PropertyElement.
 java.lang.String getToStringPrefix(java.lang.Class<?> pojoClass)
          Get the String which should appear at the beginning of the result of toString().
 java.lang.String getToStringSuffix(java.lang.Class<?> pojoClass)
          Get the String which should appear at the end of the result of toString().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultPojoFormatter

public DefaultPojoFormatter()
Method Detail

getPropertyPrefix

public java.lang.String getPropertyPrefix(PropertyElement property)
Description copied from interface: PojoFormatter
Get the String prefix for a given PropertyElement. This method will be called once for each property used in the result of toString(), in the order in which those properties will appear in that result, and before the call to PropertyFormatter.format(Object) for the property's value.

Specified by:
getPropertyPrefix in interface PojoFormatter
Parameters:
property - the property for which to generate a prefix
Returns:
the prefix for the given property

getPropertySuffix

public java.lang.String getPropertySuffix(PropertyElement property)
Description copied from interface: PojoFormatter
Get the String suffix for a given PropertyElement. This method will be called once after each call to PropertyFormatter.format(Object) for the property's value.

Specified by:
getPropertySuffix in interface PojoFormatter
Parameters:
property - the property for which to generate a suffix
Returns:
the suffix for the given property

getToStringPrefix

public java.lang.String getToStringPrefix(java.lang.Class<?> pojoClass)
Description copied from interface: PojoFormatter
Get the String which should appear at the beginning of the result of toString().

Specified by:
getToStringPrefix in interface PojoFormatter
Parameters:
pojoClass - the class for which toString() is being called
Returns:
the prefix to appear at the beginning of the result of toString()
See Also:
Object.toString()

getToStringSuffix

public java.lang.String getToStringSuffix(java.lang.Class<?> pojoClass)
Description copied from interface: PojoFormatter
Get the String which should appear at the end of the result of toString().

Specified by:
getToStringSuffix in interface PojoFormatter
Parameters:
pojoClass - the class for which toString() is being called
Returns:
the suffix to appear at the end of the result of toString()
See Also:
Object.toString()


Copyright © 2008-2010. All Rights Reserved.