Class BasicTypeConverter


  • public class BasicTypeConverter
    extends java.lang.Object
    Converter for basic types.
    • Constructor Detail

      • BasicTypeConverter

        public BasicTypeConverter()
        Create a new type converter.
        Parameters:
        converters - The contained converters.
      • BasicTypeConverter

        public BasicTypeConverter​(java.util.Map<java.lang.Class<?>,​IStringObjectConverter> converters)
        Create a new type converter.
        Parameters:
        converters - The contained converters.
    • Method Detail

      • convertString

        public java.lang.Object convertString​(java.lang.String val,
                                              java.lang.Class<?> type,
                                              java.lang.Object context)
                                       throws java.lang.Exception
        Convert a string value.
        Parameters:
        val - The string value.
        type - The target class.
        context - The conversion context.
        Returns:
        The converted value.
        Throws:
        java.lang.Exception
      • convertObject

        public java.lang.String convertObject​(java.lang.Object val,
                                              java.lang.Class<?> type,
                                              java.lang.Object context)
                                       throws java.lang.Exception
        Convert a string value.
        Parameters:
        val - The string value.
        type - The target class.
        context - The conversion context.
        Returns:
        The converted value.
        Throws:
        java.lang.Exception
      • addConverter

        public void addConverter​(java.lang.Class<?> type,
                                 IStringObjectConverter converter)
        Add a new converter.
        Parameters:
        type - The type.
        converter - The converter.
      • removeConverter

        public void removeConverter​(java.lang.Class<?> type)
        Remove a converter.
        Parameters:
        type - The type.
      • isSupportedType

        public boolean isSupportedType​(java.lang.Class<?> clazz)
        Test if a clazz is a built-in type.
        Parameters:
        clazz - The clazz.
        Returns:
        True, if built-in type.
      • getStringConverter

        public IStringObjectConverter getStringConverter​(java.lang.Class<?> clazz)
        Get a String -> X converter for a target clazz.
        Parameters:
        clazz - The clazz.
        Returns:
        converter The converter.
      • getObjectConverter

        public IObjectStringConverter getObjectConverter​(java.lang.Class<?> clazz)
        Get a X -> String converter for a source clazz.
        Parameters:
        clazz - The clazz.
        Returns:
        converter The converter.
      • isBuiltInType

        public static boolean isBuiltInType​(java.lang.Class<?> clazz)
        Test if a clazz is a built-in type.
        Parameters:
        clazz - The clazz.
        Returns:
        True, if built-in type.
      • getBasicStringConverter

        public static IStringObjectConverter getBasicStringConverter​(java.lang.Class<?> clazz)
        Get a String -> X converter for a target clazz.
        Parameters:
        clazz - The clazz.
        Returns:
        converter The converter.
      • getBasicObjectConverter

        public static IObjectStringConverter getBasicObjectConverter​(java.lang.Class<?> clazz)
        Get a X -> String converter for a source clazz.
        Parameters:
        clazz - The clazz.
        Returns:
        converter The converter.
      • getConverters

        public java.util.Map<java.lang.Class<?>,​IStringObjectConverter> getConverters()
        Get converters copy.
        Returns:
        Get a copy of the converters.
      • getExtendedConverters

        public java.util.Map<java.lang.Class<?>,​IStringObjectConverter> getExtendedConverters()
        Get extended converters copy.
        Returns:
        Get a copy of the extended converters.