package com.jxml.quick.qmap;

import com.jxml.quick.access.*;
import java.util.*;

public class QMapIterator implements QIterator
{
    private Object current=null;
    private Iterator iterator=null;
    private Map map=null;

    public void setMap(Map map)
    {
	this.map=map;
	iterator=map.keySet().iterator();
	getNext();
    }

    public Object getCurrent()
    {
	return current;
    }

    public void getNext()
    {
	if (iterator.hasNext())
	{
	    Object key=iterator.next();
	    current=map.get(key);
	    if (!(current instanceof QKeyed))
	    {
		current=new QMapEntry(map,key,current);
	    }
	}
	else
	    current=null;
    }

    public boolean isComplete()
    {
	return current==null;
    }

    public void clear()
    {
	current=null;
	iterator=null;
	map=null;
    }
}
