org.springframework.binding.format
Interface Formatter

All Known Implementing Classes:
AbstractFormatter, DateFormatter, LabeledEnumFormatter, NumberFormatter, PropertyEditorFormatter

public interface Formatter

A lightweight interface for formatting a value and parsing a value from its formatted form.

Author:
Keith Donald

Method Summary
 java.lang.String formatValue(java.lang.Object value)
          Format the value.
 java.lang.Object parseValue(java.lang.String formattedString, java.lang.Class targetClass)
          Parse the formatted string representation of a value, restoring the value.
 

Method Detail

formatValue

java.lang.String formatValue(java.lang.Object value)
                             throws java.lang.IllegalArgumentException
Format the value.

Parameters:
value - the value to format
Returns:
the formatted string, fit for display in a UI
Throws:
java.lang.IllegalArgumentException - the value could not be formatted

parseValue

java.lang.Object parseValue(java.lang.String formattedString,
                            java.lang.Class targetClass)
                            throws InvalidFormatException
Parse the formatted string representation of a value, restoring the value.

Parameters:
formattedString - the formatted string representation
targetClass - the target class to convert the formatted value to
Returns:
the parsed value
Throws:
InvalidFormatException - the string was in an invalid form


Copyright © 2009 Spring Framework. All Rights Reserved.