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 net.sf.morph.Defaults;
19 import net.sf.morph.transform.Converter;
20 import net.sf.morph.transform.Transformer;
21 import net.sf.morph.transform.transformers.SimpleDelegatingTransformer;
22
23 /**
24 * Converts an object to a textual representation by delegating to
25 * {@link net.sf.morph.transform.converters.ContainerToPrettyTextConverter},
26 * {@link net.sf.morph.transform.converters.BooleanToTextConverter},
27 * {@link net.sf.morph.transform.converters.TimeToTextConverter},
28 * {@link net.sf.morph.transform.converters.NumberToTextConverter} and
29 * {@link net.sf.morph.transform.converters.ObjectToTextConverter}.
30 *
31 * @author Matt Sgarlata
32 * @since Jan 1, 2005
33 */
34 public class DefaultToTextConverter extends SimpleDelegatingTransformer {
35
36 /**
37 * Used to specify the destination classes of this converter, and to
38 * determine if a transformation is possible.
39 *
40 * @see {@link DefaultToTextConverter#isTransformableImpl(Class, Class)}
41 * @see {@link DefaultToTextConverter#getDestinationClassesImpl()}
42 */
43 private Converter textConverter;
44
45 /**
46 * Create a new DefaultToTextConverter.
47 */
48 public DefaultToTextConverter() {
49 super();
50 }
51
52 /**
53 * Create a new DefaultToTextConverter.
54 * @param components
55 * @param appendDefaultComponents
56 */
57 public DefaultToTextConverter(Transformer[] components, boolean appendDefaultComponents) {
58 super(components, appendDefaultComponents);
59 }
60
61 /**
62 * Create a new DefaultToTextConverter.
63 * @param components
64 */
65 public DefaultToTextConverter(Transformer[] components) {
66 super(components);
67 }
68
69 /**
70 * {@inheritDoc}
71 */
72 protected Transformer[] createDefaultComponents() {
73 return new Transformer[] { new ContainerToPrettyTextConverter(),
74 new BooleanToTextConverter(), new TimeToTextConverter(),
75 new NumberToTextConverter(), new ObjectToTextConverter() };
76 }
77
78 /**
79 * Unused
80 * @return
81 * @deprecated since Morph 1.1
82 */
83 public Converter getTextConverter() {
84 if (textConverter == null) {
85 setTextConverter(Defaults.createTextConverter());
86 }
87 return textConverter;
88 }
89
90 /**
91 * Unused
92 * @param textConverter
93 * @deprecated since Morph 1.1
94 */
95 public void setTextConverter(Converter textConverter) {
96 this.textConverter = textConverter;
97 }
98 }