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 Abstract<br>
 * This class containing the <code>template</code> processing logic 
 * @see <a    href="http://quickutil.sourceforge.net/view/Main/QjmlAbstract">QjmlAbstract</a> 
 */
public class QCAbstract extends QCCoin

{
	StringBuffer sb;
	public QMAbstract ed;
/**
 * Method declaration
 * @param param The string
 * @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=(QMAbstract)dataModel;
			super.cvt(param);

	}
/**
 * Method declaration<br>
 * This method contains template processing logic to process the templates.
 * @param templateName The name of the Template
 * @param arg The parameter name
 * @return 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.implementsList,imports);
			doCvt(ed.fieldList,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("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 ");
				List l=ed.implementsList;
				s=l.size();
				for (i=0;i<s;++i)
				{
					if (i>0)
					sb.append(", ");
					Object o=l.get(i);
					doCvt(o,null);
				}
			}
			return "";
		}

		if("variables".equals(arg))
		{
			doCvt(ed.fieldList,null);
			doCvt(ed.propertyList,null);
			doCvt(ed.attributes,null);
		}	

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

		return	super.process(templateName,arg);
	}

}

