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

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

    protected Object get(Object parent, QContext context)
	throws QPE
    {
	validateParent(parent,context);
	HRef cef=(HRef)parent;
	return cef.href;
    }

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

    public void add(Object parent, 
		    QTargetFactory parentFactory,
		    Object child, 
		    QContext context)
	throws QPE
    {
	validateParent(parent,context);
	validateChild(child,context);
	HRef cef=(HRef)parent;
	cef.href=(String)child;
    }
}
