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 Text<br>
 * This controller class contain the logic for template processing for text<br> 
 * @see <a href="http://quickutil.sourceforge.net/view/Main/QjmlText">More    details here.</a><br>
 */
public class QCText extends QCCoin
{
	public QMText ed;
/**
 * Method declaration<br> 
 * @param param Name of the parameter 
 * @exception SAXException Legal SAXException  
 * @exception IOException Legal IOException
 */
	public void cvt(Object param) 
		throws SAXException, IOException 
	{
			OCMcontextSupport.SubContextSupport 						scs=(OCMcontextSupport.SubContextSupport)context;
			sb=scs.sb;
			ed=(QMText)dataModel;
			super.cvt(param);
	}
/**
 * Method declaration<br>
 * Contains template processing logic to process the templates<br>
 * @param templateName The name of the Template it is a string<br>
 * @param arg The parameter name it is a string<br>
 * @return string The string values to be plugged inside the templates
 * @exception SAXException  
 * @exception 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.extendor,imports);
			doCvt(ed.implementsList,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("extendor".equals(arg))
		{
			if(!(ed.extendor==null))
			{
				sb.append("extends ");
				doCvt(ed.extendor,null);
			}
			return "";
		}

		if ("implementor".equals(arg))
		{
			if(!(ed.implementsList.size() < 1))
			{
				sb.append("implements ");
				doCvt(ed.implementsList,null);
			}
			return "";
		}

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

