public class Formatters
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Formatters.AnnotationFormatter<A extends java.lang.annotation.Annotation,T>
Super-type for annotation-based formatters.
|
static class |
Formatters.SimpleFormatter<T>
Super-type for custom simple formatters.
|
Modifier and Type | Field and Description |
---|---|
static org.springframework.format.support.FormattingConversionService |
conversion
The underlying conversion service.
|
Constructor and Description |
---|
Formatters() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
parse(java.lang.reflect.Field field,
java.lang.String text,
java.lang.Class<T> clazz)
Parses this string as instance of a specific field in the given class
|
static <T> T |
parse(java.lang.String text,
java.lang.Class<T> clazz)
Parses this string as instance of the given class.
|
static <T> java.lang.String |
print(java.lang.reflect.Field field,
T t)
Computes the display string for any value, for a specific field.
|
static <T> java.lang.String |
print(T t)
Computes the display string for any value.
|
static <T> java.lang.String |
print(org.springframework.core.convert.TypeDescriptor desc,
T t)
Computes the display string for any value, for a specific type.
|
static <A extends java.lang.annotation.Annotation,T> |
register(java.lang.Class<T> clazz,
Formatters.AnnotationFormatter<A,T> formatter)
Registers an annotation-based formatter.
|
static <T> void |
register(java.lang.Class<T> clazz,
Formatters.SimpleFormatter<T> formatter)
Registers a simple formatter.
|
public static final org.springframework.format.support.FormattingConversionService conversion
public static <T> T parse(java.lang.String text, java.lang.Class<T> clazz)
text
- the text to parseclazz
- class representing the required typepublic static <T> T parse(java.lang.reflect.Field field, java.lang.String text, java.lang.Class<T> clazz)
field
- the related field (custom formatters are extracted from this field annotation)text
- the text to parseclazz
- class representing the required typepublic static <T> java.lang.String print(T t)
t
- the value to printpublic static <T> java.lang.String print(java.lang.reflect.Field field, T t)
field
- the related field - custom formatters are extracted from this field annotationt
- the value to printpublic static <T> java.lang.String print(org.springframework.core.convert.TypeDescriptor desc, T t)
desc
- the field descriptor - custom formatters are extracted from this descriptor.t
- the value to printpublic static <T> void register(java.lang.Class<T> clazz, Formatters.SimpleFormatter<T> formatter)
clazz
- class handled by this formatterformatter
- the formatter to registerpublic static <A extends java.lang.annotation.Annotation,T> void register(java.lang.Class<T> clazz, Formatters.AnnotationFormatter<A,T> formatter)
clazz
- class handled by this formatterformatter
- the formatter to register