You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Davis, Caleb" <CD...@rational.com> on 2002/03/05 15:52:40 UTC

[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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>