01: package org.vraptor.converter.basic;
02:
03: import java.util.Arrays;
04:
05: import org.apache.log4j.Logger;
06: import org.vraptor.converter.Converter;
07: import org.vraptor.converter.LocaleDoubleConverter;
08: import org.vraptor.converter.LocaleFloatConverter;
09: import org.vraptor.converter.LocalePrimitiveDoubleConverter;
10: import org.vraptor.converter.LocalePrimitiveFloatConverter;
11: import org.vraptor.converter.SimpleConverterManager;
12:
13: /**
14: * Utility for registering all primitive and primitive-wrappers converters for
15: * xpathing parameters.
16: *
17: * @author Guilherme Silveira
18: */
19: public class BasicConverters {
20:
21: private static final Logger LOG = Logger
22: .getLogger(BasicConverters.class);
23:
24: /**
25: * Registers those basic converters
26: *
27: */
28: public static void register(SimpleConverterManager repository) {
29: Converter[] converters = new Converter[] {
30: new SimpleLongConverter(),
31: new PrimitiveLongConverter(),
32: new SimpleIntegerConverter(),
33: new PrimitiveIntConverter(),
34: new LocaleFloatConverter(),
35: new LocalePrimitiveFloatConverter(),
36: new LocaleDoubleConverter(),
37: new LocalePrimitiveDoubleConverter(),
38: new StringConverter(), new SimpleBooleanConverter(),
39: new PrimitiveBooleanConverter(),
40: new SimpleShortConverter(),
41: new PrimitiveShortConverter(),
42: new SimpleByteConverter(),
43: new PrimitiveByteConverter(),
44: new SimpleCharacterConverter(),
45: new PrimitiveCharConverter(),
46: new SimpleBigDecimalConverter(),
47: new LocaleCalendarDateConverter(), new EnumConverter(),
48: new LocaleConverter() };
49: if (LOG.isDebugEnabled()) {
50: LOG.debug("Registering the basic converters "
51: + Arrays.toString(converters));
52: }
53: for (Converter converter : converters) {
54: repository.register(converter);
55: }
56: }
57:
58: }
|