org.apache.wicket.util.convert.converter
Class AbstractConverter<C>

java.lang.Object
  extended by org.apache.wicket.util.convert.converter.AbstractConverter<C>
Type Parameters:
C -
All Implemented Interfaces:
Serializable, IClusterable, IConverter<C>
Direct Known Subclasses:
AbstractNumberConverter, BooleanConverter, CharacterConverter, DateConverter, SqlDateConverter, SqlTimeConverter, SqlTimestampConverter

public abstract class AbstractConverter<C>
extends Object
implements IConverter<C>

Base class for locale aware type converters.

Author:
Eelco Hillenius
See Also:
Serialized Form

Constructor Summary
AbstractConverter()
           
 
Method Summary
 String convertToString(C value, Locale locale)
          Converts the given value to a string.
protected abstract  Class<C> getTargetType()
           
protected  ConversionException newConversionException(String message, Object value, Locale locale)
          Creates a conversion exception for throwing
protected  C parse(Format format, Object value, Locale locale)
          Parses a value using one of the java.util.text format classes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.wicket.util.convert.IConverter
convertToObject
 

Constructor Detail

AbstractConverter

public AbstractConverter()
Method Detail

parse

protected C parse(Format format,
                  Object value,
                  Locale locale)
Parses a value using one of the java.util.text format classes.

Parameters:
format - The format to use
value - The object to parse
locale - The locale to use to parse.
Returns:
The object
Throws:
ConversionException - Thrown if parsing fails

newConversionException

protected ConversionException newConversionException(String message,
                                                     Object value,
                                                     Locale locale)
Creates a conversion exception for throwing

Parameters:
message - The message
value - The value that didn't convert
locale - The locale
Returns:
The ConversionException

getTargetType

protected abstract Class<C> getTargetType()
Returns:
The target type of this type converter

convertToString

public String convertToString(C value,
                              Locale locale)
Description copied from interface: IConverter
Converts the given value to a string.

Specified by:
convertToString in interface IConverter<C>
Parameters:
value - The value to convert
locale - The locale used to convert the value
Returns:
The converted string value
See Also:
IConverter.convertToString(java.lang.Object, Locale)


Copyright © 2006-2012 Apache Software Foundation. All Rights Reserved.