request.java

来自「这是一个很好的考试系统的源码」· Java 代码 · 共 48 行

JAVA
48
字号
package com.tarena.exam.model;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import com.tarena.exam.exceptions.IllegalRequestTypeException;
import com.tarena.exam.exceptions.IllegalResponseTypeException;

public class Request implements Serializable{
	public static final int LOGIN_REQUEST=1;
	public static final int BEGIN_REQUEST=2;
	public static final int SEND_REQUEST=3;
	public static final int QUIT_REQUEST=4;
	
	private int type;
	private Map<String,Serializable> data;
	private static final long serialVersionUID=1L;
	
	public Request(int type){
		switch(type){
		case LOGIN_REQUEST:
		case  BEGIN_REQUEST:
		case SEND_REQUEST:
		case  QUIT_REQUEST:
			this.type=type;  break;
			
		default:
			throw new IllegalRequestTypeException("无效的异常类型:"+type);
			
		}
		data=new HashMap<String,Serializable>();
	}
	
	public void addData(String key,String value){
		data.put(key,value);
	}
	
	public Serializable getData(String key){
		return data.get(key);
	}

	public int getType() {
		return type;
	}

}

⌨️ 快捷键说明

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