View Javadoc

1   /*
2    * $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/oac.hc3x/trunk/src/java/org/apache/commons/httpclient/cookie/IgnoreCookiesSpec.java $
3    * $Revision: 1425331 $
4    * $Date: 2012-12-22 18:29:41 +0000 (Sat, 22 Dec 2012) $
5    *
6    * ====================================================================
7    *
8    *  Licensed to the Apache Software Foundation (ASF) under one or more
9    *  contributor license agreements.  See the NOTICE file distributed with
10   *  this work for additional information regarding copyright ownership.
11   *  The ASF licenses this file to You under the Apache License, Version 2.0
12   *  (the "License"); you may not use this file except in compliance with
13   *  the License.  You may obtain a copy of the License at
14   *
15   *      http://www.apache.org/licenses/LICENSE-2.0
16   *
17   *  Unless required by applicable law or agreed to in writing, software
18   *  distributed under the License is distributed on an "AS IS" BASIS,
19   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20   *  See the License for the specific language governing permissions and
21   *  limitations under the License.
22   * ====================================================================
23   *
24   * This software consists of voluntary contributions made by many
25   * individuals on behalf of the Apache Software Foundation.  For more
26   * information on the Apache Software Foundation, please see
27   * <http://www.apache.org/>.
28   *
29   */ 
30  
31  package org.apache.commons.httpclient.cookie;
32  
33  import java.util.Collection;
34  
35  import org.apache.commons.httpclient.Cookie;
36  import org.apache.commons.httpclient.Header;
37  import org.apache.commons.httpclient.NameValuePair;
38  
39  /***
40   * A cookie spec that does nothing.  Cookies are neither parsed, formatted nor matched.
41   * It can be used to effectively disable cookies altogether. 
42   * 
43   * @since 3.0
44   */
45  public class IgnoreCookiesSpec implements CookieSpec {
46  
47      /***
48       * 
49       */
50      public IgnoreCookiesSpec() {
51          super();
52      }
53  
54      /***
55       * Returns an empty {@link Cookie cookie} array.  All parameters are ignored.
56       */
57      public Cookie[] parse(String host, int port, String path, boolean secure, String header)
58          throws MalformedCookieException {
59          return new Cookie[0];
60      }
61  
62      /***
63       * @return <code>null</code>
64       */
65  	public Collection getValidDateFormats() {
66  		return null;
67  	}
68  	
69      /***
70       * Does nothing.
71       */
72  	public void setValidDateFormats(Collection datepatterns) {
73  	}
74  	
75      /***
76       * @return <code>null</code>
77       */
78      public String formatCookie(Cookie cookie) {
79          return null;
80      }
81  
82      /***
83       * @return <code>null</code>
84       */
85      public Header formatCookieHeader(Cookie cookie) throws IllegalArgumentException {
86          return null;
87      }
88  
89      /***
90       * @return <code>null</code>
91       */
92      public Header formatCookieHeader(Cookie[] cookies) throws IllegalArgumentException {
93          return null;
94      }
95  
96      /***
97       * @return <code>null</code>
98       */
99      public String formatCookies(Cookie[] cookies) throws IllegalArgumentException {
100         return null;
101     }
102 
103     /***
104      * @return <code>false</code>
105      */
106     public boolean match(String host, int port, String path, boolean secure, Cookie cookie) {
107         return false;
108     }
109 
110     /***
111      * Returns an empty {@link Cookie cookie} array.  All parameters are ignored.
112      */
113     public Cookie[] match(String host, int port, String path, boolean secure, Cookie[] cookies) {
114         return new Cookie[0];
115     }
116 
117     /***
118      * Returns an empty {@link Cookie cookie} array.  All parameters are ignored.
119      */
120     public Cookie[] parse(String host, int port, String path, boolean secure, Header header)
121         throws MalformedCookieException, IllegalArgumentException {
122         return new Cookie[0];
123     }
124 
125     /***
126      * Does nothing.
127      */
128     public void parseAttribute(NameValuePair attribute, Cookie cookie)
129         throws MalformedCookieException, IllegalArgumentException {
130     }
131 
132     /***
133      * Does nothing.
134      */
135     public void validate(String host, int port, String path, boolean secure, Cookie cookie)
136         throws MalformedCookieException, IllegalArgumentException {
137     }
138 
139     /***
140      * @return <code>false</code>
141      */
142     public boolean domainMatch(final String host, final String domain) {
143         return false;
144     }
145 
146     /***
147      * @return <code>false</code>
148      */
149     public boolean pathMatch(final String path, final String topmostPath) {
150         return false;
151     }
152 
153 }