The implementations of HttpUrlMethod (UrlGetMethod, UrlPostMethod, ...)
already extend their HttpMethod counterparts (GetMethod, PostMethod) so they
would not be able to also extend HttpUrlMethodBase.  If you wanted to extend
HttpUrlMethodBase then you'd have to duplicate any request specific code in
both classes and that would be a maintenance nightmare.  It is far safer to
duplicate the simple getUrl()/setUrl() methods.


Marc Saegesser 

> -----Original Message-----
> From: Davis, Caleb [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, March 05, 2002 8:53 AM
> To: '[EMAIL PROTECTED]'
> Subject: [httpclient] Why no HttpUrlMethodBase?
> 
> 
> I've noticed that there's a set of methods now in httpclient called
> 'Url<METHODNAME>Method', which seem to implement 
> HttpMultiClient compatible
> methods.
> 
> These seem to all have the same boilerplate code in them for 
> setting and
> getting the url, and passing on the path information to the 
> super class.
> 
> From the perspective of someone who might be implementing several new
> UrlMethods, I'm thinking about a new abstract class as an 
> analog to the
> HttpClient's HttpMethodBase - the HttpUrlMethodBase. It might 
> look something
> like this:
> 
>       package org.apache.commons.httpclient;
> 
>       import java.net.URL;
>       import java.net.MalformedURLException;
> 
>       public abstract class HttpUrlMethodBase
>               extends HttpMethodBase
>               implements HttpUrlMethod {
> 
>               private URL _url;
>       
>               public HttpUrlMethodBase() {
>                       super();
>               }
> 
>               public HttpUrlMethodBase(String url) throws
> MalformedURLException {               
>                       super(URIUtil.getPath(url));
>                       _url = new URL(url);
>               }
> 
>               public void setUrl(String url) throws 
> MalformedURLException
> {
>                       _url = new URL(url);
>               }
> 
>               public String getUrl() {
>                       return _url.toExternalForm();
>               }
> 
>               public abstract String getName();
>       }
> 
> A new HttpUrlMethod would only have extend HttpUrlMethodBase 
> and override
> getName, to be functional, in the same fashion as a new 
> HttpMethod only has
> to extend HttpMethodBase and override getName. Does this 
> sound reasonable
> and/or useful to anyone but myself?
> 
>       -Caleb
> 
> --
> To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> 

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to