org.springframework.binding.format.support
Class LabeledEnumFormatter
java.lang.Object
org.springframework.binding.format.support.AbstractFormatter
org.springframework.binding.format.support.LabeledEnumFormatter
- All Implemented Interfaces:
- Formatter
public class LabeledEnumFormatter
- extends AbstractFormatter
Converts from string to a LabeledEnum instance and back.
- Author:
- Keith Donald
Method Summary |
protected java.lang.String |
doFormatValue(java.lang.Object value)
Template method subclasses should override to encapsulate formatting logic. |
protected java.lang.Object |
doParseValue(java.lang.String formattedString,
java.lang.Class targetClass)
Template method subclasses should override to encapsulate parsing logic. |
org.springframework.core.enums.LabeledEnum |
parseLabeledEnum(java.lang.String formattedString,
java.lang.Class enumClass)
Convenience method to parse a LabeledEnum. |
void |
setLabeledEnumResolver(org.springframework.core.enums.LabeledEnumResolver labeledEnumResolver)
Set the LabeledEnumResolver used. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LabeledEnumFormatter
public LabeledEnumFormatter()
- Default constructor.
LabeledEnumFormatter
public LabeledEnumFormatter(boolean allowEmpty)
- Create a new LabeledEnum formatter.
- Parameters:
allowEmpty
- should this formatter allow empty input arguments?
setLabeledEnumResolver
public void setLabeledEnumResolver(org.springframework.core.enums.LabeledEnumResolver labeledEnumResolver)
- Set the LabeledEnumResolver used. Defaults to
StaticLabeledEnumResolver
.
doFormatValue
protected java.lang.String doFormatValue(java.lang.Object value)
- Description copied from class:
AbstractFormatter
- Template method subclasses should override to encapsulate formatting logic.
- Specified by:
doFormatValue
in class AbstractFormatter
- Parameters:
value
- the value to format
- Returns:
- the formatted string representation
doParseValue
protected java.lang.Object doParseValue(java.lang.String formattedString,
java.lang.Class targetClass)
throws java.lang.IllegalArgumentException
- Description copied from class:
AbstractFormatter
- Template method subclasses should override to encapsulate parsing logic.
- Specified by:
doParseValue
in class AbstractFormatter
- Parameters:
formattedString
- the formatted string to parse
- Returns:
- the parsed value
- Throws:
java.lang.IllegalArgumentException
parseLabeledEnum
public org.springframework.core.enums.LabeledEnum parseLabeledEnum(java.lang.String formattedString,
java.lang.Class enumClass)
throws InvalidFormatException
- Convenience method to parse a LabeledEnum.
- Throws:
InvalidFormatException
Copyright © 2009 Spring Framework. All Rights Reserved.