/**
  * Add the specified VM to the VM definitions managed by this container.
  *
  * <p>If distinguishing valid from invalid VMs is important, the specified VM must have already
  * had its install location set. An invalid VM is one whose install location doesn't exist.
  *
  * @param vm the VM to be added to this container
  */
 public void addVM(IVMInstall vm) {
   if (!fVMList.contains(vm)) {
     IVMInstallType vmInstallType = vm.getVMInstallType();
     List<IVMInstall> vmList = fVMTypeToVMMap.get(vmInstallType);
     if (vmList == null) {
       vmList = new ArrayList<IVMInstall>(3);
       fVMTypeToVMMap.put(vmInstallType, vmList);
     }
     vmList.add(vm);
     File installLocation = vm.getInstallLocation();
     if (installLocation == null
         || !vmInstallType.validateInstallLocation(installLocation).isOK()) {
       fInvalidVMList.add(vm);
     }
     fVMList.add(vm);
   }
 }
  /** Create and return a node for the specified VM install type in the specified Document. */
  private Element vmTypeAsElement(Document doc, IVMInstallType vmType) {

    // Create a node for the vm type and set its 'id' attribute
    Element element = doc.createElement("vmType"); // $NON-NLS-1$
    element.setAttribute("id", vmType.getId()); // $NON-NLS-1$

    // For each vm of the specified type, create a subordinate node for it
    List vmList = (List) getVMTypeToVMMap().get(vmType);
    Iterator vmIterator = vmList.iterator();
    while (vmIterator.hasNext()) {
      IVMInstall vm = (IVMInstall) vmIterator.next();
      Element vmElement = vmAsElement(doc, vm);
      element.appendChild(vmElement);
    }

    return element;
  }