|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectwicket.util.convert.Converter
Implementation of IConverter interface, which converts objects from one class to another. This class allows specific type converters implementing the ITypeConverter interface to be registered as conversion operations for specific types. By default this class registers type converters for Date, String and all Java primitive types and their wrapper classes.
To convert from a Double value to a String value you can use the generalized converter interface:
final IConverter converter = new ConverterFactory().newConverter(); converter.setLocale(Locale.US); converter.convert(new Double(7.1), String.class);Or this can be accomplished by directly using the StringConverter type conversion class (which is registered as a type converter on the IConverter returned by the converter factory above).
final StringConverter converter = new StringConverter(Locale.US); converter.convert(new Double(7.1));When using Wicket, you should rarely need to use any of the conversion classes directly. There are convenient validators and conversion features built into Wicket that you can use directly.
IConverterFactory,
Serialized Form| Constructor Summary | |
Converter()
Constructor |
|
Converter(java.util.Locale locale)
Constructor |
|
| Method Summary | |
void |
clear()
Removes all registered converters. |
java.lang.Object |
convert(java.lang.Object value,
java.lang.Class c)
Converts the given value to class c. |
ITypeConverter |
get(java.lang.Class c)
Gets the type converter that is registered for class c. |
IConverter |
getDefaultConverter()
Gets the converter that is to be used when no registered converter is found. |
java.util.Locale |
getLocale()
Gets the locale. |
ITypeConverter |
remove(java.lang.Class c)
Removes the type converter currently registered for class c. |
ITypeConverter |
set(java.lang.Class c,
ITypeConverter converter)
Registers a converter for use with class c. |
void |
setDefaultConverter(IConverter defaultConverter)
Sets the converter that is to be used when no registered converter is found. |
void |
setLocale(java.util.Locale locale)
Sets the locale. |
java.lang.String |
toString(java.lang.Object value)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Converter()
public Converter(java.util.Locale locale)
locale - The locale| Method Detail |
public void clear()
public java.lang.Object convert(java.lang.Object value,
java.lang.Class c)
convert in interface IConvertervalue - The value to convertc - The class to convert to
IConverter.convert(java.lang.Object,
java.lang.Class)public ITypeConverter get(java.lang.Class c)
c - The class to get the type converter for
public final IConverter getDefaultConverter()
public java.util.Locale getLocale()
ILocalizable
getLocale in interface ILocalizableILocalizable.getLocale()public ITypeConverter remove(java.lang.Class c)
c - The class for which the converter registration should be
removed
public ITypeConverter set(java.lang.Class c,
ITypeConverter converter)
converter - The converter to addc - The class for which the converter should be used
public final void setDefaultConverter(IConverter defaultConverter)
defaultConverter - The converter that is to be used when no registered converter
is foundpublic void setLocale(java.util.Locale locale)
ILocalizable
setLocale in interface ILocalizablelocale - The localeILocalizable.setLocale(java.util.Locale)public java.lang.String toString(java.lang.Object value)
value - The value to convert to a String
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||