KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > httpclient > cookie > CookieOrigin


1 /*
2  * $HeadURL:https://svn.apache.org/repos/asf/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/cookie/CookieOrigin.java $
3  * $Revision:400312 $
4  * $Date:2006-05-06 14:49:41 +0200 (Sat, 06 May 2006) $
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 package org.apache.commons.httpclient.cookie;
31
32 /**
33  * CookieOrigin class incapsulates details of an origin server that
34  * are relevant when parsing, validating or matching HTTP cookies.
35  *
36  * @author <a HREF="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
37  *
38  * @since 3.1
39  */

40 public final class CookieOrigin {
41
42     private final String JavaDoc host;
43     private final int port;
44     private final String JavaDoc path;
45     private final boolean secure;
46     
47     public CookieOrigin(final String JavaDoc host, int port, final String JavaDoc path, boolean secure) {
48         super();
49         if (host == null) {
50             throw new IllegalArgumentException JavaDoc(
51                     "Host of origin may not be null");
52         }
53         if (host.trim().equals("")) {
54             throw new IllegalArgumentException JavaDoc(
55                     "Host of origin may not be blank");
56         }
57         if (port < 0) {
58             throw new IllegalArgumentException JavaDoc("Invalid port: " + port);
59         }
60         if (path == null) {
61             throw new IllegalArgumentException JavaDoc(
62                     "Path of origin may not be null.");
63         }
64         this.host = host;
65         this.port = port;
66         this.path = path;
67         this.secure = secure;
68     }
69
70     public String JavaDoc getHost() {
71         return this.host;
72     }
73
74     public String JavaDoc getPath() {
75         return this.path;
76     }
77
78     public int getPort() {
79         return this.port;
80     }
81
82     public boolean isSecure() {
83         return this.secure;
84     }
85     
86 }
87
Popular Tags