2 * Instantlauncher. Copyright ©2012-2019, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of version 3 of the GNU Lesser General Public License
6 * or later as published by the Free Software Foundation.
9 package eu.svjatoslav.instantlauncher.configuration;
12 import java.util.regex.Matcher;
13 import java.util.regex.Pattern;
15 public class FileAssociation implements Comparable<FileAssociation> {
16 public String command;
17 public String fileRegex;
19 public FileAssociation() {
22 public FileAssociation(String fileRegex, String command) {
23 this.fileRegex = fileRegex;
24 this.command = command;
28 public int compareTo(FileAssociation o) {
29 return fileRegex.compareTo(o.fileRegex);
32 public boolean matchesFile(File file) {
33 String absolutePath = file.getAbsolutePath();
35 Pattern pattern = Pattern.compile(fileRegex);
36 Matcher matcher = pattern.matcher(absolutePath);
37 return matcher.matches();