KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > driver > ControllerInfo


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2005 Emic Networks.
4  * Contact: sequoia@continuent.org
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * Initial developer(s): Emmanuel Cecchet.
19  * Contributor(s): ______________________.
20  */

21
22 package org.continuent.sequoia.driver;
23
24 /**
25  * Controller related information, namely the host name and the port on which
26  * the controller is running.
27  *
28  * @author <a HREF="mailto:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet
29  * </a>
30  * @version 1.0
31  */

32 public class ControllerInfo
33 {
34   private String JavaDoc hostname;
35   private int port;
36
37   /**
38    * Creates a ControllerInfo object
39    */

40   public ControllerInfo()
41   {
42   }
43
44   /**
45    * Creates a new <code>ControllerInfo</code> object
46    *
47    * @param hostname the controller host name
48    * @param port the controller port
49    */

50   public ControllerInfo(String JavaDoc hostname, int port)
51   {
52     this.hostname = hostname;
53     this.port = port;
54   }
55
56   /**
57    * Get the hostname where the controller is running
58    *
59    * @return controller hostname
60    */

61   public String JavaDoc getHostname()
62   {
63     return hostname;
64   }
65
66   /**
67    * Get the port number on which the controller is listening.
68    *
69    * @return port number.
70    */

71   public int getPort()
72   {
73     return port;
74   }
75
76   /**
77    * Set the controller hostname.
78    *
79    * @param string hostname to set
80    */

81   public void setHostname(String JavaDoc string)
82   {
83     hostname = string;
84   }
85
86   /**
87    * Set the port number.
88    *
89    * @param port port number
90    */

91   public void setPort(int port)
92   {
93     this.port = port;
94   }
95
96   /**
97    * @see java.lang.Object#equals(java.lang.Object)
98    */

99   public boolean equals(Object JavaDoc obj)
100   {
101     if (obj instanceof ControllerInfo)
102     {
103       ControllerInfo other = (ControllerInfo) obj;
104       return hostname.equals(other.getHostname()) && (port == other.port);
105     }
106     return false;
107   }
108
109   /**
110    * @see java.lang.Object#hashCode()
111    */

112   public int hashCode()
113   {
114     return hostname.hashCode();
115   }
116
117   /**
118    * @see java.lang.Object#toString()
119    */

120   public String JavaDoc toString()
121   {
122     return hostname + ":" + port;
123   }
124 }
Popular Tags