package org.bench4q.recorder.httpcapture;

import java.util.Vector;

public class Action {
	private String url;
	private String method;
	private String expected_result;
	private int delayTime;
	private int expected_size;
	private int timeout;
	private Vector<HeaderValue> headers;
	private Vector<Param> queryStringParams;
	private Vector<Param> bodyParams;
	private String multiPartData;

	public Action() {
		this.headers = new Vector<HeaderValue>();
		this.queryStringParams = new Vector<Param>();
		this.bodyParams = new Vector<Param>();
		this.expected_result = "";
		this.multiPartData = "";
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getUrl() {
		return this.url;
	}

	public void setMethod(String method) {
		this.method = method;
	}

	public String getMethod() {
		return this.method;
	}

	public void setExpectedResult(String str) {
		this.expected_result = str;
	}

	public String getExpectedResult() {
		return this.expected_result;
	}

	public void setDelayTime(int seconds) {
		this.delayTime = seconds;
	}

	public int getDelayTime() {
		return this.delayTime;
	}

	public void setExpectedSize(int bytes) {
		this.expected_size = bytes;
	}

	public int getExpectedSize() {
		return this.expected_size;
	}

	public void setTimeout(int seconds) {
		this.timeout = seconds;
	}

	public int getTimeout() {
		return this.timeout;
	}

	public int getHeaderCount() {
		return this.headers.size();
	}

	public HeaderValue[] getHeaders() {
		HeaderValue[] list = new HeaderValue[this.headers.size()];
		this.headers.copyInto(list);
		return list;
	}

	public void addHeader(HeaderValue p) {
		this.headers.addElement(p);
	}

	public void removeHeader(HeaderValue p) {
		this.headers.removeElement(p);
	}

	public int getParamsCount() {
		return getParams().length;
	}

	public int getQueryStringParamCount() {
		return this.queryStringParams.size();
	}

	public int getBodyParamCount() {
		return this.bodyParams.size();
	}

	public Param[] getQueryStringParams() {
		Param[] list = new Param[this.queryStringParams.size()];
		this.queryStringParams.copyInto(list);
		return list;
	}

	public Param[] getBodyParams() {
		Param[] list = new Param[this.bodyParams.size()];
		this.bodyParams.copyInto(list);
		return list;
	}

	public Param[] getParams() {
		@SuppressWarnings("unchecked")
		Vector<Param> v = (Vector<Param>) this.queryStringParams.clone();
		v.addAll(this.bodyParams);
		Param[] list = new Param[v.size()];
		v.copyInto(list);
		return list;
	}

	public void addQueryStringParam(Param p) {
		this.queryStringParams.addElement(p);
	}

	public void addBodyParam(Param p) {
		this.bodyParams.addElement(p);
	}

	public void removeQueryStringParam(Param p) {
		this.queryStringParams.removeElement(p);
	}

	public void removeBodyParam(Param p) {
		this.bodyParams.removeElement(p);
	}

	public void setMultiPartData(String multiPartData) {
		this.multiPartData = multiPartData;
	}

	public String getMultiPartData() {
		return this.multiPartData;
	}
}
