KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
7  * Allows you to build valid config for a caching policy. This class <strong>MUST NOT</strong> invoke the actual XML
8  * beans to do its work; one of its purposes is, in fact, to test that those beans are set up correctly.
9  */

10 public class CachingPolicyConfigBuilder extends BaseConfigBuilder {
11
12   private final String JavaDoc matchType;
13   private final String JavaDoc name;
14   private final String JavaDoc query;
15
16   public static final String JavaDoc MATCH_TYPE_EXACT = "exact";
17   public static final String JavaDoc MATCH_TYPE_REGEX = "regex";
18
19   public static final String JavaDoc POLICY_LATEST_VALID = "latest-valid";
20   public static final String JavaDoc POLICY_STALE_DATA_ON_EXCEPTION = "stale-data-on-exception";
21   public static final String JavaDoc POLICY_CACHING_DISABLED = "caching-disabled";
22   public static final String JavaDoc POLICY_EMPTY_RESULTS_ON_EXCEPTION = "empty-results-on-exception";
23
24   public CachingPolicyConfigBuilder(String JavaDoc matchType, String JavaDoc name, String JavaDoc query) {
25     super(5, new String JavaDoc[0]);
26
27     this.matchType = matchType;
28     this.name = name;
29     this.query = query;
30   }
31
32   public String JavaDoc toString() {
33     String JavaDoc out = indent() + "<caching-policy";
34     if (this.matchType != null) out += " match-type=\"" + this.matchType + "\"";
35     if (this.name != null) out += " name=\"" + this.name + "\"";
36     out += ">";
37     if (this.query != null) out += this.query;
38     out += "</caching-policy>\n";
39
40     return out;
41   }
42
43 }
44
Popular Tags