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

📄 httptype.java

📁 使用java实现的RFC1945 http1.0协议。所有面向对象设计严谨按照RFC 1945协议中的描述。源代码逾4000行。提供给Java网络编程初学者学习
💻 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 + -