3 import java.io.IOException;
4 import java.util.regex.Matcher;
5 import java.util.regex.Pattern;
11 public abstract class Cookie {
13 private static final Pattern USER_SESSION_PATTERN = Pattern.compile("user_session_[\\d_]+");
15 public enum BrowserType {
17 NONE, MSIE, IE6, FIREFOX, CHROME,
18 OPERA, CHROMIUM, OTHER
21 public static Cookie create(BrowserType type) {
24 return new CookieWinCrome();
26 return new CookieWinFirefox4();
28 return new CookieWinMsIe();
30 throw new UnsupportedOperationException();
34 public abstract String getUserSessionString() throws IOException;
37 * 文字列から user_session_ で始まる文字列を切り出して返す。数字とアンダーバー以外の文字で切れる。
38 * @param str 切り出す対象文字列
39 * @return user_session 文字列。見つからなければnull。
41 protected String cutUserSession(String str) {
42 final Matcher mather = USER_SESSION_PATTERN.matcher(str);
43 if (mather.lookingAt()) {
44 return mather.group(1);