1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.morph.reflect.reflectors;
17
18 import net.sf.composite.Defaults;
19 import net.sf.composite.specialize.SpecializationException;
20 import net.sf.composite.specialize.Specializer;
21 import net.sf.composite.specialize.specializers.CachingSpecializerProxy;
22 import net.sf.composite.specialize.specializers.CloningSpecializer;
23 import net.sf.composite.util.CompositeUtils;
24 import net.sf.composite.validate.ComponentValidator;
25 import net.sf.morph.reflect.Reflector;
26
27 /**
28 *
29 * @author Matt Sgarlata
30 * @since Oct 25, 2007
31 */
32 public abstract class BaseCompositeReflector extends BaseReflector {
33
34 private Object[] components;
35 private Specializer specializer;
36 private ComponentValidator componentValidator;
37
38
39 public boolean isSpecializable(Class type) throws SpecializationException {
40 initialize();
41 return getSpecializer().isSpecializable(this, type);
42 }
43
44 public Object specialize(Class type) {
45 initialize();
46 return getSpecializer().specialize(this, type);
47 }
48
49 public Class getComponentType() {
50 return Reflector.class;
51 }
52
53 protected boolean isPerformingLogging() {
54
55 return false;
56 }
57
58 public Object clone() throws CloneNotSupportedException {
59 return super.clone();
60 }
61
62 public String toString() {
63 return CompositeUtils.toString(this);
64 }
65
66 public Object[] getComponents() {
67 return components;
68 }
69
70 public void setComponents(Object[] components) {
71 setInitialized(false);
72 this.components = components;
73 }
74
75 public Specializer getSpecializer() {
76 if (specializer == null) {
77 specializer = new CachingSpecializerProxy(new CloningSpecializer());
78 }
79 return specializer;
80 }
81
82 public void setSpecializer(Specializer specializer) {
83 this.specializer = specializer;
84 }
85
86 public ComponentValidator getComponentValidator() {
87 if (componentValidator == null) {
88 componentValidator = Defaults.createComponentValidator();
89 }
90 return componentValidator;
91 }
92
93 public void setComponentValidator(ComponentValidator validator) {
94 this.componentValidator = validator;
95 }
96
97 }