package com.jxml.quick.engine;
import com.jxml.quick.*;
import com.jxml.quick.access.*;
import com.jxml.quick.tf.*;

public class QTargetFactoryAccess extends QOptionalAccess
{
    protected void validateParent(Object parent, QContext context)
	throws QPE
    {
	if (!(parent instanceof QElementFactory))
	    context.throwPE("requires QElementFactory parent, not"+
			    parent.getClass());
    }

    protected void validateChild(Object child, QContext context)
	throws QPE
    {
	if (!(child instanceof QTargetFactory))
	    context.throwPE("requires QTargetFactory child, not"+
			    child.getClass());
    }

    protected Object get(Object parent, QContext context)
	throws QPE
    {
	validateParent(parent,context);
	QElementFactory ef=(QElementFactory)parent;
	return ef.targetFactory;
    }

    public void add(Object parent, 
		    QTargetFactory parentFactory,
		    Object child, 
		    QContext context)
	throws QPE
    {
	validateParent(parent,context);
	validateChild(child,context);
	QElementFactory ef=(QElementFactory)parent;
	ef.targetFactory=(QTargetFactory)child;
    }
}
