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 Extends<br> 
 * @see <a href="http://quickutil.sourceforge.net/view/Main/QjmlExtends">QjmlExtends</a><br>
 */
public class QCExtends extends OCMrootPeerSupportLite
{
/**
 * Method declaration<br>
 * This method is imprting packages
 * @param param The name of the package
 * @return String,it is a name of the package
 * @exception SAXException
 * @exception IOException
 */
	public void cvt(Object param) throws SAXException, IOException 
	{
		OCMcontextSupport.SubContextSupport scs=(OCMcontextSupport.SubContextSupport)context;
		StringBuffer sb=scs.sb;
		QMQJML qjml=(QMQJML)scs.dataModelRoot;

		QMExtends ed = (QMExtends)dataModel;
		String text=ed.text;

		TreeMap coinMap=qjml.coinMap;
		QMCoin extendor=(QMCoin)coinMap.get(text);
		String className=extendor.getClassName();
		int i=className.lastIndexOf('.');
		
		if (param==null)
		{
			if (i==-1)
				sb.append(className);
			else
				sb.append(className.substring(i+1));
			return;
		}
		else if (param instanceof ArrayList)
		{
			if (i==-1)
				return;
			ArrayList imports=(ArrayList)param;
			int j,s;
			s=imports.size();
			String pkg=className.substring(0,i);

			for (j=0;j<s;++j)
			{
				if (pkg.equals(imports.get(j)))
					return;
			}
			imports.add(pkg);
		}
		
	}
}

