// Path: src/main/java/org/dynaform/xml/form/Form.java
// public interface Form {
//   
//   String HL_CHILD = "/";
//   String HL_DESCENDANT_OR_SELF = "//";
//   String LL_CHILD = "!";
//   String LL_DESCENDANT_OR_SELF = "!!";
//   String INDEX_START = "[";
//   String INDEX_END = "]";
//   String OPERATOR_SEQUENCE = "sequence";
//   String OPERATOR_CHOICE = "choice";
//   String OPERATOR_ALL = "all";
//   
//   // Identity and parent
//   String getDescendantOrSelfSelector();         // "//element"
//   String getFullSelector();                     // "/aa/bb/cc!selector[0]"
//   String getHighLevelFullSelectorForChildren(); // "/aa/bb/cc"
// 
//   String getHighLevelId();  // cc
//   String getLowLevelId();   // selector[0]
//   
//   Form getParent();
//   void _setParent(Form parent);
//   
//   // Sequence
//   String nextCounterValue();
//   
//   // Visitors
// 	void accept(FormVisitor visitor);
// 	<T> T apply(FormFunction<T> function);
// 
// }


import org.dynaform.xml.form.Form;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;

package org.dynaform.dynadata;



public class MappingSet implements MappingCollection {

  private final Map<String, Mapping> allMappings = new LinkedHashMap<String, Mapping>();
  private final Map<String, Mapping> usedMappings = new LinkedHashMap<String, Mapping>();
  
  public void clear() {
    allMappings.clear();
    usedMappings.clear();
  }
  
  public void add(Mapping mapping) {
    allMappings.put(mapping.getSelector().getString(), mapping);
    usedMappings.put(mapping.getSelector().getString(), mapping);
  }

  public void addAll(Collection<Mapping> mappings) {
    for (Mapping mapping : mappings)
      add(mapping);
  }

  public Collection<Mapping> getAll() {
    return allMappings.values();
  }
  
  public void removeAll(Collection<Mapping> mappings) {
    for (Mapping mapping : mappings) {
      allMappings.remove(mapping.getSelector().getString());
      usedMappings.remove(mapping.getSelector().getString());
    }
  }


// Path: src/main/java/org/dynaform/xml/form/Form.java
// public interface Form {
//   
//   String HL_CHILD = "/";
//   String HL_DESCENDANT_OR_SELF = "//";
//   String LL_CHILD = "!";
//   String LL_DESCENDANT_OR_SELF = "!!";
//   String INDEX_START = "[";
//   String INDEX_END = "]";
//   String OPERATOR_SEQUENCE = "sequence";
//   String OPERATOR_CHOICE = "choice";
//   String OPERATOR_ALL = "all";
//   
//   // Identity and parent
//   String getDescendantOrSelfSelector();         // "//element"
//   String getFullSelector();                     // "/aa/bb/cc!selector[0]"
//   String getHighLevelFullSelectorForChildren(); // "/aa/bb/cc"
// 
//   String getHighLevelId();  // cc
//   String getLowLevelId();   // selector[0]
//   
//   Form getParent();
//   void _setParent(Form parent);
//   
//   // Sequence
//   String nextCounterValue();
//   
//   // Visitors
// 	void accept(FormVisitor visitor);
// 	<T> T apply(FormFunction<T> function);
// 
// }


// Path: src/main/java/org/dynaform/dynadata/MappingSet.java
import org.dynaform.xml.form.Form;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;

package org.dynaform.dynadata;



public class MappingSet implements MappingCollection {

  private final Map<String, Mapping> allMappings = new LinkedHashMap<String, Mapping>();
  private final Map<String, Mapping> usedMappings = new LinkedHashMap<String, Mapping>();
  
  public void clear() {
    allMappings.clear();
    usedMappings.clear();
  }
  
  public void add(Mapping mapping) {
    allMappings.put(mapping.getSelector().getString(), mapping);
    usedMappings.put(mapping.getSelector().getString(), mapping);
  }

  public void addAll(Collection<Mapping> mappings) {
    for (Mapping mapping : mappings)
      add(mapping);
  }

  public Collection<Mapping> getAll() {
    return allMappings.values();
  }
  
  public void removeAll(Collection<Mapping> mappings) {
    for (Mapping mapping : mappings) {
      allMappings.remove(mapping.getSelector().getString());
      usedMappings.remove(mapping.getSelector().getString());
    }
  }


  public Collection<Mapping> get(Form form) {
