Skip navigation links

Oracle© Fusion Middleware Java API Reference for Oracle ADF Faces
11g Release 1 (11.1.1.7.0)
E10684-08


oracle.adf.view.rich.remote
Class CookieWrapper

java.lang.Object
  extended by javax.servlet.http.Cookie
      extended by oracle.adf.view.rich.remote.CookieWrapper

All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, org.apache.http.cookie.Cookie, org.apache.http.cookie.SetCookie, org.apache.http.cookie.SetCookie2

public class CookieWrapper
extends javax.servlet.http.Cookie
implements org.apache.http.cookie.SetCookie2, java.io.Externalizable

The RemoteApplicationFramework needs to use two cookie types on a regular basis. The first is the javax.servlet.http.Cookie which is required on the producer side in order to be served from some of our ServletWrappers. The second is the org.apache.http.cookie.SetCookie2 which is used by the Apache HttpComponents used to connect to the client from the producer. We often need to use these cookie types at different times and casting the cookies from one format to another is confusing. <p/> 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.

See Also:
Serialized Form

Constructor Summary
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(java.lang.String name, java.lang.String value)
          Creates a new Cookie using a name and value pair

 

Method Summary
 java.lang.Object clone()
           
 boolean equals(java.lang.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.
 java.lang.String getCommentURL()
          Returns the comment URL.
 java.util.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.
 java.lang.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(java.util.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(java.io.ObjectInput in)
          Reads the CookieWrapper from the input stream.
 void setCommentURL(java.lang.String commentURL)
          Sets the comment URL
 void setDiscard(boolean discard)
          Set the Discard attribute.
 void setExpiryDate(java.util.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.
 java.lang.String toString()
           
 void writeExternal(java.io.ObjectOutput out)
          Writes the object to the output stream.

 

Methods inherited from class javax.servlet.http.Cookie
getComment, getDomain, getPath, getSecure, getValue, getVersion, setComment, setDomain, setPath, setValue, setVersion

 

Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait

 

Methods inherited from interface org.apache.http.cookie.SetCookie
setComment, setDomain, setPath, setValue, setVersion

 

Methods inherited from interface org.apache.http.cookie.Cookie
getComment, getDomain, getPath, getValue, getVersion

 

Constructor Detail

CookieWrapper

public CookieWrapper()

CookieWrapper

public CookieWrapper(java.lang.String name,
                     java.lang.String value)
Creates a new Cookie using a name and value pair
Parameters:
name -
value -

CookieWrapper

public CookieWrapper(javax.servlet.http.Cookie cookie)
Creates a new CookieWrapper based on a javax.servlet.http.Cookie.
Parameters:
cookie -

CookieWrapper

public CookieWrapper(CookieWrapper cookie)
This is a copy constructor which creates a new CookieWrapper based on another CookieWrapper.
Parameters:
cookie -

CookieWrapper

public CookieWrapper(org.apache.http.cookie.Cookie cookie)
Creates a new CookieWrapper based on org.apache.http.cookie
Parameters:
cookie -

Method Detail

getName

public java.lang.String getName()
Returns the name of the cookie.
Specified by:
getName in interface org.apache.http.cookie.Cookie
Overrides:
getName in class javax.servlet.http.Cookie
Returns:
the name of the cookie

setCommentURL

public void setCommentURL(java.lang.String commentURL)
Sets the comment URL
Specified by:
setCommentURL in interface org.apache.http.cookie.SetCookie2
Parameters:
commentURL -

getCommentURL

public java.lang.String getCommentURL()
Returns the comment URL.
Specified by:
getCommentURL in interface org.apache.http.cookie.Cookie
Returns:

setMaxAge

public void setMaxAge(int expiry)
Sets the cookie's max age in seconds ala the javax.servlet.http.Cookie spec. If the value specified is less then zero, this will be treated as a session cookie and the getExpiryDate method will also be set to return null. <p/> If the expiry is greater then zero, then the ExpiryDate will be computed from the current System time and saved accordingly. <p/> 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.
Overrides:
setMaxAge in class javax.servlet.http.Cookie
Parameters:
expiry -

getMaxAge

public int getMaxAge()
Computes the max age of this cookie based on the ExpiryDate compared to the local time. If ExpiryDate is null, then the value returned will be -1. If the ExpiryDate has already passed, then the value returned will be 0.
Overrides:
getMaxAge in class javax.servlet.http.Cookie
Returns:

setExpiryDate

public void setExpiryDate(java.util.Date expiryDate)
Sets the expiration Date of the cookie.
Specified by:
setExpiryDate in interface org.apache.http.cookie.SetCookie
Parameters:
expiryDate - the Date or null is this cookie has no expiration.

getExpiryDate

public java.util.Date getExpiryDate()
Returns the expiration Date of the cookie, or null if none exists.
Specified by:
getExpiryDate in interface org.apache.http.cookie.Cookie
Returns:
Expiration Date or null

isPersistent

public boolean isPersistent()
Returns false if the cookie should be discarded at the end of the "session"; true otherwise.
Specified by:
isPersistent in interface org.apache.http.cookie.Cookie
Returns:
a boolean whether this cookie should be persisted or not.

setPorts

public void setPorts(int[] ports)
Sets the Port attribute. It restricts the ports to which a cookie may be returned in a Cookie request header.
Specified by:
setPorts in interface org.apache.http.cookie.SetCookie2
Parameters:
ports -

getPorts

public int[] getPorts()
Get the Port attribute. It restricts the ports to which a cookie may be returned in a Cookie request header.
Specified by:
getPorts in interface org.apache.http.cookie.Cookie
Returns:
an array of ports

setSecure

public void setSecure(boolean secure)
Sets whether this cookie requires a secure connection. This is almost always needed when the cookie contains "secure" information.
Specified by:
setSecure in interface org.apache.http.cookie.SetCookie
Overrides:
setSecure in class javax.servlet.http.Cookie
Parameters:
secure -

setDiscard

public void setDiscard(boolean discard)
Set the Discard attribute. <p/> Note: Discard attribute overrides Max-age.
Specified by:
setDiscard in interface org.apache.http.cookie.SetCookie2
Parameters:
discard -

isSecure

public boolean isSecure()
Indicates whether this cookie requires a secure connection.
Specified by:
isSecure in interface org.apache.http.cookie.Cookie
Returns:
true if this cookie should only be sent over secure connections, false otherwise.

isExpired

public boolean isExpired(java.util.Date date)
Returns true if this cookie is expired as of the procided date.
Specified by:
isExpired in interface org.apache.http.cookie.Cookie
Parameters:
date - Current time
Returns:
true if the cookie has expired.
Throws:
java.lang.IllegalArgumentException - is Date is null

hashCode

public int hashCode()
Returns a hashcode based on name and value.
Overrides:
hashCode in class java.lang.Object
Returns:

equals

public boolean equals(java.lang.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. There are items like comments and such which may differ on functionally equivalent cookies.
Overrides:
equals in class java.lang.Object
Parameters:
object -
Returns:

clone

public java.lang.Object clone()
Overrides:
clone in class javax.servlet.http.Cookie

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Writes the object to the output stream. This is needed because the base cookie object is not serializable NOR does it have a default constructor. As such, standard serialization will not work. This method will ensure all fields are sent over the wire, including those from the parent class.
Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
out - the ObjectOutput object
Throws:
java.io.IOException - if something goes wrong

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Reads the CookieWrapper from the input stream. This is needed because the base cookie object is not serializable NOR does it have a default constructor. As such, the base serialization needs to be done manually. This method will ensurte all field are received over the wire and set on the class, including those from the parent class.
Specified by:
readExternal in interface java.io.Externalizable
Parameters:
in - the ObjectInput
Throws:
java.io.IOException - if something goes wrong with the IO
java.lang.ClassNotFoundException - if we have trouble recieving an object member field.

Skip navigation links

Oracle© Fusion Middleware Java API Reference for Oracle ADF Faces
11g Release 1 (11.1.1.7.0)
E10684-08


Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.