package com.jxml.quick.model.qdml;
import com.jxml.quick.ocm.*;
import com.jxml.quick.*;
import org.xml.sax.*;
import java.util.*;
import java.io.*;

/**
 * Models an interface element in QDML.
 * An interface element has no tag attribute, since it doesn't define a particular
 * XML element. (Similarly, a Java interface can't be instantiated.)
 * Interfaces provide a means of refering to the family of beans which implement them.
 <pre>
DTD:

&lt;!ELEMENT interface (<a href="QDMCoin.html#remList">rem*</a>, <a href="#extendsList">extends*</a>)  

&lt;!ATTLIST interface 
&nbsp;&nbsp;&nbsp;&nbsp;<a href="QDMCoin.html#label">label</a> CDATA #REQUIRED
&nbsp;&nbsp;&nbsp;&nbsp;<a href="QDMCoin.html#generate">generate</a> CDATA "True"
&nbsp;&nbsp;&nbsp;&nbsp;ID id #IMPLIED
>
 </pre>
 */
public class QDMInterface extends QDMCoin
	implements QDMElement
{
	/**
	 * A container for QDMExtends objects, which model extends elements.
	 * The extends elements are optional and repeating.
	 * These extends elements name the other interface coins which this interface coin extends.
	 * (An interface element, like a Java interface class, can extend any number of
	 * other interfaces.)
	 */
	public ArrayList extendsList=new ArrayList();

	/**
	 * A container for QDMProperty objects, which model property elements.
	 * The property elements are optional and repeating.
	 * These property elements describe the bean property methods of the Java interface which
	 * this interface element describes.
	 */
	public ArrayList propertyList=new ArrayList();

	public Object clone()
	{
		QDMInterface rv=(QDMInterface)super.clone();
		rv.extendsList=clone(extendsList);
		return rv;
	}

	public void buildMaps(Map coinMap, Map contentMap)
		throws SAXException
	{
		int i;
		int s;

		String l=getLabel();
		if ("".equals(l))
			throw new SAXException(
				"Interface coin has no label.");
		if (coinMap.containsKey(l))
			throw new SAXException("Duplicate label: "+l);
		coinMap.put(l,this);
	}

	public void init(Map coinMap, Map contentMap)
		throws SAXException
	{
		int i;
		int s;

		s=extendsList.size();
		for (i=0;i<s;++i)
		{
			String l=((QDMExtends)extendsList.get(i)).text;
			QDMCoin c=(QDMCoin)coinMap.get(l);
			if (c==null)
				throw new SAXException("Undefined coin: "+l);
			c.extensions.add(this);
		}
	}

	public Map getAtts()
		throws SAXException
	{
		return new HashMap();
	}

	/**
	 * Returns  the element or attribute tag name..
	 */
	public String getTag()
	{
		return "";
	}
}
