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

📄 globals.java

📁 p2p仿真器。开发者可以工作在覆盖层中进行创造和测试逻辑算法或者创建和测试新的服务。PlanetSim还可以将仿真代码平稳转换为在Internet上的实验代码
💻 JAVA
字号:

package planet.simulate;

import planet.util.Properties;

/**
 * This class contains as static manner all of the types and
 * string representatations of them requireds for the simulator. 
 * @author <a href="mailto: pedro.garcia@urv.net">Pedro Garcia</a>
 * @author <a href="mailto: ruben.mondejar@estudiants.urv.es">Ruben Mondejar</a>
 * @author <a href="mailto: jordi.pujol@estudiants.urv.es">Jordi Pujol</a>
 * 08-jul-2005
 */
public class Globals {
	/**
	 * For internal use to correct value for the TYPES array.
	 */
	private static final int MINIMUM	= 200;
	/**
	 * Event type: Adding a new node to the network.
	 */
	public final static int JOIN		= 200;
	/**
	 * Event type: Node leaving network.
	 */
	public final static int LEAVE		= 201;
	/**
	 * Event type: Node fails.
	 */
	public final static int FAIL 		= 202;
	
	/* END ******************  CONSTANTS FOR EVENTS *********************/
	
	/* ******************  CONSTANTS FOR MODE OF ROUTEMESSAGE *******/
	/**
	 * Mode value: This mode is returned by the simulator always when the
	 * receiver of a message not exist in the actual network. 
	 */
	public final static int ERROR 		= 203;
	
	/* END ******************  CONSTANTS FOR MODE OF ROUTEMESSAGE *******/

	/**
	 * This String contains a string representation of each of 
	 * event types and RouteMessage type.
	 */	
	private final static String[] TYPES = {"JOIN","LEAVE","FAIL","ERROR"}; 

	/**
	 * Returns a string representation of each of event type and 
	 * RouteMessage mode.
	 * @param type Type of the RouteMessage to get its 
	 * String representation.
	 * @return String representation of the type of RouteMessage.
	 */
	public static final String typeToString(int type) {
		try {
			return Properties.overlayPropertiesInstance.typeToString(type);
		} catch(ArrayIndexOutOfBoundsException e) {
			return TYPES[type-MINIMUM];
		}
	}
	/**
	 * Returns a string representation of each of event mode and 
	 * RouteMessage mode.
	 * @param mode Mode of the RouteMessage to get its 
	 * String representation.
	 * @return String representation of the mode of RouteMessage.
	 */
	public static final String modeToString(int mode) {
		try {
			return Properties.overlayPropertiesInstance.modeToString(mode);
		} catch(ArrayIndexOutOfBoundsException e) {
			return TYPES[mode-MINIMUM];
		}
	}
}

⌨️ 快捷键说明

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