|
@@ -1,52 +1,52 @@ |
1 |
|
- |
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
|
- |
package com.google.gwt.user.client; |
3 |
|
- |
|
4 |
|
- |
import java.util.*; |
5 |
|
- |
|
6 |
|
- |
public class CookieSnapshot { |
7 |
|
- |
private final String mPrimaryCookieValue; |
8 |
|
- |
private final String mRawDocCookies; |
9 |
|
- |
private final HashMap<String, String> mCookies; |
10 |
|
- |
|
11 |
|
- |
public CookieSnapshot( String pPrimaryCookieName ) { |
12 |
|
- |
mPrimaryCookieValue = Cookies.getCookie( pPrimaryCookieName ); // Force update of GWT's Variables |
13 |
|
- |
mRawDocCookies = Cookies.rawCookies; |
14 |
|
- |
mCookies = Cookies.cachedCookies; |
15 |
|
- |
} |
16 |
|
- |
|
17 |
|
- |
/** |
18 |
|
- |
* Gets the Primary Cookie Value associated with the Primary Cookie Name (from construction). |
19 |
|
- |
* |
20 |
|
- |
* @return the primary cookie's value, or <code>null</code> if the primary cookie didn't exist |
21 |
|
- |
*/ |
22 |
|
- |
public String getPrimaryCookieValue() { |
23 |
|
- |
return mPrimaryCookieValue; |
24 |
|
- |
} |
25 |
|
- |
|
26 |
|
- |
/** |
27 |
|
- |
* @return !null String which can be used to check if ANY 'visible' Cookie state has changed |
28 |
|
- |
*/ |
29 |
|
- |
public String getRawDocCookies() { |
30 |
|
- |
return (mRawDocCookies != null) ? mRawDocCookies : ""; |
31 |
|
- |
} |
32 |
|
- |
|
33 |
|
- |
/** |
34 |
|
- |
* Gets all the cookie names in this Snapshot. |
35 |
|
- |
* |
36 |
|
- |
* @return !null set of all the cookie names in this Snapshot |
37 |
|
- |
*/ |
38 |
|
- |
public Set<String> getCookieNames() { |
39 |
|
- |
return mCookies.keySet(); |
40 |
|
- |
} |
41 |
|
- |
|
42 |
|
- |
/** |
43 |
|
- |
* Gets the cookie value associated with the given name in this Snapshot. |
44 |
|
- |
* |
45 |
|
- |
* @param pName the cookie name to retrieved the value for |
46 |
|
- |
* |
47 |
|
- |
* @return the cookie's value, or <code>null</code> if the cookie didn't exist |
48 |
|
- |
*/ |
49 |
|
- |
public String getCookie( String pName ) { |
50 |
|
- |
return mCookies.get( pName ); |
51 |
|
- |
} |
52 |
|
- |
} |
|
1 |
+ |
// This Source Code is in the Public Domain per: http://unlicense.org |
|
2 |
+ |
package com.google.gwt.user.client; |
|
3 |
+ |
|
|
4 |
+ |
import java.util.*; |
|
5 |
+ |
|
|
6 |
+ |
public class CookieSnapshot { |
|
7 |
+ |
private final String mPrimaryCookieValue; |
|
8 |
+ |
private final String mRawDocCookies; |
|
9 |
+ |
private final HashMap<String, String> mCookies; |
|
10 |
+ |
|
|
11 |
+ |
public CookieSnapshot( String pPrimaryCookieName ) { |
|
12 |
+ |
mPrimaryCookieValue = Cookies.getCookie( pPrimaryCookieName ); // Force update of GWT's Variables |
|
13 |
+ |
mRawDocCookies = Cookies.rawCookies; |
|
14 |
+ |
mCookies = Cookies.cachedCookies; |
|
15 |
+ |
} |
|
16 |
+ |
|
|
17 |
+ |
/** |
|
18 |
+ |
* Gets the Primary Cookie Value associated with the Primary Cookie Name (from construction). |
|
19 |
+ |
* |
|
20 |
+ |
* @return the primary cookie's value, or <code>null</code> if the primary cookie didn't exist |
|
21 |
+ |
*/ |
|
22 |
+ |
public String getPrimaryCookieValue() { |
|
23 |
+ |
return mPrimaryCookieValue; |
|
24 |
+ |
} |
|
25 |
+ |
|
|
26 |
+ |
/** |
|
27 |
+ |
* @return !null String which can be used to check if ANY 'visible' Cookie state has changed |
|
28 |
+ |
*/ |
|
29 |
+ |
public String getRawDocCookies() { |
|
30 |
+ |
return (mRawDocCookies != null) ? mRawDocCookies : ""; |
|
31 |
+ |
} |
|
32 |
+ |
|
|
33 |
+ |
/** |
|
34 |
+ |
* Gets all the cookie names in this Snapshot. |
|
35 |
+ |
* |
|
36 |
+ |
* @return !null set of all the cookie names in this Snapshot |
|
37 |
+ |
*/ |
|
38 |
+ |
public Set<String> getCookieNames() { |
|
39 |
+ |
return mCookies.keySet(); |
|
40 |
+ |
} |
|
41 |
+ |
|
|
42 |
+ |
/** |
|
43 |
+ |
* Gets the cookie value associated with the given name in this Snapshot. |
|
44 |
+ |
* |
|
45 |
+ |
* @param pName the cookie name to retrieved the value for |
|
46 |
+ |
* |
|
47 |
+ |
* @return the cookie's value, or <code>null</code> if the cookie didn't exist |
|
48 |
+ |
*/ |
|
49 |
+ |
public String getCookie( String pName ) { |
|
50 |
+ |
return mCookies.get( pName ); |
|
51 |
+ |
} |
|
52 |
+ |
} |