/**
     * Constructor for class BackupAssociation
     *
     * @param assoc given Association (not null)
     * @param regLeve given regLevel
     */
    protected BackupAssociation(Association assoc, int regLevel) {
      curMimeType = assoc.getMimeType();

      Iterator iter = null;
      List temFileExtList = assoc.getFileExtList();
      if (temFileExtList != null) {
        iter = temFileExtList.iterator();
      }
      if (iter != null) {
        if (iter.hasNext()) {
          curFileExt = (String) iter.next();
        }
      }

      if (curMimeType != null) {
        curMimeTypeExisted = WinRegistryUtil.isMimeTypeExist(curMimeType, regLevel);
      } else {
        curMimeTypeExisted = false;
      }

      if (curFileExt != null) {
        curFileExtExisted = WinRegistryUtil.isFileExtExist(curFileExt, regLevel);
      } else {
        curFileExtExisted = false;
      }

      if (curMimeTypeExisted) {
        backupFileExt = WinRegistryUtil.getFileExtByMimeType(curMimeType, regLevel);
      }

      if (curFileExtExisted) {
        backupClassID = WinRegistryUtil.getClassIDByFileExt(curFileExt, regLevel);
        backupMimeType = WinRegistryUtil.getMimeTypeByFileExt(curFileExt, regLevel);
      }
    }
  /**
   * Checks whether the given assocation is valid for registration.
   *
   * <PRE>
   * 1. The file extension list and mime type can't all be null
   * 2. If any of the fileds: description, iconFile, actionList is not null,
   *    then fileExtensionList should not be empty
   * </PRE>
   *
   * @param assoc a given Association object.
   * @param level a given MIME database level.
   * @throws IllegalArgumentException if the given association is not valid for registration.
   */
  public void checkAssociationValidForRegistration(Association assoc)
      throws IllegalArgumentException {
    boolean isActionListEmpty = true;
    boolean isFileExtensionEmpty = true;
    boolean isValid = false;

    // Check if actionlist is empty
    if (assoc.getActionList() != null) {
      isActionListEmpty = assoc.getActionList().isEmpty();
    }
    // Check if file extension list is empty
    if (assoc.getFileExtList() != null) {
      isFileExtensionEmpty = assoc.getFileExtList().isEmpty();
    }

    if (isFileExtensionEmpty && (assoc.getMimeType() == null)) {
      isValid = false;
    } else if ((assoc.getDescription() != null)
        || (assoc.getIconFileName() != null)
        || (!isActionListEmpty)) {
      isValid = !isFileExtensionEmpty;
    } else {
      isValid = true;
    }

    if (!isValid) {
      throw new IllegalArgumentException(
          "The given association is invalid. It should "
              + "specify both the mimeType and fileExtensionList fields to perform this operation.");
    }
  }
 /**
  * Checks whether the given assocation is valid for unregistration. If both the mimeType and
  * fileExtensionList field is null, throw exception.
  *
  * @param assoc a given Association object.
  * @param level a given MIME database level.
  * @throws IllegalArgumentException if the given association is not valid for unregistration.
  */
 public void checkAssociationValidForUnregistration(Association assoc)
     throws IllegalArgumentException {
   boolean isFileExtListEmpty = true;
   if (assoc.getFileExtList() != null) {
     isFileExtListEmpty = assoc.getFileExtList().isEmpty();
   }
   if ((assoc.getMimeType() == null) && isFileExtListEmpty) {
     throw new IllegalArgumentException(
         "The given association is invalid. It should "
             + "specify both the mimeType and fileExtensionList fields to perform this operation.");
   }
 }
  /**
   * Checks whether the given assocation already existed in Windows registry.
   *
   * <PRE>
   * The evaluation will based on the following rule:
   * 1. mimetype == null && fileExt == null
   *    return false
   * 2. mimetype == null && fileExt != null
   *    return !(fileExt existed in the reg table)
   * 3. mimetype != null && fileExt == null
   *    return !(mimetype existed in the reg table)
   * 4. mimetype != null && fileExt != null
   *    return ( (mimetype existed in the reg table) &&
   *             (fileExt existed in the reg table) &&
   *             (getFileExtByMimeType(mimetype) == fileExt) &&
   *             (getMimeTypeByFileExt(fileExt) == mimetype) )
   * </PRE>
   *
   * @param assoc given association (not null)
   * @param regLevel given registry level
   * @return true if the given association existed
   */
  public boolean isAssociationExist(Association assoc, int regLevel) {
    String temFileExt = null;
    String temMimeType = assoc.getMimeType();
    Iterator temFileExtIter;
    if (assoc.getFileExtList() != null) {
      temFileExtIter = assoc.getFileExtList().iterator();
    } else {
      temFileExtIter = null;
    }

    if (temFileExtIter != null) {
      if (temFileExtIter.hasNext()) {
        temFileExt = (String) temFileExtIter.next();
      }
    }

    // Check if there is the same file extension define in Win2k
    // HKEY_CURRENT_USER\\software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts
    if (WinRegistryUtil.isWin2kUserDefinedFileExtExist(temFileExt)) {
      return true;
    }

    if ((temMimeType == null) && (temFileExt == null)) {
      return false;
    } else if ((temMimeType == null) && (temFileExt != null)) {
      return WinRegistryUtil.isFileExtExist(temFileExt, regLevel);
    } else if ((temMimeType != null) && (temFileExt == null)) {
      return WinRegistryUtil.isMimeTypeExist(temMimeType, regLevel);
    } else {
      String regMimeType = WinRegistryUtil.getMimeTypeByFileExt(temFileExt, regLevel);
      String regFileExt = WinRegistryUtil.getFileExtByMimeType(temMimeType, regLevel);

      return ((WinRegistryUtil.isMimeTypeExist(temMimeType, regLevel))
          && (WinRegistryUtil.isFileExtExist(temFileExt, regLevel))
          && (temFileExt == null ? regFileExt == null : temFileExt.equals(regFileExt))
          && (temMimeType == null ? regMimeType == null : temMimeType.equals(regMimeType)));
    }
  }