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, FIREFOX3, FIREFOX, CHROME,
18 OPERA, CHROMIUM, OTHER
21 public static Cookie create(BrowserType type) {
24 return new CookieWinCrome();
26 return new CookieWinFirefox4();
28 throw new UnsupportedOperationException();
32 public abstract String getUserSessionString() throws IOException;
35 * 文字列から user_session_ で始まる文字列を切り出して返す。数字とアンダーバー以外の文字で切れる。
36 * @param str 切り出す対象文字列
37 * @return user_session 文字列。見つからなければnull。
39 protected String cutUserSession(String str) {
40 final Matcher mather = USER_SESSION_PATTERN.matcher(str);
41 if (mather.lookingAt()) {
42 return mather.group(1);