⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 address.java

📁 一款Java实现的HTTP代理服务器
💻 JAVA
字号:
package rabbit.io;import java.net.InetAddress;/** A class to handle the addresses of the connections. *  Basically just a pair of InetAddress and port number. * * @author <a href="mailto:robo@khelekore.org">Robert Olofsson</a> */public class Address {    /** The internet address of this Address. */    private InetAddress ia;    /** The port number were connected to. */    private int port;    /** The hash code.*/    private int hash;        /** Create a new Address with given InetAddress and port      * @param ia the InetAddress this Address is connected to.     * @param port the port number this Address is connected to.     */    public Address (InetAddress ia, int port) {	this.ia = ia;	this.port = port;	String s = ia.getHostAddress () + ":" + port;	hash = s.hashCode ();    }        /** Get the hash code for this object.     * @return the hash code.     */    public int hashCode () {	return hash;    }	    /** Compare this objcet agains another object.     * @param o the Object to compare against.     * @return true if the other Object is an Address connected to      *  the same InetAddress and port, false otherwise.     */    public boolean equals (Object o) {	if (o instanceof Address) {	    Address a = (Address)o;	    return (port == a.port && ia.equals (a.ia));	}	return false;    }	    /** Get a String representation of this Address */    public String toString () {	return ia + ":" + port;    }    /** Get the internet address */    public InetAddress getInetAddress () {	return ia;    }    /** Get the port number */    public int getPort () {	return port;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -