01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.config.schema.test;
05:
06: import com.tc.config.schema.builder.InstrumentedClassConfigBuilder;
07:
08: /**
09: * Allows you to build valid config for an instrumented class. This class <strong>MUST NOT</strong> invoke the actual
10: * XML beans to do its work; one of its purposes is, in fact, to test that those beans are set up correctly.
11: */
12: public class InstrumentedClassConfigBuilderImpl extends
13: BaseConfigBuilder implements InstrumentedClassConfigBuilder {
14:
15: private boolean isInclude;
16:
17: public InstrumentedClassConfigBuilderImpl(Class clazz) {
18: this ();
19: setClassExpression(clazz.getName());
20: }
21:
22: public InstrumentedClassConfigBuilderImpl() {
23: //super(4, ALL_PROPERTIES);
24: super (5, ALL_PROPERTIES);
25: this .isInclude = true;
26:
27: setArrayPropertyTagName("on-load", "method");
28: }
29:
30: public void setIsInclude(boolean isInclude) {
31: this .isInclude = isInclude;
32: }
33:
34: public void setClassExpression(String value) {
35: if (isInclude)
36: setProperty("class-expression", value);
37: else
38: setProperty("exclude", value);
39: }
40:
41: public void setHonorTransient(String value) {
42: setProperty("honor-transient", value);
43: }
44:
45: public void setHonorTransient(boolean value) {
46: setProperty("honor-transient", value);
47: }
48:
49: public void setCallConstructorOnLoad(String value) {
50: setProperty("call-constructor-on-load", value);
51: }
52:
53: public void setCallConstructorOnLoad(boolean value) {
54: setProperty("call-constructor-on-load", value);
55: }
56:
57: public void setCallMethodOnLoad(String value) {
58: setProperty("on-load", new Object[] { value });
59: }
60:
61: private static final String[] ALL_PROPERTIES = new String[] {
62: "class-expression", "honor-transient",
63: "call-constructor-on-load", "exclude", "on-load" };
64:
65: public String toString() {
66: String out = "";
67:
68: if (this .isInclude) {
69: out += indent() + openElement("include");
70: out += indent() + elements(ALL_PROPERTIES);
71: out += indent() + closeElement("include");
72: } else {
73: out += indent() + elements(ALL_PROPERTIES);
74: }
75:
76: return out;
77: }
78:
79: }
|