001: /*
002: * $Header$
003: * $Revision: 3848 $
004: * $Date: 2005-09-28 02:29:22 +0000 (Wed, 28 Sep 2005) $
005: *
006: * ====================================================================
007: *
008: * Copyright 2002-2004 The Apache Software Foundation
009: *
010: * Licensed under the Apache License, Version 2.0 (the "License");
011: * you may not use this file except in compliance with the License.
012: * You may obtain a copy of the License at
013: *
014: * http://www.apache.org/licenses/LICENSE-2.0
015: *
016: * Unless required by applicable law or agreed to in writing, software
017: * distributed under the License is distributed on an "AS IS" BASIS,
018: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
019: * See the License for the specific language governing permissions and
020: * limitations under the License.
021: * ====================================================================
022: *
023: * This software consists of voluntary contributions made by many
024: * individuals on behalf of the Apache Software Foundation. For more
025: * information on the Apache Software Foundation, please see
026: * <http://www.apache.org/>.
027: *
028: */
029:
030: package org.apache.commons.httpclient.cookie;
031:
032: import java.util.Collection;
033: import java.util.SortedMap;
034:
035: import org.apache.commons.httpclient.Cookie;
036: import org.apache.commons.httpclient.Header;
037: import org.apache.commons.httpclient.NameValuePair;
038:
039: /**
040: * A cookie spec that does nothing. Cookies are neither parsed, formatted nor matched.
041: * It can be used to effectively disable cookies altogether.
042: *
043: * @since 3.0
044: */
045: public class IgnoreCookiesSpec implements CookieSpec {
046: private static final Cookie[] NO_COOKIES = new Cookie[0];
047:
048: /**
049: *
050: */
051: public IgnoreCookiesSpec() {
052: super ();
053: }
054:
055: /**
056: * Returns an empty {@link Cookie cookie} array. All parameters are ignored.
057: */
058: public Cookie[] parse(String host, int port, String path,
059: boolean secure, String header)
060: throws MalformedCookieException {
061: return NO_COOKIES;
062: }
063:
064: /**
065: * @return <code>null</code>
066: */
067: public Collection getValidDateFormats() {
068: return null;
069: }
070:
071: /**
072: * Does nothing.
073: */
074: public void setValidDateFormats(Collection datepatterns) {
075: }
076:
077: /**
078: * @return <code>null</code>
079: */
080: public String formatCookie(Cookie cookie) {
081: return null;
082: }
083:
084: /**
085: * @return <code>null</code>
086: */
087: public Header formatCookieHeader(Cookie cookie)
088: throws IllegalArgumentException {
089: return null;
090: }
091:
092: /**
093: * @return <code>null</code>
094: */
095: public Header formatCookieHeader(Cookie[] cookies)
096: throws IllegalArgumentException {
097: return null;
098: }
099:
100: /**
101: * @return <code>null</code>
102: */
103: public String formatCookies(Cookie[] cookies)
104: throws IllegalArgumentException {
105: return null;
106: }
107:
108: /**
109: * @return <code>false</code>
110: */
111: public boolean match(String host, int port, String path,
112: boolean secure, Cookie cookie) {
113: return false;
114: }
115:
116: /**
117: * Returns an empty {@link Cookie cookie} array. All parameters are ignored.
118: */
119: public Cookie[] match(String host, int port, String path,
120: boolean secure, Cookie[] cookies) {
121: return NO_COOKIES;
122: }
123:
124: /**
125: * Returns an empty {@link Cookie cookie} array. All parameters are ignored.
126: */
127: public Cookie[] parse(String host, int port, String path,
128: boolean secure, Header header)
129: throws MalformedCookieException, IllegalArgumentException {
130: return NO_COOKIES;
131: }
132:
133: /**
134: * Does nothing.
135: */
136: public void parseAttribute(NameValuePair attribute, Cookie cookie)
137: throws MalformedCookieException, IllegalArgumentException {
138: }
139:
140: /**
141: * Does nothing.
142: */
143: public void validate(String host, int port, String path,
144: boolean secure, Cookie cookie)
145: throws MalformedCookieException, IllegalArgumentException {
146: }
147:
148: /**
149: * @return <code>false</code>
150: */
151: public boolean domainMatch(final String host, final String domain) {
152: return false;
153: }
154:
155: /**
156: * @return <code>false</code>
157: */
158: public boolean pathMatch(final String path, final String topmostPath) {
159: return false;
160: }
161:
162: public Cookie[] match(String domain, int port, String path,
163: boolean secure, SortedMap cookiesMap) {
164: return NO_COOKIES;
165: }
166: }
|