KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > driver > ControllerInfo


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2005 Emic Networks.
4  * Contact: c-jdbc@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published by the
8  * Free Software Foundation; either version 2.1 of the License, or any later
9  * version.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14  * for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19  *
20  * Initial developer(s): Emmanuel Cecchet.
21  * Contributor(s): ______________________.
22  */

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

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

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

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

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

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

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

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

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

114   public String JavaDoc toString()
115   {
116     return hostname + ":" + port;
117   }
118 }
Popular Tags