
package de.ivu.elect.jee.faces.upload;

import java.util.List;

/**
 * @deprecated
 * @see FileTypeResolver
 */
@Deprecated
public class AllowedTypesFilter {

  public AllowedTypesFilter() {
    super();
  }

  /**
   * @return Ein regulärer Ausdruck zum Filtern von erlaubten Dateien. E.g. "/(\.|\/)(gif|jpe?g|png)$/"
   * @see PrimeFaces-Komponente FileUpload.allowTypes
   */
  public String getAllowedTypesRegEx(List<String> fileExtension) {
    StringBuilder result = new StringBuilder();

    result.append("/(\\.|\\/)(");

    for (int i = 0; i < fileExtension.size(); i++) {
      result.append(fileExtension.get(i).toLowerCase());

      if (i < fileExtension.size() - 1) {
        result.append("|");
      }
    }

    result.append(")$/");

    return result.toString();
  }
}
