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

📄 httptype.java

📁 RFC 1945 Http1.0协议实现。对协议进行了完整面向对象设计
💻 JAVA
字号:
/**
 * 
 */
package edu.sysu.http.impl;

import edu.sysu.http.util.HttpGrammarException;
import edu.sysu.http.util.HttpRegex;

/**
 * @author Administrator
 * 
 */
public class HttpType {

	private String type;
	private String subtype;
	private HttpRegex regex = new HttpRegex();

	/**
	 * 
	 */
	public HttpType() {
		// TODO Auto-generated constructor stub
		this.regex.SetPattern(".+");
	}

	public HttpType(String type, String subtype) throws HttpGrammarException {
		this();
		this.setType(type);
		this.setSubtype(subtype);
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

	public void setType(String type) throws HttpGrammarException {
		if (this.regex.Match(type))
			this.type = type;
		else
			throw new HttpGrammarException("Type invalid.");
	}

	public String getType() {
		return type;
	}

	public void setSubtype(String subtype) throws HttpGrammarException {
		if (this.regex.Match(subtype))
			this.subtype = subtype;
		else
			throw new HttpGrammarException("SubType invalid.");
	}

	public String getSubtype() {
		return subtype;
	}

	public String toString() {
		if(this.type != null && this.subtype != null)
			return this.type + "/" + this.subtype;
		else
			return null;
	}

}

⌨️ 快捷键说明

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