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 Implements<br> 
 * @see <a href="http://quickutil.sourceforge.net/view/Main/QjmlImplements">More details here.</a><br>
 */

public class QCImplements extends OCMrootPeerSupportLite
{		
/**
 * Method declaration<br>
 * @param param The name of the package
 * @return string The name of the implements
 * @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;
		
		QMImplements ed = (QMImplements)dataModel;

		String text=ed.text;
	
		TreeMap coinMap=qjml.coinMap;
		QMCoin implementor=(QMCoin)coinMap.get(text);

	       	String implementorName=implementor.getClassName();



		int i=implementorName.lastIndexOf('.');


		if (param==null)
		{
			sb.append(implementorName);
			return ;
		}

		 if (param instanceof ArrayList)
		{
			if (i==-1)
				return;
			ArrayList imports=(ArrayList)param;
			int j,s;
			s=imports.size();
			String pkg=implementorName.substring(0,i);
			for (j=0;j<s;++j)
			{
				if (pkg.equals(imports.get(j)))

					return;
			}

			imports.add(pkg);
		}
		
	}
}

