package com.jxml.quick.util.qjml2java2;
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.*;
/**
 * Controller class for Interfaces.
 * @see <a href="http://quickutil.sourceforge.net/view/Main/QjmlInterface">More details here.</a><br>
 */
public class QCInterface extends QCCoin

{
	StringBuffer sb;
	public QMInterface ed;
/**
 * Method declaration<br> 
 * @param param It is a string
 * @exception SAXException  
 * @exception IOException 
 */
	public void cvt(Object param) 
		throws SAXException, IOException 
	{

			OCMcontextSupport.SubContextSupport                         scs=(OCMcontextSupport.SubContextSupport)context;
			sb=scs.sb;
			ed=(QMInterface)dataModel;
			super.cvt(param);

	}
/**
 * Method declaration<br>
 * Contains template processing logic to <code>process</code> the <code>templates</code>.
 * @param templateName The name of the Template<br>
 * @param arg The <tt>parameter</tt> name<br>
 * @return string The string values to be plugged inside the templates
 * @exception SAXException  Legal SAXException
 * @exception IOException Legal IOException
 */

	public String process(String templateName, String arg)
		throws SAXException, IOException
	{
		int i,s;

		if("import".equals(arg))
		{
			ArrayList imports=new ArrayList();
			imports.add(packageName);
			doCvt(ed.extendsList,imports);
			doCvt(ed.propertyList,imports);
			s=imports.size();
			for (i=1;i<s;++i)
			{
				String imp=(String)imports.get(i);
				if (!imp.equals("java.lang"))
					sb.append("import "+imp+".*;\n");

			}
			return "";

		}

		if ("extendsList".equals(arg))
		{
			if(!(ed.extendsList.size() < 1))
			{
				sb.append("extends ");
				List l=ed.extendsList;
				s=l.size();
				for (i=0;i<s;++i)
				{
					if (i>0)
					sb.append(", ");
					Object o=l.get(i);
					doCvt(o,null);
				}

			}
			return "";
		}
	
		if ("methods".equals(arg))
		{
			doCvt(ed.propertyList,"");
			return "";
		}

		return	super.process(templateName,arg);
	}
}


