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

/**
 * Models a sequence element in QJML.
 * The contentModel elements held by a sequence element define a series of content
 * sub-models within the element content of another element.
 <pre>
DTD:

&lt;!ELEMENT sequence (<a href="QMContentModel.html#remList">rem*</a>,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="QMContentModel.html#aref">(aref</a>|<a href="QMContentModel.html#access">id|identity|ignore|field|property|accessClass)?</a>,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#contentList">(item|selection|sequence)</a>+)>

&lt;!ATTLIST sequence
&nbsp;&nbsp;&nbsp;&nbsp;<a href="QMContentModel.html#label">label</a> CDATA #IMPLIED
&nbsp;&nbsp;&nbsp;&nbsp;<a href="QMContentModel.html#cref">cref</a> CDATA #IMPLIED
&nbsp;&nbsp;&nbsp;&nbsp;<a href="QMContentModel.html#optional">optional</a> CDATA "False"
&nbsp;&nbsp;&nbsp;&nbsp;<a href="QMContentModel.html#repeating">repeating</a> CDATA "False"
&nbsp;&nbsp;&nbsp;&nbsp;ID id #IMPLIED
>
 </pre>
 */
public class QMSequence extends QMContentModel 
{
	/**
	 * A container for the QMContentModel objects (QMItem, QMSequence, and QMSelection)
	 * which model the contentModel elements (item, sequence, and selection) held by
	 * this elements element.
	 */
	public ArrayList contentList=new ArrayList();

	public Object clone()
	{
		QMSequence rv=(QMSequence)super.clone();
		rv.contentList=clone(contentList);
		return rv;
	}

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

		s=contentList.size();
		for(i=0;i<s;++i)
		{
			QMContentModel cm=(QMContentModel)contentList.get(i);
			cm.buildMaps(coinMap,contentMap,myCoin);
		}
	}

	protected void cminit(Map coinMap, Map contentMap)
		throws SAXException
	{
		super.init(coinMap,contentMap);
	}

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

		s=contentList.size();
		for(i=0;i<s;++i)
		{
			QMContentModel cm=(QMContentModel)contentList.get(i);
			cm.init(coinMap,contentMap);
		}

		if (content!=null && (content instanceof QMSequence))
		{
			QMSequence seq=(QMSequence)content;
			ArrayList join=new ArrayList(seq.contentList);
			join.addAll(contentList);
			contentList=join;
		}
	}
}
