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

📄 identificador.java

📁 java 实现的P2P Chord算法。chord算法是结构式的P2P搜索与管理协议
💻 JAVA
字号:
package org.mikel.jchord;/* * Identificador.java * * Created on 16 de diciembre de 2004, 15:55 */import java.io.*;import java.security.*;import java.text.*;import java.math.*;import java.net.*;/** * * @author mikel */public class Identificador implements Comparable,Serializable {        private String IP;    private int puerto;    private BigInteger hash;        /**     * Creates a new instance of Identificador     * @param bits     * @param intId     */    public Identificador(String IP, int puerto) {                this.setIP(IP);        this.setPuerto(puerto);        this.setHash(Utilidades.generarSHA1(IP+":"+puerto));                    }        public Identificador(String IP, int puerto, BigInteger hash) {                this.setIP(IP);        this.setPuerto(puerto);        this.setHash(hash);            }        public String getIP(){        return IP;    }        public int getPuerto(){        return puerto;    }        public BigInteger getHash(){        return hash;    }        public int compareTo(Object o){        return this.getHash().compareTo(((Identificador)o).getHash());            }        public boolean equals(Object o){                if(o==null){            return false;        } else{            return (this.getIP().equals(((Identificador)o).getIP())&& this.getPuerto()==((Identificador)o).getPuerto());        }    }        public void setIP(String IP) {        this.IP = IP;    }        public void setPuerto(int puerto) {        this.puerto = puerto;    }        public void setHash(BigInteger hash) {        this.hash = hash;    }            }

⌨️ 快捷键说明

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