Docmosis API 4.5.0

com.docmosis.template.population.format
Interface DataFormatter

All Known Implementing Classes:
BooleanDataFormatter, DateDataFormatter, ReflectiveDataProvider.DataFormatManager

public interface DataFormatter

This interface specifies the required signature for a class that can provide format facilities for values produced by DataProviders. The format method provides several parameters which the implementing classes can use to decide the String value to return. Often, not all information will be required by the implenting class to decide what to return. For example, if the DataFormatter is intended to always represent java.util.Date objects the same way, then it does not need to concern itself with anything other than the value. Conversely, if the DataFormatter is intended to render (say) booleans as "Yes/No" in a Person object, but as "Y/N" in an Address object contained inside the Person object, then a single DataFormatter can decide which form to render based on the given delegateClass (which will be Person.class or Address.class).


Method Summary
 String format(Class type, Object value, String fieldName, Class delegateClass)
          Format the given value and return a String to display.
 

Method Detail

format

public String format(Class type,
                     Object value,
                     String fieldName,
                     Class delegateClass)
Format the given value and return a String to display. The class type and fieldName are given to provide more information to the method. Returning null is acceptable.

Parameters:
type - the Class of the object to be formatted
value - the value being formatted
fieldName - the name of the field in the template that the value is destined to populate.
delegateClass - the class of the delegate currently being interrogated. This information may be useful when wanting to format the same types of information differently in the context of different delegate objects.
Returns:
the formatted String. Null may be returned which will be blank in the template.

Docmosis API 4.5.0

Copyright © 2014 Docmosis Pty Ltd. All Rights Reserved.