1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.morph.transform.converters;
17
18 import java.util.Locale;
19
20 import net.sf.morph.transform.DecoratedConverter;
21 import net.sf.morph.transform.TransformationException;
22 import net.sf.morph.transform.transformers.BaseTransformer;
23
24 /**
25 * Converts <code>null</code> to <code>null</code>.
26 * @deprecated an IdentityConverter can do the same thing.
27 * @author Matt Sgarlata
28 * @since Dec 31, 2004
29 */
30 public class NullConverter extends BaseTransformer implements DecoratedConverter {
31
32 private static final Class[] SOURCE_TYPES = { null };
33
34 private static final Class[] DESTINATION_TYPES = { null, Object.class };
35
36 /**
37 * {@inheritDoc}
38 */
39 protected Object convertImpl(Class destinationClass, Object source,
40 Locale locale) throws Exception {
41
42 if (source == null) {
43 return null;
44 }
45 throw new TransformationException(destinationClass, source);
46 }
47
48 /**
49 * {@inheritDoc}
50 */
51 protected boolean isPerformingLogging() {
52
53 return false;
54 }
55
56 /**
57 * {@inheritDoc}
58 */
59 protected boolean isWrappingRuntimeExceptions() {
60 return true;
61 }
62
63 /**
64 * {@inheritDoc}
65 */
66 protected Class[] getSourceClassesImpl() throws Exception {
67 return SOURCE_TYPES;
68 }
69
70 /**
71 * {@inheritDoc}
72 */
73 protected Class[] getDestinationClassesImpl() throws Exception {
74 return DESTINATION_TYPES;
75 }
76
77 }