org.directwebremoting.convert
Class LocaleConverter

java.lang.Object
  extended by org.directwebremoting.extend.AbstractConverter
      extended by org.directwebremoting.convert.LocaleConverter
All Implemented Interfaces:
Converter

public class LocaleConverter
extends AbstractConverter

An implementation of Converter for java.util.Locale.

Author:
Jose Noheda [jose.noheda@gmail.com]

Constructor Summary
LocaleConverter()
           
 
Method Summary
 java.lang.Object convertInbound(java.lang.Class<?> paramType, InboundVariable data)
          Parses a locale string that matches language_country_variant.
 OutboundVariable convertOutbound(java.lang.Object data, OutboundContext outctx)
          Return a javascript string that defines the variable named varName to have the contents of the converted object data.
 
Methods inherited from class org.directwebremoting.extend.AbstractConverter
setConverterManager
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocaleConverter

public LocaleConverter()
Method Detail

convertInbound

public java.lang.Object convertInbound(java.lang.Class<?> paramType,
                                       InboundVariable data)
                                throws ConversionException
Parses a locale string that matches language_country_variant.

Parameters:
paramType - The type to convert to
data - The data to convert
Returns:
The converted data, or null if the conversion was not possible
Throws:
ConversionException - If the conversion failed for some reason

convertOutbound

public OutboundVariable convertOutbound(java.lang.Object data,
                                        OutboundContext outctx)
                                 throws ConversionException
Description copied from interface: Converter
Return a javascript string that defines the variable named varName to have the contents of the converted object data.

In contrast to convertInbound() failures in converting data on the way out should not stop processing, and we should carry on if we can. Failures are probably down to some misconfiguration so as much information about the error as can be safely generated to console logs is good. In other words if you need to loop in outbound conversion then it might be a good idea to catch issues inside the loop, log, and carry on.

Parameters:
data - The data to convert
outctx - A collection of objects already converted and the results
Returns:
The OutboundVariable that represents the data to convert
Throws:
ConversionException - If the conversion failed for some reason

Copyright 2008