Class ConverterService


  • public abstract class ConverterService
    extends java.lang.Object
    Class to convert values to objects of specified Class. It provides methods to convert values, register/deregister the custom converters. Few pre-registered converters are already present for byte[], UUID, CustomDate and Date
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract <T> T convert​(java.lang.Object o, java.lang.Class<T> clazz)
      Utility method to convert the value to an object of the specified class(if possible).
      abstract void deRegister()
      Remove all registered Converters, and re-establish the standard Converters.
      abstract void deRegister​(java.lang.Class clazz)
      Remove any registered Converter for the specified destination Class.
      static ConverterService getInstance()  
      abstract void register​(boolean throwException, boolean defaultNull, int defaultArraySize)
      Register the provided converters with the specified defaults.
      abstract void register​(Converter converter, java.lang.Class<?> clazz)
      Register a custom Converter for the specified destination Class, replacing any previously registered Converter.
      static void setInstance​(ConverterService instance)  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ConverterService

        public ConverterService()
    • Method Detail

      • convert

        public abstract <T> T convert​(java.lang.Object o,
                                      java.lang.Class<T> clazz)
        Utility method to convert the value to an object of the specified class(if possible). Standard registers are already present. java.lang.BigDecimal (no default value) java.lang.BigInteger (no default value) boolean and java.lang.Boolean (default to false) byte and java.lang.Byte (default to zero) char and java.lang.Character (default to a space) java.lang.Class (no default value) double and java.lang.Double (default to zero) float and java.lang.Float (default to zero) int and java.lang.Integer (default to zero) long and java.lang.Long (default to zero) short and java.lang.Short (default to zero) java.lang.String (default to null) java.io.File (no default value) java.net.URL (no default value) java.sql.Date (no default value) java.sql.Time (no default value) java.sql.Timestamp (no default value)
        Type Parameters:
        T -
        Parameters:
        o -
        clazz -
        Returns:
      • deRegister

        public abstract void deRegister()
        Remove all registered Converters, and re-establish the standard Converters.
      • deRegister

        public abstract void deRegister​(java.lang.Class clazz)
        Remove any registered Converter for the specified destination Class.
        Parameters:
        clazz - - Class for which to remove any registered Converter
      • register

        public abstract void register​(boolean throwException,
                                      boolean defaultNull,
                                      int defaultArraySize)
        Register the provided converters with the specified defaults.
        Parameters:
        throwException - - true if the converters should throw an exception when a conversion error occurs, otherwise false if a default value should be used.
        defaultNull - - true if the standard converters (see org.apache.commons.beanutils.ConvertUtilsBean#registerStandard(boolean, boolean) should use a default value of null, otherwise false. N.B. This values is ignored if throwException is true
        defaultArraySize - - The size of the default array value for array converters (N.B. This values is ignored if throwException is true). Specifying a value less than zero causes a null value to be used for the default.
      • register

        public abstract void register​(Converter converter,
                                      java.lang.Class<?> clazz)
                               throws DermisException
        Register a custom Converter for the specified destination Class, replacing any previously registered Converter.
        Parameters:
        converter - - Converter to be registered
        clazz - - Destination class for conversions performed by this Converter
        Throws:
        DermisException