/* * Copyright (c) 2005-2010 Clark & Parsia, LLC. <http://www.clarkparsia.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.complexible.common.web; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; /** * <p>Simple implementation of the {@link HttpResource} interface.</p> * * @author Michael Grove * @since 1.0 */ @Deprecated public class HttpResourceImpl implements HttpResource { private URL mURL; public HttpResourceImpl(final URL theBaseURL) { mURL = theBaseURL; // TODO: does this need to be an interface? seems like overkill. } /** * @inheritDoc */ public HttpResource resource(final String theName) { try { return new HttpResourceImpl(new URL(mURL.toString() + (mURL.toString().endsWith("/") ? "" : "/") + theName));// + (theName.endsWith("/") ? "" : "/"))); } catch (MalformedURLException e) { throw new IllegalArgumentException(e); } } /** * @inheritDoc */ public Response delete() throws IOException { return initDelete().execute(); } /** * @inheritDoc */ public Response get() throws IOException { return initGet().execute(); } /** * @inheritDoc */ public Request initGet() { return new Request(Method.GET, mURL); } /** * @inheritDoc */ public Request initPost() { return new Request(Method.POST, mURL); } /** * @inheritDoc */ public Request initPut() { return new Request(Method.PUT, mURL); } /** * @inheritDoc */ public Request initDelete() { return new Request(Method.DELETE, mURL); } /** * @inheritDoc */ public Request initRequest(Method theMethod) { return new Request(theMethod, mURL); } /** * @inheritDoc */ public URL url() { return mURL; } }