/*------------------------------------------------------------------------------------
Copyright (c)2000 TogetherSoft Corporation. Patents pending. All rights reserved. 
------------------------------------------------------------------------------------*/ 

package com.togethersoft.modules.xmleditor.xmltree;

import java.util.*;
import com.togethersoft.modules.xmleditor.dtd.*;

public class ANDGroupInst extends GroupInst 
{
  //--------------------------------------------------------------------
  public ANDGroupInst (DTDGroupItemDef groupDef)
  {
    super (groupDef);
  }

  //--------------------------------------------------------------------
  public boolean isComplete()
  {
    for (int i = 0; i < m_itemInstHolders.length; i ++)
    {
      if (! m_itemInstHolders[i].isComplete())
        return false;
    }

    return true;
  }

  //--------------------------------------------------------------------
  public int checkElementInstAllowance (DTDElementDef elementDef)
  {
    int foundAllowance = ElementInst.NEA_PROHIBITED;

    for (int i = 0; i < m_itemInstHolders.length; i ++)
    {
      foundAllowance = m_itemInstHolders[i].checkElementInstAllowance (elementDef);
      if (foundAllowance != ElementInst.NEA_PROHIBITED)
        break;
    }

    return foundAllowance;
  }

  //--------------------------------------------------------------------
  public boolean putElementInst (ElementInst elementInst)
  {
    for (int i = 0; i < m_itemInstHolders.length; i ++)
    {
      if (m_itemInstHolders[i].putElementInst (elementInst))
        return true;
    }

    return false;
  }

  //--------------------------------------------------------------------
  public Vector getContainedElements()
  {
    Vector allElements = new Vector();

    for (int i = 0; i < m_itemInstHolders.length; i ++)
    {
      InstHolder instHolder = m_itemInstHolders[i];
      Vector v = instHolder.getContainedElements();
      allElements.addAll (v);
    }

    return allElements;
  }

  //--------------------------------------------------------------------
}
