📄 httptype.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 + -