| 1 | |
package org.webslinger.resolver; |
| 2 | |
|
| 3 | |
import javax.servlet.http.Cookie; |
| 4 | |
|
| 5 | |
public final class CookieResolver extends BeanResolver<Cookie> { |
| 6 | |
private CookieResolver() { |
| 7 | 1 | super(); |
| 8 | |
|
| 9 | |
|
| 10 | 1 | addFetcher("comment", new BeanResolver.BeanGet<Cookie, String>("comment", String.class) { |
| 11 | |
public String getValue(Cookie cookie) { |
| 12 | 0 | return cookie.getComment(); |
| 13 | |
} |
| 14 | |
|
| 15 | |
public void setValue(Cookie cookie, String value) { |
| 16 | 0 | cookie.setComment(value); |
| 17 | 0 | } |
| 18 | |
}); |
| 19 | 1 | addFetcher("domain", new BeanResolver.BeanGet<Cookie, String>("domain", String.class) { |
| 20 | |
public String getValue(Cookie cookie) { |
| 21 | 0 | return cookie.getDomain(); |
| 22 | |
} |
| 23 | |
|
| 24 | |
public void setValue(Cookie cookie, String value) { |
| 25 | 0 | cookie.setDomain(value); |
| 26 | 0 | } |
| 27 | |
}); |
| 28 | 1 | addFetcher("max-age", new BeanResolver.BeanGet<Cookie, Integer>("max-age", Integer.class) { |
| 29 | |
public Integer getValue(Cookie cookie) { |
| 30 | 0 | return cookie.getMaxAge(); |
| 31 | |
} |
| 32 | |
|
| 33 | |
public void setValue(Cookie cookie, Integer value) { |
| 34 | 0 | cookie.setMaxAge(value); |
| 35 | 0 | } |
| 36 | |
}); |
| 37 | 1 | addFetcher("name", new BeanResolver.BeanGet<Cookie, String>("name", String.class) { |
| 38 | |
public String getValue(Cookie cookie) { |
| 39 | 0 | return cookie.getName(); |
| 40 | |
} |
| 41 | |
}); |
| 42 | 1 | addFetcher("path", new BeanResolver.BeanGet<Cookie, String>("path", String.class) { |
| 43 | |
public String getValue(Cookie cookie) { |
| 44 | 0 | return cookie.getPath(); |
| 45 | |
} |
| 46 | |
|
| 47 | |
public void setValue(Cookie cookie, String value) { |
| 48 | 0 | cookie.setPath(value); |
| 49 | 0 | } |
| 50 | |
}); |
| 51 | 1 | addFetcher("secure", new BeanResolver.BeanGet<Cookie, Boolean>("secure", Boolean.class) { |
| 52 | |
public Boolean getValue(Cookie cookie) { |
| 53 | 0 | return cookie.getSecure(); |
| 54 | |
} |
| 55 | |
}); |
| 56 | 1 | addFetcher("value", new BeanResolver.BeanGet<Cookie, String>("value", String.class) { |
| 57 | |
public String getValue(Cookie cookie) { |
| 58 | 0 | return cookie.getValue(); |
| 59 | |
} |
| 60 | |
|
| 61 | |
public void setValue(Cookie cookie, String value) { |
| 62 | 0 | cookie.setValue(value); |
| 63 | 0 | } |
| 64 | |
}); |
| 65 | 1 | addFetcher("version", new BeanResolver.BeanGet<Cookie, Integer>("version", Integer.class) { |
| 66 | |
public Integer getValue(Cookie cookie) { |
| 67 | 0 | return cookie.getVersion(); |
| 68 | |
} |
| 69 | |
|
| 70 | |
public void setValue(Cookie cookie, Integer value) { |
| 71 | 0 | cookie.setVersion(value); |
| 72 | 0 | } |
| 73 | |
}); |
| 74 | 1 | } |
| 75 | |
|
| 76 | 1 | public static final CookieResolver RESOLVER = new CookieResolver(); |
| 77 | |
|
| 78 | 2 | public static class CookieResolverInfo implements ObjectResolverInfo<Cookie> { |
| 79 | |
public String getType() { |
| 80 | 1 | return "javax.servlet.http.Cookie"; |
| 81 | |
} |
| 82 | |
|
| 83 | |
public CookieResolver getResolver() { |
| 84 | 1 | return RESOLVER; |
| 85 | |
} |
| 86 | |
} |
| 87 | |
} |