public interface Formatter<T>
Interface that is used to provide a relatively simple formatting interface to the rest of the system. Designed to wrap the complexity of the java.text format classes in an interface that can take two (or three if you include Locale) parameters from tags and apply formats in an intelligent way.
In terms of lifecycle, a formatter will be instantiated, have setFormatType(), setFormatString() and setLocale() called in rapid succession. If no values were supplied, setFormatType() and setFormatString() may not be called - and implementations should select reasonable defaults. Locale will always be provided. After the setters have been called, init() will be called, and the Formatter should use this opportunity to construct any internal objects necessary to perform formatting. The format() method will then be called one or more times before the Formatter is eventually dereferenced.
Modifier and Type | Method and Description |
---|---|
java.lang.String |
format(T input)
Formats the supplied value as a String.
|
void |
init()
Called once all setters have been invoked, to allow Formatter to prepare itself.
|
void |
setFormatPattern(java.lang.String formatPattern)
Sets a named format, or format pattern to use in formatting objects.
|
void |
setFormatType(java.lang.String formatType)
Sets the type of format that should be created.
|
void |
setLocale(java.util.Locale locale)
Sets the Locale into which the object should be formatted.
|
void setFormatType(java.lang.String formatType)
void setFormatPattern(java.lang.String formatPattern)
void setLocale(java.util.Locale locale)
void init()
java.lang.String format(T input)
null
.input
- an object of a type that the formatter knows how to format? Copyright 2005-2006, Stripes Development Team.