peer.java

来自「一个p2p仿真软件」· Java 代码 · 共 77 行

JAVA
77
字号
/*
 * @(#)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 + =
减小字号Ctrl + -
显示快捷键?