package com.jxml.quick.util.qjml4;

import java.io.PrintWriter;
import java.util.ArrayList;
import org.xml.sax.*;

public class QMChild extends QGBase implements QGBaseIntf {

    public QGBase access;

    public String element;

    public String label="";

    /** default = "False" */
    public boolean optional;

    /** default = "False" */
    public boolean repeating;


    public QMChild() {
    }

    public QMChild(QGBase access, String element, String label, boolean optional, boolean repeating) {
        this.access = access;
        this.element = element;
        this.label = label;
        this.optional = optional;
        this.repeating = repeating;
    }

    public void setDestination(DocumentHandler destination)
    {
	super.setDestination(destination);
	if (access!=null)
	    access.setDestination(destination);
    }

    public void cvt()
	throws SAXException
    {
	addStringAttribute("coin",element);
	if (!"".equals(label))
	    addStringAttribute("label",label);
	if (optional)
	    addBooleanAttribute("optional",true);
	if (repeating)
	    addBooleanAttribute("repeating",true);
	startElement("item");
	if (access!=null)
	    access.cvt();
	endElement("item");
    }

    public void print(PrintWriter pw, String indent) {
        pw.println(indent + "element child");
        if (access != null) {
            if (access instanceof QGBaseIntf)
                ((QGBaseIntf)access).print(pw, indent + "    ");
            else
                pw.println(indent + "access = " + access);
        } else
            pw.println(indent + "access = null");
        pw.println(indent + "element = " + element);
        pw.println(indent + "label = " + label);
        pw.println(indent + "optional = " + optional);
        pw.println(indent + "repeating = " + repeating);
    }

}
