1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 1997,2008 Oracle.  All rights reserved.
5 *
6 * $Id: ReplicationHostAddress.java,v 12.11 2008/04/02 13:43:38 bschmeck Exp $
7 */
8
9package com.sleepycat.db;
10
11/**
12A simple wrapper class to hold information needed to define
13a host in a replication group.
14<p>
15The ReplicationHostAddress can be used to refer to the current
16site, or to a remote site in the replication group.
17<p>
18Used in the {@link com.sleepycat.db.EnvironmentConfig#replicationManagerAddRemoteSite EnvironmentConfig.replicationManagerAddRemoteSite}
19and the {@link com.sleepycat.db.EnvironmentConfig#setReplicationManagerLocalSite EnvironmentConfig.setReplicationManagerLocalSite}
20methods.
21**/
22public class ReplicationHostAddress {
23    /**
24    The network port component of the site address.
25    **/
26    public int port;
27    /**
28    The name component of the site address. Can be a fully qualified
29    name, or a dotted format address in String format.
30    **/
31    public String host;
32
33    /**
34    Create a ReplicationHostAddress with default settings.
35    <p>
36    This is likely not what you want. The current default is
37    host: localhost and port 0.
38    <p>
39    Only use this constructor if you plan to configure the object
40    fields manually after construction.
41    **/
42    public ReplicationHostAddress()
43    {
44        this("localhost", 0);
45    }
46
47    /**
48    Create a ReplicationHostAddress with user defined host and port information.
49    **/
50    public ReplicationHostAddress(String host, int port)
51    {
52	this.port = port;
53	this.host = host;
54    }
55
56    /** {@inheritDoc} */
57    public String toString() {
58	return host + ":" + port;
59    }
60
61    /** {@inheritDoc} */
62    public boolean equals(Object o){
63	try{
64	    return this.toString().equals(((ReplicationHostAddress)o).toString());
65	}catch (Exception e){
66	    return false;
67	}
68    }
69}
70