org.apache.commons.httpclient.cookie
Class IgnoreCookiesSpec

java.lang.Object
  extended by org.apache.commons.httpclient.cookie.IgnoreCookiesSpec
All Implemented Interfaces:
CookieSpec

public class IgnoreCookiesSpec
extends Object
implements CookieSpec

A cookie spec that does nothing. Cookies are neither parsed, formatted nor matched. It can be used to effectively disable cookies altogether.

Since:
3.0

Field Summary
 
Fields inherited from interface org.apache.commons.httpclient.cookie.CookieSpec
PATH_DELIM, PATH_DELIM_CHAR
 
Constructor Summary
IgnoreCookiesSpec()
           
 
Method Summary
 boolean domainMatch(String host, String domain)
          Performs domain-match as defined by the cookie specification.
 String formatCookie(Cookie cookie)
          Create a "Cookie" header value for an array of cookies.
 Header formatCookieHeader(Cookie cookie)
          Create a "Cookie" Header for single Cookie.
 Header formatCookieHeader(Cookie[] cookies)
          Create a "Cookie" Header for an array of Cookies.
 String formatCookies(Cookie[] cookies)
          Create a "Cookie" header value for an array of cookies.
 Collection getValidDateFormats()
          Returns the Collection of date patterns used for parsing.
 boolean match(String host, int port, String path, boolean secure, Cookie cookie)
          Determines if a Cookie matches a location.
 Cookie[] match(String host, int port, String path, boolean secure, Cookie[] cookies)
          Returns an empty cookie array.
 Cookie[] parse(String host, int port, String path, boolean secure, Header header)
          Returns an empty cookie array.
 Cookie[] parse(String host, int port, String path, boolean secure, String header)
          Returns an empty cookie array.
 void parseAttribute(NameValuePair attribute, Cookie cookie)
          Does nothing.
 boolean pathMatch(String path, String topmostPath)
          Performs path-match as defined by the cookie specification.
 void setValidDateFormats(Collection datepatterns)
          Does nothing.
 void validate(String host, int port, String path, boolean secure, Cookie cookie)
          Does nothing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IgnoreCookiesSpec

public IgnoreCookiesSpec()
Method Detail

parse

public Cookie[] parse(String host,
                      int port,
                      String path,
                      boolean secure,
                      String header)
               throws MalformedCookieException
Returns an empty cookie array. All parameters are ignored.

Specified by:
parse in interface CookieSpec
Parameters:
host - the host which sent the Set-Cookie header
port - the port which sent the Set-Cookie header
path - the path which sent the Set-Cookie header
secure - true when the Set-Cookie header was received over secure conection
header - the Set-Cookie received from the server
Returns:
an array of Cookies parsed from the Set-Cookie value
Throws:
MalformedCookieException - if an exception occurs during parsing
See Also:
CookieSpec.validate(String, int, String, boolean, Cookie)

getValidDateFormats

public Collection getValidDateFormats()
Description copied from interface: CookieSpec
Returns the Collection of date patterns used for parsing. The String patterns are compatible with the SimpleDateFormat.

Specified by:
getValidDateFormats in interface CookieSpec
Returns:
null

setValidDateFormats

public void setValidDateFormats(Collection datepatterns)
Does nothing.

Specified by:
setValidDateFormats in interface CookieSpec
Parameters:
datepatterns - collection of date patterns

formatCookie

public String formatCookie(Cookie cookie)
Description copied from interface: CookieSpec
Create a "Cookie" header value for an array of cookies.

Specified by:
formatCookie in interface CookieSpec
Parameters:
cookie - the cookie to be formatted as string
Returns:
null

formatCookieHeader

public Header formatCookieHeader(Cookie cookie)
                          throws IllegalArgumentException
Description copied from interface: CookieSpec
Create a "Cookie" Header for single Cookie.

Specified by:
formatCookieHeader in interface CookieSpec
Parameters:
cookie - the Cookie format as a Cookie header
Returns:
null
Throws:
IllegalArgumentException - if an input parameter is illegal

formatCookieHeader

public Header formatCookieHeader(Cookie[] cookies)
                          throws IllegalArgumentException
