KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgroups > conf > ProtocolParameter


1 // $Id: ProtocolParameter.java,v 1.4 2004/09/23 16:29:14 belaban Exp $
2

3 package org.jgroups.conf;
4
5 /**
6  * Data holder for protocol data
7  *
8  * @author Filip Hanik (<a HREF="mailto:filip@filip.net">filip@filip.net)
9  * @version 1.0
10  */

11
12 public class ProtocolParameter {
13
14     private final String JavaDoc mParameterName;
15     private final Object JavaDoc mParameterValue;
16
17     public ProtocolParameter(String JavaDoc parameterName,
18                              Object JavaDoc parameterValue) {
19         mParameterName=parameterName;
20         mParameterValue=parameterValue;
21     }
22
23     public String JavaDoc getName() {
24         return mParameterName;
25     }
26
27     public Object JavaDoc getValue() {
28         return mParameterValue;
29     }
30
31     public int hashCode() {
32         if(mParameterName != null)
33             return mParameterName.hashCode();
34         else
35             return -1;
36     }
37
38     public boolean equals(Object JavaDoc another) {
39         if(another instanceof ProtocolParameter)
40             return getName().equals(((ProtocolParameter)another).getName());
41         else
42             return false;
43     }
44
45     public String JavaDoc getParameterString() {
46         StringBuffer JavaDoc buf=new StringBuffer JavaDoc(mParameterName);
47         if(mParameterValue != null)
48             buf.append('=').append(mParameterValue.toString());
49         return buf.toString();
50     }
51
52     public String JavaDoc getParameterStringXml() {
53         StringBuffer JavaDoc buf=new StringBuffer JavaDoc(mParameterName);
54         if(mParameterValue != null)
55             buf.append("=\"").append(mParameterValue.toString()).append('\"');
56         return buf.toString();
57     }
58 }
59
Popular Tags