2 * Instantlauncher. Author: Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
3 * This project is released under Creative Commons Zero (CC0) license.
5 package eu.svjatoslav.instantlauncher.configuration;
8 import java.util.regex.Matcher;
9 import java.util.regex.Pattern;
11 public class FileAssociation implements Comparable<FileAssociation> {
12 public String command;
13 public String fileRegex;
15 public FileAssociation() {
18 public FileAssociation(String fileRegex, String command) {
19 this.fileRegex = fileRegex;
20 this.command = command;
24 public int compareTo(FileAssociation o) {
25 return fileRegex.compareTo(o.fileRegex);
28 public boolean matchesFile(File file) {
29 String absolutePath = file.getAbsolutePath();
31 Pattern pattern = Pattern.compile(fileRegex);
32 Matcher matcher = pattern.matcher(absolutePath);
33 return matcher.matches();