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

public class QAccess
{
    private ArrayList iterators=new ArrayList();
    private int s=0;

    public boolean writeable(QTargetFactory parentFactory, QContext context)
	throws QPE
    {
	return false;
    }

    public void add(Object parentObject, 
		    QTargetFactory parentFactory,
		    Object childObject, 
		    QContext context)
	throws QPE
    {
    }

    public int reserve(QTargetFactory parentFactory,			//1.1.5
			Object parentObject,
		       QContext context)
	throws QPE
    {
	return -1;
    }

    public void set(int reserved,
		    Object parentObject, 
		    QTargetFactory parentFactory,
		    Object childObject, 
		    QContext context)
	throws QPE
    {
	add(parentObject,parentFactory,childObject,context);
    }

    public boolean readable(QTargetFactory parentFactory, QContext context)
	throws QPE
    {
	return false;
    }

    public QIterator createIterator()
    {
	return null;
    }

    public void setIteratorParent(QIterator it, 
				  Object parent, 
				  QTargetFactory parentFactory,
				  QContext context)
	throws QPE
    {
    }

    public final QIterator allocateIterator(Object parent, 
					    QTargetFactory parentFactory,
					    QContext context)
	throws QPE
    {
	    QIterator it;
	if (s==0)
	    it=createIterator();
	else
	    {
		--s;
		it=(QIterator)iterators.remove(s);
	    }
	setIteratorParent(it,parent,parentFactory,context);
	return it;
    }

    public final void releaseIterator(QIterator iterator)
    {
	iterator.clear();
	iterators.add(iterator);
	++s;
    }
}
