// Copyright 2014 Boundary, Inc.
//
// 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.boundary.camel.component.url;

import java.net.URL;

import com.boundary.camel.component.common.ServiceResult;
import static com.boundary.camel.component.url.UrlStatus.*;

public class UrlResult extends ServiceResult {
	
	private UrlStatus urlStatus;
	private URL url;
	private long responseTime;
	private int responseCode;
	private String responseBody;
	private String requestMethod;


	UrlResult() {
		urlStatus = OK;
	}

	public void setURLStatus(UrlStatus urlStatus) {
		this.urlStatus = urlStatus;
	}
	
	public UrlStatus getURLStatus() {
		return this.urlStatus;
	}
	
	public void setURL(URL url) {
		this.url = url;
	}
	
	public URL getURL() {
		return url;
	}

	public String toString() {
		StringBuffer s = new StringBuffer();
		s.append(",url=" + getURL());
		s.append(",timeout=" + getTimeout());
		s.append(",urlStatus=" + (getURLStatus() == null ? "" : getURLStatus().toString()));
		
		return s.toString();
	}

	public long getResponseTime() {
		return responseTime;
	}

	public void setResponseTime(long responseTime) {
		this.responseTime = responseTime;
	}

	public String getResponseBody() {
		return responseBody;
	}

	public void setResponseBody(String responseBody) {
		this.responseBody = responseBody;
	}

	public int getResponseCode() {
		return responseCode;
	}

	public void setResponseCode(int responseCode) {
		this.responseCode = responseCode;
	}
	
	public String getRequestMethod() {
		return requestMethod;
	}

	public void setRequestMethod(String requestMethod) {
		this.requestMethod = requestMethod;
	}
}

@@ -1268,264 +1268,8 @@
 %09%7D%0A%0A
-%09public String toString() %7B%0A%09%09StringBuffer s = new StringBuffer();%0A%09%09s.append(%22,url=%22 + getURL());%0A%09%09s.append(%22,timeout=%22 + getTimeout());%0A%09%09s.append(%22,urlStatus=%22 + (getURLStatus() == null ? %22%22 : getURLStatus().toString()));%0A%09%09%0A%09%09return s.toString();%0A%09%7D%0A%0A
 %09pub
@@ -1875,11 +1875,277 @@
 thod;%0A%09%7D
+%0A%0A%09@Override%0A%09public String toString() %7B%0A%09%09return %22UrlResult %5BurlStatus=%22 + urlStatus + %22, url=%22 + url%0A%09%09%09%09+ %22, responseTime=%22 + responseTime + %22, responseCode=%22%0A%09%09%09%09+ responseCode + %22, responseBody=%22 + responseBody%0A%09%09%09%09+ %22, requestMethod=%22 + requestMethod + %22%5D%22;%0A%09%7D
 %0A%7D%0A

Update toString() method with new fields