All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sapia.ubik.mcast.InetServerAddress Maven / Gradle / Ivy

The newest version!
package org.sapia.ubik.mcast;

import org.sapia.ubik.net.ServerAddress;

import java.net.InetAddress;


/**
 * Implement a ServerAddress around a
 * an InetAddress and a port.
 *
 * @author Yanick Duchesne
 * 
*
Copyright:
Copyright © 2002-2003 Sapia Open Source Software. All Rights Reserved.
*
License:
Read the license.txt file of the jar or visit the * license page at the Sapia OSS web site
*
*/ public class InetServerAddress implements ServerAddress { private String _transportType = "udp/event/address"; private InetAddress _addr; private int _port; private int _hashCode; /** * Constructor for InetServerAddress. * * @param addr the InetAddress of the server * to which this instance corresponds. * * @param port the port of the server * to which this instance corresponds. */ public InetServerAddress(InetAddress addr, int port) { _addr = addr; _port = port; _hashCode = (addr.toString() + port).hashCode(); } /** * Returns this instance's InetAddress. * * @return an InetAddess. */ public InetAddress getInetAddress() { return _addr; } /** * Returns this instance's port. * * @return a port. */ public int getPort() { return _port; } /** * @see Object#equals(java.lang.Object) */ public boolean equals(Object other) { try { InetServerAddress addr = (InetServerAddress) other; return addr._addr.equals(_addr) && (addr._port == _port); } catch (ClassCastException e) { return false; } } /** * @see ServerAddress#getTransportType() */ public String getTransportType() { return _transportType; } /** * @see Object#hashCode() */ public int hashCode() { return _hashCode; } public String toString(){ return new StringBuffer("[") .append("address=").append(_addr) .append(" ,port=").append(_port) .append("]").toString(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy