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

/**
 * Generic element model.
 */
public class OCMelement implements QDOMEle
{
	public String name;
	public String text;
	public ArrayList elements=new ArrayList();
	public ArrayList attributes=new ArrayList();

	transient boolean allSet=false;

	public void setIDs(QDoc doc)
		throws QPE
	{
		if (allSet)
			return;
		allSet=true;

		int i,s;

		s=attributes.size();
		for (i=0;i<s;++i)
		{
			OCMattribute a=(OCMattribute)attributes.get(i);
			if ("ID".equals(a.name))
			{
				i=s;
				doc.setId(a.text,this);
			}
		}

		s=elements.size();
		for (i=0;i<s;++i)
		{
			OCMelement e=(OCMelement)elements.get(i);
			e.setIDs(doc);
		}
	}

	public String getQName()
	{
		return name;
	}

	public void setQName(String name)
	{
		this.name=name;
	}

	public String getQText()
	{
		return text;
	}

	public void setQText(String text)
	{
		this.text=text;
	}

	public List getQElements()
	{
		return elements;
	}

	public List getQAttributes()
	{
		return attributes;
	}
	
	public void addAttribute(OCMattribute att)
	{
		int i,s;
		s=attributes.size();
		for(i=0; i<s;i++)
		{
			OCMattribute a=(OCMattribute)attributes.get(i);
			if(a.equals(att))
			{
				attributes.set(i,att);
				return;
			}
		}
		attributes.add(att);
	}
}