wicket.util.convert.converters
Class StringConverter

java.lang.Object
  extended by wicket.util.convert.converters.AbstractConverter
      extended by wicket.util.convert.converters.StringConverter
All Implemented Interfaces:
java.io.Serializable, ITypeConverter

public class StringConverter
extends AbstractConverter

Converts objects to Strings. Since the formatting of Strings may vary depending on the type of object being converted, you can register ITypeConverters for each kind of formatting you want to support. For example, the default StringConverter class registers a set of converters which convert from various types to String, including DateToStringConverter, which converts from Objects of type Date to Strings.

Author:
Eelco Hillenius, Jonathan Locke
See Also:
Serialized Form

Constructor Summary
StringConverter()
          Construct.
 
Method Summary
 void clear()
          Removes all registered string converters.
 java.lang.Object convert(java.lang.Object value, java.util.Locale locale)
          Converts the given value
 ITypeConverter get(java.lang.Class c)
          Gets the type converter that is registered for class c.
 ITypeConverter getDefaultConverter()
          Gets the converter that is to be used when no registered converter is found.
protected  java.lang.Class getTargetType()
           
 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(ITypeConverter defaultConverter)
          Sets the converter that is to be used when no registered converter is found.
 
Methods inherited from class wicket.util.convert.converters.AbstractConverter
newConversionException, parse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringConverter

public StringConverter()
Construct.

Method Detail

clear

public void clear()
Removes all registered string converters.


convert

public java.lang.Object convert(java.lang.Object value,
                                java.util.Locale locale)
Description copied from interface: ITypeConverter
Converts the given value

Parameters:
value - The value to convert
Returns:
The converted value
See Also:
ITypeConverter.convert(java.lang.Object,java.util.Locale)

get

public ITypeConverter get(java.lang.Class c)
Gets the type converter that is registered for class c.

Parameters:
c - The class to get the type converter for
Returns:
The type converter that is registered for class c or null if no type converter was registered for class c

getDefaultConverter

public final ITypeConverter getDefaultConverter()
Gets the converter that is to be used when no registered converter is found.

Returns:
the converter that is to be used when no registered converter is found

remove

public ITypeConverter remove(java.lang.Class c)
Removes the type converter currently registered for class c.

Parameters:
c - The class for which the converter registration should be removed
Returns:
The converter that was registered for class c before removal or null if none was registered

set

public ITypeConverter set(java.lang.Class c,
                          ITypeConverter converter)
Registers a converter for use with class c.

Parameters:
converter - The converter to add
c - The class for which the converter should be used
Returns:
The previous registered converter for class c or null if none was registered yet for class c

setDefaultConverter

public final void setDefaultConverter(ITypeConverter defaultConverter)
Sets the converter that is to be used when no registered converter is found. This allows converter chaining.

Parameters:
defaultConverter - The converter that is to be used when no registered converter is found

getTargetType

protected java.lang.Class getTargetType()
Specified by:
getTargetType in class AbstractConverter
Returns:
The target type of this type converter
See Also:
AbstractConverter.getTargetType()


Copyright © 2004-2007 Wicket developers. All Rights Reserved.