/*
 * 
 * Created on Jun 4, 2005
 * 
 * György Süveges
 * Etixpert Kft.
 * Copyright(c) 2005
 * 
 */
package com.etixpert.evolution.gui.servlets.elements;

import javax.servlet.http.HttpSession;
import java.util.*;

/**
 * @author Suveges Gyorgy
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class MapSelect extends Select {
    protected Iterator it;
    protected Map values;
    /**
     * @param session
     * @param jspSite
     * @param key
     */
    public MapSelect(HttpSession session, String jspSite, String key, Map values) {
        super(session, jspSite, key);
        this.values = values;
        // TODO Auto-generated constructor stub
    }

    /**
     * @param session
     * @param jspSite
     * @param key
     * @param defaultValue
     */
    public MapSelect(HttpSession session, String jspSite, String key, Map values,
            String defaultValue) {
        super(session, jspSite, key, defaultValue);
        this.values = values;
    }

    /* (non-Javadoc)
     * @see com.etixpert.evolution.gui.servlets.elements.Select#reset()
     */
    protected void reset() throws Exception {
        it = values.keySet().iterator();

    }

    /* (non-Javadoc)
     * @see com.etixpert.evolution.gui.servlets.elements.Select#hasNext()
     */
    protected boolean hasNext() throws Exception {
        
        return it.hasNext();
    }

    /* (non-Javadoc)
     * @see com.etixpert.evolution.gui.servlets.elements.Select#next()
     */
    protected String[] next() throws Exception {
        // TODO Auto-generated method stub
        String [] pair= new String[2];
        pair[0] = (String) it.next();
        pair[1] = (String) values.get(pair[0]);
        return pair;
        
    }

}
