lumis.util.converter
Class AbstractConverter

Package class diagram package AbstractConverter
java.lang.Object
  extended by lumis.util.converter.AbstractConverter
All Implemented Interfaces:
IConverter
Direct Known Subclasses:
AbstractSourceConverter, BooleanConverter, CollectionConverter, DateTimeConverter, FileDataType.FileDataConverter, FilesDataType.FilesDataConverter, NumberConverter, PageDataType.PageDataConverter, PageOrPageTemplateDataType.PageOrPageTemplateDataConverter, PageTemplateDataType.PageDataConverter, ParentContentDataType.ParentContentDataConverter, ResourcesDataType.ResourcesDataConverter, RestConverter

@StableMinor(version="6.2",
             sinceVersion="4.0")
public abstract class AbstractConverter
extends Object
implements IConverter

This is a abstract converter where a default locale and pattern may be specified and has fallback conversion capability.

If the convertion implementation does not support the requested type, this converter falls back to try to convert using ConvertUtil.convert(Class, Object, Locale, String).

Since:
4.0.4

Constructor Summary
AbstractConverter()
           
 
Method Summary
<T> T
convert(Class<T> type, Object value)
          Converts the specified input object into an output object of the specified type.
<T> T
convert(Class<T> type, Object value, Locale locale)
          Converts the specified input object into an output object of the specified type.
<T> T
convert(Class<T> type, Object value, Locale locale, String pattern)
          Converts the specified input object into an output object of the specified type.
protected abstract
<T> T
doConversion(Class<T> type, Object value, Locale locale, String pattern)
          Converts the specified input object into an output object of the specified type.
protected  boolean doesNullValueReturnNull()
           
protected  boolean doesValueInstanceOfTypeReturnValue()
           
 Locale getDefaultLocale()
           
 String getDefaultPattern()
           
 void setDefaultLocale(Locale defaultLocale)
           
 void setDefaultPattern(String defaultPattern)
           
protected  void setFallbackToRegisteredConverters(boolean fallbackToRegisteredConverters)
          Sets if the registered converters should be tried if this converter does not know how to complete the conversion.
protected  boolean shouldFallbackToRegisteredConverters()
          Indicates if the registered converters should be tried if this converter does not know how to complete the conversion.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractConverter

public AbstractConverter()
Method Detail

getDefaultLocale

public Locale getDefaultLocale()

setDefaultLocale

public void setDefaultLocale(Locale defaultLocale)

getDefaultPattern

public String getDefaultPattern()

setDefaultPattern

public void setDefaultPattern(String defaultPattern)

doesNullValueReturnNull

protected boolean doesNullValueReturnNull()

doesValueInstanceOfTypeReturnValue

protected boolean doesValueInstanceOfTypeReturnValue()

shouldFallbackToRegisteredConverters

protected boolean shouldFallbackToRegisteredConverters()
Indicates if the registered converters should be tried if this converter does not know how to complete the conversion.

Returns:
true if should fallback to registered converters, false otherwise.
Since:
4.0.11

setFallbackToRegisteredConverters

protected void setFallbackToRegisteredConverters(boolean fallbackToRegisteredConverters)
Sets if the registered converters should be tried if this converter does not know how to complete the conversion.

Note that if this property is set to false, it is important not to fallback to the registered converters, since it may cause an infinite loop.

Parameters:
fallbackToRegisteredConverters - the value to set.
Since:
4.0.11

doConversion

protected abstract <T> T doConversion(Class<T> type,
                                      Object value,
                                      Locale locale,
                                      String pattern)
                           throws UnsupportedConversionTypeException
Converts the specified input object into an output object of the specified type.

Type Parameters:
T - generics support for the data type specified.
Parameters:
type - data type to which the value should be converted.
value - the input value to be converted.
locale - locale to be used during conversion, if necessary.
pattern - converter specific conversion pattern, to be used during conversion, if necessary.
Throws:
UnsupportedConversionTypeException - if this converter does not supports converting to the specified type.
Since:
4.0.4

convert

public <T> T convert(Class<T> type,
                     Object value,
                     Locale locale,
                     String pattern)
Description copied from interface: IConverter
Converts the specified input object into an output object of the specified type.

Specified by:
convert in interface IConverter
Type Parameters:
T - generics support for the data type specified.
Parameters:
type - data type to which the value should be converted.
value - the input value to be converted.
locale - locale to be used during conversion, if necessary.
pattern - converter specific conversion pattern, to be used during conversion, if necessary.

convert

public <T> T convert(Class<T> type,
                     Object value,
                     Locale locale)
Description copied from interface: IConverter
Converts the specified input object into an output object of the specified type.

Specified by:
convert in interface IConverter
Type Parameters:
T - generics support for the data type specified.
Parameters:
type - data type to which the value should be converted.
value - the input value to be converted.
locale - locale to be used during conversion

convert

public <T> T convert(Class<T> type,
                     Object value)
Description copied from interface: IConverter
Converts the specified input object into an output object of the specified type.

Specified by:
convert in interface IConverter
Type Parameters:
T - generics support for the data type specified.
Parameters:
type - data type to which the value should be converted.
value - the input value to be converted.


Lumisportal  6.2.0.120405 - Copyright © 2006–2012 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.