View Javadoc

1   /*
2    * $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/Attic/UrlPostMethod.java,v 1.11.2.1 2004/02/22 18:21:15 olegk Exp $
3    * $Revision: 1.11.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.net.MalformedURLException;
38  
39  /***
40   * HttpUrlMethod version of PostMethod.
41   *
42   * @deprecated use PostMethod
43   *
44   * @author Marc A. Saegesser
45   * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
46   */
47  public class UrlPostMethod extends PostMethod implements HttpUrlMethod {
48      // ----------------------------------------------------- Instance Variables
49      /*** The URL */
50      private String url;
51  
52      /***
53       * No-arg constructor.
54       */
55      public UrlPostMethod() {
56          super();
57      }
58  
59      /***
60       * Path-setting constructor.
61       * @param url the URL to request
62       * @throws MalformedURLException If the url isn't valid.
63       */
64      public UrlPostMethod(String url) throws MalformedURLException {
65          super(URIUtil.getPath(url));
66          setUrl(url);
67      }
68  
69      /***
70       * Constructor.
71       * @param url the URL to request
72       * @param tempDir directory to store temp files in
73       * @throws MalformedURLException If the url isn't valid.
74       */
75      public UrlPostMethod(String url, String tempDir) throws MalformedURLException {
76          super(URIUtil.getPath(url), tempDir);
77          setUrl(url);
78      }
79  
80      /***
81       * Constructor.
82       * @param url the URL to request
83       * @param tempDir directory to store temp files in
84       * @param tempFile file to store temporary data in
85       * @throws MalformedURLException If the url isn't valid.
86       */
87      public UrlPostMethod(String url, String tempDir, String tempFile) 
88          throws MalformedURLException {
89          super(URIUtil.getPath(url), tempDir, tempFile);
90          setUrl(url);
91      }
92  
93      /***
94       * Sets the URL.  Calls the underlying HttpMethod.setPath()
95       * with the url's path.  If the url contains a query string
96       * the underlying HttpMethod.setQueryString() is called.
97       *
98       * @param url - the URL for this request.
99       * @throws MalformedURLException If the url isn't valid.
100      */
101     public void setUrl(String url) throws MalformedURLException {
102         super.setPath(URIUtil.getPath(url));
103         this.url = url;
104         String query = URIUtil.getQuery(url);
105         if (query != null && query.length() > 0) {
106             super.setQueryString(query);
107         }
108     }
109 
110     /***
111      * Returns this request's URL.
112      * 
113      * @return the request's URL.
114      */
115     public String getUrl() {
116         return url;
117     }
118 }
119