package com.jxml.quick.util.qjml2qiml;
import com.jxml.quick.model.qjml.*;
import com.jxml.quick.*;
import org.xml.sax.*;
import java.util.*;
import com.jxml.quick.ocm.*;
import java.io.*;

/**
 * Extracts QJML data.
 */
public class QCLink extends OCMpeerSupport
{
	public boolean beenHere=false;

	/**
	 * User-provided code to perform the conversion.
	 */
	public void cvt(Object param)
		throws SAXException, IOException
	{
		QMLink dm=(QMLink)dataModel;

		if (beenHere)
		{
			addStringAttribute("href","#"+dm.getLabel());
			//addStringAttribute("schema","http://www.jxml.com/qiml.qiml");
			emptyElement("link");
			return;
		}
		beenHere=true;

		addStringAttribute("tagName",dm.getTag());
		addStringAttribute("ID",dm.getLabel());
		if (dm.wild)
			addStringAttribute("wild","True");

		startElement("elementDefinition");

		doCvt(dm.remList,null);

		startElement("targetFactory");
		addStringContent("com.jxml.quick.engine.QHRefTF");
		endElement("targetFactory");

		startElement("childElement");

		startElement("accessClass");
		addStringContent("com.jxml.quick.access.QMALAccess");
		endElement("accessClass");

		addStringAttribute("tagName","_attributes");
		startElement("elementDefinition");

		startElement("targetFactory");
		addStringContent("com.jxml.quick.tf.QMALTF");
		endElement("targetFactory");

		addStringAttribute("default",dm.getClassName());
		addBooleanAttribute("optional",true);
		addBooleanAttribute("fixed",true);
		startElement("childElement");
		startElement("accessField");
		addStringContent("expects");
		endElement("accessField");
		addStringAttribute("tagName","expects");
		addStringAttribute("ID",dm.getLabel()+".expects");
		startElement("elementDefinition");
		addStringAttribute("class","sun.beans.editors.StringEditor");
		addStringAttribute("targetClass","java.lang.String");
		startElement("targetEditor");
		endElement("targetEditor");
		endElement("elementDefinition");
		endElement("childElement");

		startElement("childElement");
		startElement("accessField");
		addStringContent("href");
		endElement("accessField");
		addStringAttribute("tagName","href");
		addStringAttribute("ID",dm.getLabel()+".href");
		startElement("elementDefinition");
		addStringAttribute("class","sun.beans.editors.StringEditor");
		addStringAttribute("targetClass","java.lang.String");
		startElement("targetEditor");
		endElement("targetEditor");
		endElement("elementDefinition");
		endElement("childElement");

		addStringAttribute("default",dm.schema);
		addBooleanAttribute("optional",true);
		addBooleanAttribute("fixed",true);
		startElement("childElement");
		startElement("accessField");
		addStringContent("schema");
		endElement("accessField");
		addStringAttribute("tagName","schema");
		addStringAttribute("ID",dm.getLabel()+".schema");
		startElement("elementDefinition");
		addStringAttribute("class","sun.beans.editors.StringEditor");
		addStringAttribute("targetClass","java.lang.String");
		startElement("targetEditor");
		endElement("targetEditor");
		endElement("elementDefinition");
		endElement("childElement");

		if (!"".equals(dm.schemaClass))
		{
			addStringAttribute("default",dm.schemaClass);
			addBooleanAttribute("optional",true);
			addBooleanAttribute("fixed",true);
			startElement("childElement");
			startElement("accessField");
			addStringContent("schemaClass");
			endElement("accessField");
			addStringAttribute("tagName","schemaClass");
			addStringAttribute("ID",dm.getLabel()+".schemaClass");
			startElement("elementDefinition");
			addStringAttribute("class","sun.beans.editors.StringEditor");
			addStringAttribute("targetClass","java.lang.String");
			startElement("targetEditor");
			endElement("targetEditor");
			endElement("elementDefinition");
			endElement("childElement");
		}

		endElement("elementDefinition");

		endElement("childElement");

		endElement("elementDefinition");
	}
}
