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

📄 peer.java

📁 p2p仿真
💻 JAVA
字号:
/*
 * @(#)Peer.java	ver 1.2  6/20/2005
 *
 * Copyright 2005 Weishuai Yang (wyang@cs.binghamton.edu). 
 * All rights reserved.
 * 
 */

package gps.protocol;

import java.util.HashMap;

/**
 * Peer base class, all specific protocol peers inherit from it. 
 *
 *
 * @author  Weishuai Yang
 * @version 1.2,  6/20/2005
 */

public class Peer extends Agent {

	public HashMap mDocDBbyKey = new HashMap();


	/**
	 * dummy constructor
	 *
	 */
	public Peer() {}
	/**
	 * constructs a Peer with peer id
	 */
	public Peer(int i) {
		super(i);
	}	
	/**
	 * resets status of the peer
	 */
	public void reset(){
		super.reset();
		mDocDBbyKey.clear();
		mDocDBbyKey = new HashMap();
	}
	
	/**
	 * add a document to this peer, to be overriden
	 * 
	 * @param doc  the Document
	 */	
	public void ownDocument(Document doc){	
		mDocDBbyKey.put(doc.getKey(),doc);	
	}
	/**
	 * retrieve a document by key
	 * 
	 * @param key
	 * @return Document
	 */	
	public Document getDocument(String key){	
		return (Document)mDocDBbyKey.get(key);	
	}

	/**
	 * gets string description
	 *
	 * @return string description
	 *
	 */

	public String toString(){
		return "Peer("+mAgentID+"/"+getNode().getID()+")";
	}

	
}

⌨️ 快捷键说明

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