package org.jerrymouse.cc.site.view.display;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;

import org.jerrymouse.cc.site.web.utils.WebUtil;

public class DisplayResult {
	private Object entity;
	private String type;

	public DisplayResult() {
	}

	/**
	 * html
	 * 
	 * @param html
	 */
	public DisplayResult(Object entity) {
		super();
		this.entity = entity;
		type = MediaType.TEXT_HTML;
	}

	public DisplayResult(Object entity, String type) {
		super();
		this.entity = entity;
		this.type = type;
	}

	public Object getEntity() {
		return entity;
	}

	public void setEntity(Object entity) {
		this.entity = entity;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public ResponseBuilder createResponse() {
		ResponseBuilder responseBuilder = Response.ok(entity);
		responseBuilder.type(type);
		responseBuilder.header(WebUtil.CONTENTDISPOSITION, WebUtil.INLINE);
		return responseBuilder;
	}
}
