httpresponseexception.java

来自「RFC 1945 Http1.0协议实现。对协议进行了完整面向对象设计」· Java 代码 · 共 56 行

JAVA
56
字号
/**
 * 
 */
package edu.sysu.http.util;

/**
 * @author Administrator
 *
 */
public class HttpResponseException extends Exception{

	/**
	 * 
	 */
	private static final long serialVersionUID = -3389874230879895502L;
	private String msg;
	private HttpRegex regex = new HttpRegex("[0-9]{3}");
	/**
	 * 
	 */
	public HttpResponseException() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param msg the msg to set
	 */
	public void setMsg(String msg) throws HttpGrammarException{
		if(this.regex.Match(msg))
			this.msg = msg;
		else
			throw new HttpGrammarException("Message invalid.");
	}
	public HttpResponseException(String msg) {
		try {
			this.setMsg(msg);
		} catch (HttpGrammarException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
	}
	public String getMessage(){
		return this.msg;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		HttpResponseException exp = new HttpResponseException("200");
		System.out.println(exp.getMessage());
	}

}

⌨️ 快捷键说明

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