public class CookieWrapper extends javax.servlet.http.Cookie implements org.apache.http.cookie.SetCookie2, Externalizable
This class extends both the javax.servlet.http.Cookie and implements the org.apache.http.cookie.SetCookie2 interface and makes them serializable. There are copy constructors designed for either of these cookie types in order to create a new cookie wrapper that should have the capabilities of both. By using the CookieWrapper for all cookies in the RemoteApplication framework, we can ensure that our handling of cookies between these two frameworks is less error prone.
| Constructor and Description |
|---|
CookieWrapper() |
CookieWrapper(javax.servlet.http.Cookie cookie)
Creates a new CookieWrapper based on a javax.servlet.http.Cookie.
|
CookieWrapper(org.apache.http.cookie.Cookie cookie)
Creates a new CookieWrapper based on org.apache.http.cookie
|
CookieWrapper(CookieWrapper cookie)
This is a copy constructor which creates a new CookieWrapper based on another CookieWrapper.
|
CookieWrapper(String name, String value)
Creates a new Cookie using a name and value pair
|
| Modifier and Type | Method and Description |
|---|---|
Object |
clone() |
boolean |
equals(Object object)
Checks to see whether these cookies are "functionally" equivalent by checking the equivalency of the object's "toString()" function which has all the relivant information.
|
String |
getCommentURL()
Returns the comment URL.
|
Date |
getExpiryDate()
Returns the expiration Date of the cookie, or
null if none exists. |
int |
getMaxAge()
Computes the max age of this cookie based on the ExpiryDate compared to the local time.
|
String |
getName()
Returns the name of the cookie.
|
int[] |
getPorts()
Get the Port attribute.
|
int |
hashCode()
Returns a hashcode based on name and value.
|
boolean |
isExpired(Date date)
Returns
true if this cookie is expired as of the procided date. |
boolean |
isPersistent()
Returns
false if the cookie should be discarded at the end of the "session"; true otherwise. |
boolean |
isSecure()
Indicates whether this cookie requires a secure connection.
|
void |
readExternal(ObjectInput in)
Reads the CookieWrapper from the input stream.
|
void |
setCommentURL(String commentURL)
Sets the comment URL
|
void |
setDiscard(boolean discard)
Set the Discard attribute.
|
void |
setExpiryDate(Date expiryDate)
Sets the expiration Date of the cookie.
|
void |
setMaxAge(int expiry)
Sets the cookie's max age in seconds ala the javax.servlet.http.Cookie spec.
|
void |
setPorts(int[] ports)
Sets the Port attribute.
|
void |
setSecure(boolean secure)
Sets whether this cookie requires a secure connection.
|
String |
toString() |
void |
writeExternal(ObjectOutput out)
Writes the object to the output stream.
|
getComment, getDomain, getPath, getSecure, getValue, getVersion, isHttpOnly, setComment, setDomain, setHttpOnly, setPath, setValue, setVersionfinalize, getClass, notify, notifyAll, wait, wait, waitpublic CookieWrapper()
public CookieWrapper(String name, String value)
name - The name of the Cookievalue - The Cookie Value.public CookieWrapper(javax.servlet.http.Cookie cookie)
cookie - A javax.servlet.http.Cookiepublic CookieWrapper(CookieWrapper cookie)
cookie - A javax.servlet.http.Cookiepublic CookieWrapper(org.apache.http.cookie.Cookie cookie)
cookie - A javax.servlet.http.Cookiepublic String getName()
getName in interface org.apache.http.cookie.CookiegetName in class javax.servlet.http.Cookiepublic void setCommentURL(String commentURL)
setCommentURL in interface org.apache.http.cookie.SetCookie2commentURL - the URL for the comment.public String getCommentURL()
getCommentURL in interface org.apache.http.cookie.Cookiepublic void setMaxAge(int expiry)
null.
If the expiry is greater then zero, then the ExpiryDate will be computed from the current System time and saved accordingly.
If the expiry is zero, then the ExpiryDate will be set to the current System time -1 milisecond to indicate the that cookie has already expired.
setMaxAge in class javax.servlet.http.Cookieexpiry - The delta time to use to add to system time for experation.public int getMaxAge()
getMaxAge in class javax.servlet.http.Cookiepublic void setExpiryDate(Date expiryDate)
setExpiryDate in interface org.apache.http.cookie.SetCookieexpiryDate - the Date or null is this cookie has no expiration.public Date getExpiryDate()
null if none exists.getExpiryDate in interface org.apache.http.cookie.Cookienullpublic boolean isPersistent()
false if the cookie should be discarded at the end of the "session"; true otherwise.isPersistent in interface org.apache.http.cookie.Cookiepublic void setPorts(int[] ports)
setPorts in interface org.apache.http.cookie.SetCookie2ports - Array of ports values.public int[] getPorts()
getPorts in interface org.apache.http.cookie.Cookiepublic void setSecure(boolean secure)
setSecure in interface org.apache.http.cookie.SetCookiesetSecure in class javax.servlet.http.Cookiesecure - value for security.public void setDiscard(boolean discard)
Note: Discard attribute overrides Max-age.
setDiscard in interface org.apache.http.cookie.SetCookie2discard - If the value should be discarded.public boolean isSecure()
isSecure in interface org.apache.http.cookie.Cookietrue if this cookie should only be sent over secure connections, false otherwise.public boolean isExpired(Date date)
true if this cookie is expired as of the procided date.isExpired in interface org.apache.http.cookie.Cookiedate - Current timetrue if the cookie has expired.IllegalArgumentException - is Date is nullpublic int hashCode()
public boolean equals(Object object)
public Object clone()
clone in class javax.servlet.http.Cookiepublic void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface Externalizableout - the ObjectOutput objectIOException - if something goes wrongpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface Externalizablein - the ObjectInputIOException - if something goes wrong with the IOClassNotFoundException - if we have trouble recieving an object member field.