package com.fp.dto.query;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import com.fp.dto.Request;

/**
 * 
 * @author Jorge Vaca
 * @version 2.1
 */
public class QueryRequest extends Request {
	
	private static final long serialVersionUID = 1L;
	
	/**
	 * indica si la consulta se origina en una pagina jsf.
	 */
	private boolean jsf = false;
	
	/* (non-Javadoc)
	 * @see java.util.HashMap#get(java.lang.Object)
	 */
	@Override
	public Object get(Object key) {		
		return super.get(key);
	}

	/* (non-Javadoc)
	 * @see java.util.HashMap#put(java.lang.Object, java.lang.Object)
	 */
	@Override
	public Object put(String key, Object value) {
		if(key.compareTo("beans")==0){
			return value;
		}
		return super.put(key, value);
	}

	/**
	 * Entrega un map con los objetos de tipo QueryBean.
	 * @return Map<String,QueryBean>
	 */
	public Map<String, QueryBean> getBeans() {
		Map<String,QueryBean> beans=new HashMap<String, QueryBean>();
		Set<String> keys=super.keySet();
		for(String key:keys){
			Object obj=super.get(key);
			if(obj instanceof QueryBean){
				beans.put(key, (QueryBean)obj);
			}
		}
		return beans;
	}
	
	@Override
	public Set<java.util.Map.Entry<String, Object>> entrySet() {
		super.entrySet();
		super.remove("beans");
		return super.entrySetDefault();
	}

	/**
	 * Entrega el valor de: jsf
	 * @return boolean
	 */
	public boolean isJsf() {
		return jsf;
	}

	/**
	 * Fija el valor de: jsf 
	 * @param Valor a fijar en el atributo.
	 */
	public void setJsf(boolean jsf) {
		this.jsf = jsf;
	}


 
	
	
}
