org.nuiton.util.converter
Class ConverterUtil

java.lang.Object
  extended by org.nuiton.util.converter.ConverterUtil

public class ConverterUtil
extends Object

Une classe contenant des méthodes utiles sur les converters et les conversions

Since:
1.3 (replace org.nuiton.util.ConverterUtil).
Author:
tchemit

Field Summary
protected static String CONVERTER_PACKAGE
          le paquetage où chercher les implentations de Converter, si non présents dans le système
protected static Boolean WAS_INIT
          un drapeau pour savoir si on doit charger les converters specifiques
 
Constructor Summary
ConverterUtil()
           
 
Method Summary
static byte[] convert(char[] chars)
           
static
<T> T
convert(Class<T> type, Object toConvert)
          Convertir une valeur!
static void deregister()
           
static
<T> org.apache.commons.beanutils.Converter
getConverter(Class<T> type)
          Cherche un converter pour un type donné.
static void initConverters()
           
static void registerConverter(Class<?> type)
           
protected static void registerConverter0(Class<?> type)
           
static void registerEnumConverter(Class<?> type)
          Enregistre un nouveau converter pour un type d'enum donné, sans utiliser de valeur par defaut.
static void registerEnumConverter(Class<?> type, Object defaultValue)
          Enregistre un nouveau converter pour un type d'enum donné, avec une valeur par defaut.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONVERTER_PACKAGE

protected static final String CONVERTER_PACKAGE
le paquetage où chercher les implentations de Converter, si non présents dans le système

See Also:
Constant Field Values

WAS_INIT

protected static Boolean WAS_INIT
un drapeau pour savoir si on doit charger les converters specifiques

Constructor Detail

ConverterUtil

public ConverterUtil()
Method Detail

getConverter

public static <T> org.apache.commons.beanutils.Converter getConverter(Class<T> type)
Cherche un converter pour un type donné.

Recherche dans un premier temps dans les converteurs déjà connus.

Si le type est une énum et qu'aucun converter, n'a été trouvé, on enregistre un nouveau convert d'enum.

Sinon on tente d'instancier un converteur dans le paquetage dédié aux converteurs CONVERTER_PACKAGE.

Type Parameters:
T - le type a convertir
Parameters:
type - le type a convertir
Returns:
le converter trouvé, ou null si non trouvé

convert

public static <T> T convert(Class<T> type,
                            Object toConvert)
Convertir une valeur!

Type Parameters:
T - le type de donnee recherchee
Parameters:
type - le type de donnee recherchee
toConvert - l'object a convertir
Returns:
la nouvelle instance de l'objet converti type ou null

registerConverter

public static void registerConverter(Class<?> type)
                              throws IllegalAccessException,
                                     InstantiationException,
                                     ClassNotFoundException
Throws:
IllegalAccessException
InstantiationException
ClassNotFoundException

registerConverter0

protected static void registerConverter0(Class<?> type)
                                  throws IllegalAccessException,
                                         InstantiationException,
                                         ClassNotFoundException
Throws:
IllegalAccessException
InstantiationException
ClassNotFoundException

registerEnumConverter

public static void registerEnumConverter(Class<?> type,
                                         Object defaultValue)
Enregistre un nouveau converter pour un type d'enum donné, avec une valeur par defaut.

Parameters:
type - le type d'enum à convertir
defaultValue - la valeur par defaut.

registerEnumConverter

public static void registerEnumConverter(Class<?> type)
Enregistre un nouveau converter pour un type d'enum donné, sans utiliser de valeur par defaut.

Parameters:
type - le type d'enum à convertir

convert

public static byte[] convert(char[] chars)

deregister

public static void deregister()

initConverters

public static void initConverters()


Copyright © 2004-2011 CodeLutin. All Rights Reserved.