KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > dyade > aaa > agent > conf > A3CMLNat


1 /*
2  * Copyright (C) 2001 - 2003 ScalAgent Distributed Technologies
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17  * USA.
18  */

19 package fr.dyade.aaa.agent.conf;
20
21 import java.io.*;
22
23 /**
24  * The class <code>A3CMLNat</code> describes a
25  * network address translation.
26  */

27 public class A3CMLNat implements Serializable {
28   /** server id. */
29   public short sid = -1;
30   /** Value of the translation host. */
31   public String JavaDoc host = null;
32   /** Value of the translation port. */
33   public int port = -1;
34
35   public A3CMLNat(short sid,
36                   String JavaDoc host,
37                   int port) {
38     this.sid = sid;
39     this.host = host;
40     this.port = port;
41   }
42   
43   public A3CMLNat duplicate() throws Exception JavaDoc {
44     A3CMLNat clone = new A3CMLNat(sid, host, port);
45     return clone;
46   }
47
48   public String JavaDoc toString() {
49     StringBuffer JavaDoc strBuf = new StringBuffer JavaDoc();
50     strBuf.append("(");
51     strBuf.append(super.toString());
52     strBuf.append(",sid=").append(sid);
53     strBuf.append(",host=").append(host);
54     strBuf.append(",port=").append(port);
55     strBuf.append(")");
56     return strBuf.toString();
57   }
58
59   public boolean equals(Object JavaDoc obj) {
60     if (obj == null) return false;
61
62     if (obj instanceof A3CMLNat) {
63       A3CMLNat nat = (A3CMLNat) obj;
64       if ((sid == nat.sid) &&
65           ((host == nat.host) ||
66            ((host != null) && host.equals(nat.host))) &&
67           (port == nat.port))
68         return true;
69     }
70     return false;
71   }
72 }
73
Popular Tags