?? cookie.java
字號:
package com.maverick.http;
import java.util.Date;
import java.util.StringTokenizer;
import java.text.SimpleDateFormat;
import java.text.ParseException;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2005</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class Cookie {
String name;
String value;
String path = "";
Date expires = null;
String domain = "";
boolean secure = false;
static SimpleDateFormat format = new SimpleDateFormat("EEE, DD-MMM-yyyy HH:mm:ss z");
public Cookie(String setCookieHeaderValue) {
StringTokenizer tokens = new StringTokenizer(setCookieHeaderValue, ";");
while(tokens.hasMoreTokens()) {
String pair = tokens.nextToken();
int idx = pair.indexOf('=');
if(idx > -1) {
String name = pair.substring(0, idx).trim();
String value = pair.substring(idx+1).trim();
if(name.equalsIgnoreCase("expires")) {
try {
int e = Integer.parseInt(value);
} catch(NumberFormatException ex) {
try {
expires = format.parse(value);
} catch(ParseException ex2) {
}
}
} else if(name.equalsIgnoreCase("path")) {
this.path = value;
} else if(name.equalsIgnoreCase("domain")) {
this.domain = path;
} else {
this.name = name;
this.value = value;
}
} else if(pair.trim().equalsIgnoreCase("secure"))
secure = true;
}
}
public String getPath() {
return path;
}
public String getDomain() {
return domain;
}
public boolean isSecure() {
return secure;
}
public String getName() {
return name;
}
public String getValue() {
return value;
}
public Date getExpires() {
return expires;
}
public String toString() {
return name + "=" + value;
/* + (expires!=null ? format.format(expires) + "; " : "")
+ (path!=null ? "path=" + path + "; " : "")
+ (domain!=null ? "domain=" + domain + "; " : "")
+ (secure ? "secure" : "");*/
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -