package com.jxml.quick.util.qjml4;

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

public class QMQJML extends QGBase implements QGBaseIntf {

    public String root;

    /** list of QMElement */
    public ArrayList items = new ArrayList();

    public QMQJML() {
    }

    public QMQJML(String root, ArrayList items) {
        this.root = root;
        this.items = items;
    }

    public void setDestination(DocumentHandler destination)
    {
	super.setDestination(destination);
	int i,s;
	s=items.size();
	for (i=0;i<s;++i)
	{
	    QGBase b=(QGBase)items.get(i);
	    b.setDestination(destination);
	}
    }

    public void evalRoot()
	throws SAXException
    {
	int i,s;

	addStringAttribute("root",root);
	startElement("qjml");

	s=items.size();
	for (i=0;i<s;++i)
	{
	    QGBase b=(QGBase)items.get(i);
	    b.cvt();
	}

	endElement("qjml");
    }

    public QMElement getQMElement(int i) {
        return((QMElement)items.get(i));
    }

    public void setQMElement(int i, QMElement qMElement) {
        items.set(i, qMElement);
    }

    public int qMElementCount() {
        return(items.size());
    }

    public void print(PrintWriter pw, String indent) {
        pw.println(indent + "element qjml");
        pw.println(indent + "root = " + root);
        for (int i=0; i<items.size(); i++)
            getQMElement(i).print(pw, indent + "    ");
    }

}
