01: package org.jgroups.conf;
02:
03: /**
04: * Data holder for protocol data
05: *
06: * @author Filip Hanik (<a href="mailto:filip@filip.net">filip@filip.net)
07: * @author Bela Ban
08: * @version $Id: ProtocolParameter.java,v 1.5 2006/08/15 05:50:06 belaban Exp $
09: */
10:
11: public class ProtocolParameter {
12:
13: private final String mParameterName;
14: private String mParameterValue;
15:
16: public ProtocolParameter(String parameterName, String parameterValue) {
17: mParameterName = parameterName;
18: mParameterValue = parameterValue;
19: }
20:
21: public String getName() {
22: return mParameterName;
23: }
24:
25: public String getValue() {
26: return mParameterValue;
27: }
28:
29: public void setValue(String replacement) {
30: mParameterValue = replacement;
31: }
32:
33: public int hashCode() {
34: if (mParameterName != null)
35: return mParameterName.hashCode();
36: else
37: return -1;
38: }
39:
40: public boolean equals(Object another) {
41: if (another instanceof ProtocolParameter)
42: return getName().equals(
43: ((ProtocolParameter) another).getName());
44: else
45: return false;
46: }
47:
48: public String getParameterString() {
49: StringBuffer buf = new StringBuffer(mParameterName);
50: if (mParameterValue != null)
51: buf.append('=').append(mParameterValue);
52: return buf.toString();
53: }
54:
55: public String getParameterStringXml() {
56: StringBuffer buf = new StringBuffer(mParameterName);
57: if (mParameterValue != null)
58: buf.append("=\"").append(mParameterValue).append('\"');
59: return buf.toString();
60: }
61:
62: }
|