Class AbstractConverter

    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      <T> T convert​(java.lang.Class<T> type, java.lang.Object value)
      Converts the specified input object into an output object of the specified type.
      <T> T convert​(java.lang.Class<T> type, java.lang.Object value, java.util.Locale locale)
      Converts the specified input object into an output object of the specified type.
      <T> T convert​(java.lang.Class<T> type, java.lang.Object value, java.util.Locale locale, java.lang.String pattern)
      Converts the specified input object into an output object of the specified type.
      protected abstract <T> T doConversion​(java.lang.Class<T> type, java.lang.Object value, java.util.Locale locale, java.lang.String pattern)
      Converts the specified input object into an output object of the specified type.
      protected boolean doesNullValueReturnNull()  
      protected boolean doesValueInstanceOfTypeReturnValue()  
      java.util.Locale getDefaultLocale()  
      java.lang.String getDefaultPattern()  
      void setDefaultLocale​(java.util.Locale defaultLocale)  
      void setDefaultPattern​(java.lang.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 java.util.Locale getDefaultLocale()
      • setDefaultLocale

        public void setDefaultLocale​(java.util.Locale defaultLocale)
      • getDefaultPattern

        public java.lang.String getDefaultPattern()
      • setDefaultPattern

        public void setDefaultPattern​(java.lang.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​(java.lang.Class<T> type,
                                              java.lang.Object value,
                                              java.util.Locale locale,
                                              java.lang.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​(java.lang.Class<T> type,
                             java.lang.Object value,
                             java.util.Locale locale,
                             java.lang.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​(java.lang.Class<T> type,
                             java.lang.Object value,
                             java.util.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​(java.lang.Class<T> type,
                             java.lang.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.