Description copied from interface: CookieSpec
Create a "Cookie" Header for an array of Cookies.

Specified by:
formatCookieHeader in interface CookieSpec
Parameters:
cookies - the Cookies format into a Cookie header
Returns:
null
Throws:
IllegalArgumentException - if an input parameter is illegal

formatCookies

public String formatCookies(Cookie[] cookies)
                     throws IllegalArgumentException
Description copied from interface: CookieSpec
Create a "Cookie" header value for an array of cookies.

Specified by:
formatCookies in interface CookieSpec
Parameters:
cookies - the Cookies to be formatted
Returns:
null
Throws:
IllegalArgumentException - if an input parameter is illegal

match

public boolean match(String host,
                     int port,
                     String path,
                     boolean secure,
                     Cookie cookie)
Description copied from interface: CookieSpec
Determines if a Cookie matches a location.

Specified by:
match in interface CookieSpec
Parameters:
host - the host to which the request is being submitted
port - the port to which the request is being submitted
path - the path to which the request is being submitted
secure - true if the request is using a secure connection
cookie - the Cookie to be matched
Returns:
false

match

public Cookie[] match(String host,
                      int port,
                      String path,
                      boolean secure,
                      Cookie[] cookies)
Returns an empty cookie array. All parameters are ignored.

Specified by:
match in interface CookieSpec
Parameters:
host - the host to which the request is being submitted
port - the port to which the request is being submitted (currenlty ignored)
path - the path to which the request is being submitted
secure - true if the request is using a secure protocol
cookies - an array of Cookies to be matched
Returns:
true if the cookie should be submitted with a request with given attributes, false otherwise.

parse

public Cookie[] parse(String host,
                      int port,
                      String path,
                      boolean secure,
                      Header header)
               throws MalformedCookieException,
                      IllegalArgumentException
Returns an empty cookie array. All parameters are ignored.

Specified by:
parse in interface CookieSpec
Parameters:
host - the host which sent the Set-Cookie header
port - the port which sent the Set-Cookie header
path - the path which sent the Set-Cookie header
secure - true when the Set-Cookie header was received over secure conection
header - the Set-Cookie received from the server
Returns:
an array of Cookies parsed from the header
Throws:
MalformedCookieException - if an exception occurs during parsing
IllegalArgumentException - if an input parameter is illegal
See Also:
CookieSpec.validate(String, int, String, boolean, Cookie)

parseAttribute

public void parseAttribute(NameValuePair attribute,
                           Cookie cookie)
                    throws MalformedCookieException,
                           IllegalArgumentException
Does nothing.

Specified by:
parseAttribute in interface CookieSpec
Parameters:
attribute - cookie attribute from the Set-Cookie
cookie - the to be updated
Throws:
MalformedCookieException - if an exception occurs during parsing
IllegalArgumentException - if an input parameter is illegal

validate

public void validate(String host,
                     int port,
                     String path,
                     boolean secure,
                     Cookie cookie)
              throws MalformedCookieException,
                     IllegalArgumentException
Does nothing.

Specified by:
validate in interface CookieSpec
Parameters:
host - the host from which the Cookie was received
port - the port from which the Cookie was received
path - the path from which the Cookie was received
secure - true when the Cookie was received using a secure connection
cookie - the Cookie to validate
Throws:
MalformedCookieException - if the cookie is invalid
IllegalArgumentException - if an input parameter is illegal

domainMatch

public boolean domainMatch(String host,
                           String domain)
Description copied from interface: CookieSpec
Performs domain-match as defined by the cookie specification.

Specified by:
domainMatch in interface CookieSpec
Parameters:
host - The target host.
domain - The cookie domain attribute.
Returns:
false

pathMatch

public boolean pathMatch(String path,
                         String topmostPath)
Description copied from interface: CookieSpec
Performs path-match as defined by the cookie specification.

Specified by:
pathMatch in interface CookieSpec
Parameters:
path - The target path.
topmostPath - The cookie path attribute.
Returns:
false


Copyright © 2001-2008 Apache Software Foundation. All Rights Reserved.