KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > httpclient > methods > UrlGetMethod


1 /*
2  * $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/Attic/UrlGetMethod.java,v 1.12.2.1 2004/02/22 18:21:15 olegk Exp $
3  * $Revision: 1.12.2.1 $
4  * $Date: 2004/02/22 18:21:15 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2004 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  * ====================================================================
22  *
23  * This software consists of voluntary contributions made by many
24  * individuals on behalf of the Apache Software Foundation. For more
25  * information on the Apache Software Foundation, please see
26  * <http://www.apache.org/>.
27  *
28  * [Additional notices, if required by prior licensing conditions]
29  *
30  */

31
32 package org.apache.commons.httpclient.methods;
33
34 import org.apache.commons.httpclient.HttpUrlMethod;
35 import org.apache.commons.httpclient.util.URIUtil;
36
37 import java.io.File JavaDoc;
38 import java.net.MalformedURLException JavaDoc;
39
40 /**
41  * Implements the URL version of GetMethod. It serves the
42  * same purpose as GetMethod but it takes URL instead of
43  * a path.
44  *
45  * @deprecated use GetMethod
46  *
47  * @author Marc A. Saegesser
48  * @author <a HREF="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
49  */

50 public class UrlGetMethod extends GetMethod implements HttpUrlMethod {
51     // ----------------------------------------------------- Instance Variables
52
/** The URL */
53     private String JavaDoc url;
54
55     /**
56      * No-arg constructor.
57      */

58     public UrlGetMethod() {
59         super();
60     }
61
62     /**
63      * Create an instance with the specified URL
64      * @param url The URL
65      * @throws MalformedURLException If the url isn't valid.
66      */

67     public UrlGetMethod(String JavaDoc url) throws MalformedURLException JavaDoc {
68         super(URIUtil.getPath(url));
69         setUrl(url);
70     }
71
72     /**
73      * Create an instance with the specified URL and temporary directory.
74      * @param url The URL
75      * @param tempDir The temporary directory
76      * @throws MalformedURLException If the url isn't valid.
77      */

78     public UrlGetMethod(String JavaDoc url, String JavaDoc tempDir) throws MalformedURLException JavaDoc {
79         super(URIUtil.getPath(url), tempDir);
80         setUrl(url);
81     }
82
83     /**
84      * Constructor.
85      * @param url the path of the request
86      * @param tempDir the directory in which to store temporary files
87      * @param tempFile the file (under tempDir) to buffer contents to
88      * @throws MalformedURLException If the url isn't valid.
89      */

90     public UrlGetMethod(String JavaDoc url, String JavaDoc tempDir, String JavaDoc tempFile)
91         throws MalformedURLException JavaDoc {
92         super(URIUtil.getPath(url), tempDir, tempFile);
93         setUrl(url);
94     }
95
96     /**
97      * Constructor.
98      * @param url the path of the request
99      * @param fileData the file to buffer contents to
100      * @throws MalformedURLException If the url isn't valid.
101      */

102     public UrlGetMethod(String JavaDoc url, File JavaDoc fileData)
103         throws MalformedURLException JavaDoc {
104         super(URIUtil.getPath(url), fileData);
105         setUrl(url);
106     }
107
108     /**
109      * Sets the URL. Calls the underlying HttpMethod.setPath()
110      * with the url's path. If the url contains a query string
111      * the underlying HttpMethod.setQueryString() is called.
112      *
113      * @param url - the URL for this request.
114      * @throws MalformedURLException If the url isn't valid.
115      */

116     public void setUrl(String JavaDoc url) throws MalformedURLException JavaDoc {
117         super.setPath(URIUtil.getPath(url));
118         this.url = url;
119         String JavaDoc query = URIUtil.getQuery(url);
120         if (query != null && query.length() > 0) {
121             super.setQueryString(query);
122         }
123     }
124
125     /**
126      * Returns this request's URL.
127      *
128      * @return the request's URL.
129      */

130     public String JavaDoc getUrl() {
131         return url;
132     }
133 }
134
Popular Tags