Interface IConverter<C>
-
- Type Parameters:
C
- The object to convert from and to String
- All Superinterfaces:
IClusterable
,Serializable
- All Known Implementing Classes:
AbstractConverter
,AbstractDateConverter
,AbstractDecimalConverter
,AbstractIntegerConverter
,AbstractJavaTimeConverter
,AbstractNumberConverter
,BigDecimalConverter
,BigIntegerConverter
,BooleanConverter
,ByteConverter
,CalendarConverter
,CharacterConverter
,DateConverter
,DoubleConverter
,FloatConverter
,IntegerConverter
,LocalDateConverter
,LocalDateTimeConverter
,LocalTimeConverter
,LongConverter
,MaskConverter
,ShortConverter
,SqlDateConverter
,SqlTimeConverter
,SqlTimestampConverter
,ZonedDateTimeConverter
public interface IConverter<C> extends IClusterable
Converts input to output and vice versa. Converters are needed in web applications because we have to switch between Java objects on the server and Strings in the browser output and input.Output conversion, which is handled by
See org.apache.wicket.Component#getConverter(Class) See org.apache.wicket.Application#getConverterLocator()convertToString(Object, Locale)
, is typically used by components when they render, so that a date can be displayed as '12/12/2007'. Input conversion, handled byconvertToObject(String, Locale)
, is typically used by form components to interpret incoming values Such values are strings as they are send as request parameters from browsers. An incoming value could be the string '12/12/2007' which could be translated to a correspondingDate
object. Notice that incoming value, when used by a FormComponent, will never be null because before validation form components perform the required (see FormComponent.isRequired()) check which errors out on null values. In the case the FormComponent is not required and the user enters a null value converters will not be invoked because no type conversion is necessary.- Author:
- Eelco Hillenius, Jonathan Locke
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description C
convertToObject(String value, Locale locale)
Converts the givenString
valueString
convertToString(C value, Locale locale)
Converts the given value to a string.
-
-
-
Method Detail
-
convertToObject
C convertToObject(String value, Locale locale) throws ConversionException
Converts the givenString
value- Parameters:
value
- The string value to convertlocale
- The locale used to convert the value- Returns:
- The converted value
- Throws:
ConversionException
- if value could not be converted
-
convertToString
String convertToString(C value, Locale locale)
Converts the given value to a string.- Parameters:
value
- The value to convertlocale
- The locale used to convert the value- Returns:
- The converted string value
-
-