01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.config.schema.test;
06:
07: public class HaConfigBuilder extends BaseConfigBuilder {
08: public static final String HA_MODE_NETWORKED_ACTIVE_PASSIVE = "networked-active-passive";
09: public static final String HA_MODE_DISK_BASED_ACTIVE_PASSIVE = "disk-based-active-passive";
10:
11: private static final String MODE = "mode";
12: private static final String NETWORKED_ACTIVE_PASSIVE_ELECTION_TIME = "election-time";
13: private static final String[] NETWORKED_ACTIVE_PASSIVE = concat(new Object[] { NETWORKED_ACTIVE_PASSIVE_ELECTION_TIME });
14: private static final String[] ALL_PROPERTIES = concat(new Object[] {
15: MODE, NETWORKED_ACTIVE_PASSIVE });
16:
17: public HaConfigBuilder() {
18: super (3, ALL_PROPERTIES);
19: }
20:
21: public void setMode(String data) {
22: setProperty("mode", data);
23: }
24:
25: public void setElectionTime(String data) {
26: setProperty("election-time", data);
27: }
28:
29: public String toString() {
30: String out = "";
31:
32: out += openElement("ha");
33:
34: out += element(MODE);
35:
36: String networkedActivePassiveString = openElement(
37: "networked-active-passive", NETWORKED_ACTIVE_PASSIVE);
38: if (!networkedActivePassiveString.equals("")) {
39: out += networkedActivePassiveString
40: + element(NETWORKED_ACTIVE_PASSIVE_ELECTION_TIME)
41: + closeElement("networked-active-passive");
42: }
43:
44: out += closeElement("ha");
45:
46: return out;
47: }
48:
49: public static HaConfigBuilder newMinimalInstance() {
50: return new HaConfigBuilder();
51: }
52:
53: }
|