package eu.dnetlib.api.utils;

import org.dom4j.Document;
import org.dom4j.Node;

public class ResponseHeader {

	private String query;
	private String locale;
	private int page;
	private int pageSize;
	private int total;

	public String getQuery() {
		return query;
	}

	public void setQuery(final String query) {
		this.query = query;
	}

	public String getLocale() {
		return locale;
	}

	public void setLocale(final String locale) {
		this.locale = locale;
	}

	public int getPage() {
		return page;
	}

	public void setPage(final int page) {
		this.page = page;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(final int pageSize) {
		this.pageSize = pageSize;
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(final int total) {
		this.total = total;
	}

	public ResponseHeader() {
		super();
		// TODO Auto-generated constructor stub
	}

	public ResponseHeader(final String query, final String locale, final int page, final int pageSize, final int total) {
		super();
		this.query = query;
		this.locale = locale;
		this.page = page;
		this.pageSize = pageSize;
		this.total = total;
	}

	public ResponseHeader(final Document doc) {
		Node headerNode = doc.selectSingleNode("/response/header");
		this.query = headerNode.selectSingleNode("./query").getText();
		this.locale = headerNode.selectSingleNode("./locale").getText();
		this.page = Integer.parseInt(headerNode.selectSingleNode("./page").getText());
		this.pageSize = Integer.parseInt(headerNode.selectSingleNode("./size").getText());
		this.total = Integer.parseInt(headerNode.selectSingleNode("./total").getText());
	}
}
