KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > config > schema > test > InstrumentedClassConfigBuilderImpl


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.config.schema.test;
5
6 import com.tc.config.schema.builder.InstrumentedClassConfigBuilder;
7
8 /**
9  * 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 BaseConfigBuilder implements InstrumentedClassConfigBuilder {
13
14   private boolean isInclude;
15
16   public InstrumentedClassConfigBuilderImpl(Class JavaDoc clazz) {
17     this();
18     setClassExpression(clazz.getName());
19   }
20
21   public InstrumentedClassConfigBuilderImpl() {
22     super(4, ALL_PROPERTIES);
23     this.isInclude = true;
24   }
25
26   public void setIsInclude(boolean isInclude) {
27     this.isInclude = isInclude;
28   }
29
30   public void setClassExpression(String JavaDoc value) {
31     if (isInclude) setProperty("class-expression", value);
32     else setProperty("exclude", value);
33   }
34
35   public void setHonorTransient(String JavaDoc value) {
36     setProperty("honor-transient", value);
37   }
38
39   public void setHonorTransient(boolean value) {
40     setProperty("honor-transient", value);
41   }
42
43   public void setCallConstructorOnLoad(String JavaDoc value) {
44     setProperty("call-constructor-on-load", value);
45   }
46
47   public void setCallConstructorOnLoad(boolean value) {
48     setProperty("call-constructor-on-load", value);
49   }
50
51   private static final String JavaDoc[] ALL_PROPERTIES = new String JavaDoc[] { "class-expression", "honor-transient",
52       "call-constructor-on-load", "exclude" };
53
54   public String JavaDoc toString() {
55     String JavaDoc out = "";
56
57     if (this.isInclude) {
58       out += indent() + openElement("include");
59       out += indent() + elements(ALL_PROPERTIES);
60       out += indent() + closeElement("include");
61     } else {
62       out += indent() + elements(ALL_PROPERTIES);
63     }
64
65     return out;
66   }
67
68 }
69
Popular Tags