//
// DataMapList.java - Try a sequence of DataMaps, until nothing left to map
//

package nyangau.jmsadapter;

//...simports:0:
import java.util.Set;
import java.util.Map;
import java.util.Vector;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.Text;
//...e

public class DataMapList extends DataMap
  {
  protected Vector<DataMap> datamaps;
//...sDataMapList:2:
public DataMapList(Node eDataMap)
  throws FlowProcessorException
  {
  super(eDataMap);
  datamaps = new Vector<DataMap>();
  NamedNodeMap nnmDataMap = eDataMap.getAttributes();

  // Build a vector of nested DataMaps
  NodeList nl = eDataMap.getChildNodes();
  for ( int i = 0; i < nl.getLength(); i++ )
    {
    Node eDataMapNested = nl.item(i);
    if ( eDataMapNested.getNodeType() == Node.ELEMENT_NODE )
      {
      DataMap datamap = DataMap.newDataMap(eDataMapNested);
      datamaps.add(datamap);
      }
    }
  }
//...e
//...smap:2:
public void map(Set<String> unmapped, Map<String,String> mapped)
  throws FlowProcessorException
  {
  for ( int i = 0; ! unmapped.isEmpty() && i < datamaps.size(); i++ )
    {
    DataMap datamap = datamaps.elementAt(i);
    datamap.map(unmapped, mapped);
    }
  }
//...e
  }
