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: /**
07: * Allows you to build valid config for a caching policy. This class <strong>MUST NOT</strong> invoke the actual XML
08: * beans to do its work; one of its purposes is, in fact, to test that those beans are set up correctly.
09: */
10: public class CachingPolicyConfigBuilder extends BaseConfigBuilder {
11:
12: private final String matchType;
13: private final String name;
14: private final String query;
15:
16: public static final String MATCH_TYPE_EXACT = "exact";
17: public static final String MATCH_TYPE_REGEX = "regex";
18:
19: public static final String POLICY_LATEST_VALID = "latest-valid";
20: public static final String POLICY_STALE_DATA_ON_EXCEPTION = "stale-data-on-exception";
21: public static final String POLICY_CACHING_DISABLED = "caching-disabled";
22: public static final String POLICY_EMPTY_RESULTS_ON_EXCEPTION = "empty-results-on-exception";
23:
24: public CachingPolicyConfigBuilder(String matchType, String name,
25: String query) {
26: super (5, new String[0]);
27:
28: this .matchType = matchType;
29: this .name = name;
30: this .query = query;
31: }
32:
33: public String toString() {
34: String out = indent() + "<caching-policy";
35: if (this .matchType != null)
36: out += " match-type=\"" + this .matchType + "\"";
37: if (this .name != null)
38: out += " name=\"" + this .name + "\"";
39: out += ">";
40: if (this .query != null)
41: out += this .query;
42: out += "</caching-policy>\n";
43:
44: return out;
45: }
46:
47: }
|