package com.jxml.quick.ocm; // Open Conversion Model
import com.jxml.quick.*;
import org.xml.sax.*;
import java.util.*;
import java.io.*;
import com.jxml.quick.qmap.*;

/**
 * Maps data model classes to peer classes.
 */
public class OCMpeerFactoryEntry extends QKeyedBase
{
	public HashMap params=new HashMap();
        public String peerClass;
	
	transient Class c=null;
	
	/**
	 * Return a peer object.
	 */
	public OCMpeer createPeer(Object dataModel, OCMcontext context, OCMpeer parent)
		throws SAXException, IOException
	{
		ClassLoader cl=context.getClassLoader();
		try
		{
			if (c==null)
			{
				if (cl==null)
					c=Class.forName(peerClass);
				else
				{
					c=cl.loadClass(peerClass);
				}
			}
			OCMpeer peer=(OCMpeer)c.newInstance();
			peer.init(dataModel,context,parent,params);
			return peer;
		}
		catch (Exception f)
		{
			throw new SAXException(f.toString());
		}
	}
}
