1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.morph.transform.copiers;
17
18 import java.util.Locale;
19
20 import net.sf.morph.reflect.IndexedContainerReflector;
21 import net.sf.morph.transform.Converter;
22 import net.sf.morph.transform.Copier;
23 import net.sf.morph.transform.Transformer;
24 import net.sf.morph.util.ReflectorUtils;
25
26 /**
27 * FIXME this class isn't done
28 *
29 * @author Matt Sgarlata
30 * @since Dec 20, 2004
31 * @deprecated it's not clear what the intent of this copier was
32 */
33 public class ContainerOfBeansCopier extends ContainerCopier {
34
35
36 private Class destinationBeanClass;
37
38 protected void put(int index, Object destination, Object value, Class valueClass, Locale locale, Integer preferredTransformationType) {
39 Object transformed = null;
40
41 if (getBeanTransformer() instanceof Copier &&
42 ReflectorUtils.isReflectable(getReflector(),
43 destination.getClass(), IndexedContainerReflector.class)) {
44
45 if (((IndexedContainerReflector) getReflector()).getSize(destination) > index) {
46 transformed = ((IndexedContainerReflector) getReflector()).get(destination, index);
47 if (transformed != null &&
48 getDestinationBeanClass().isAssignableFrom(transformed.getClass())) {
49 ((Copier) getBeanTransformer()).copy(transformed, value, locale);
50 }
51 }
52 }
53
54 if (transformed == null) {
55 transformed = ((Converter) getBeanTransformer()).convert(getDestinationBeanClass(), value, locale);
56 }
57 super.put(index, destination, transformed, valueClass, locale, preferredTransformationType);
58 }
59
60 protected Transformer getBeanTransformer() {
61
62 return getNestedTransformer();
63 }
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81 public Class getDestinationBeanClass() {
82 return destinationBeanClass;
83 }
84 public void setDestinationBeanClass(Class destinationBeanClass) {
85 this.destinationBeanClass = destinationBeanClass;
86 }
87 }