2015-07-30 09:08:03 -04:00
|
|
|
package net.filebot.format;
|
2015-07-26 07:52:11 -04:00
|
|
|
|
2016-03-09 15:36:28 -05:00
|
|
|
import static net.filebot.Logging.*;
|
2016-03-27 09:52:59 -04:00
|
|
|
import static net.filebot.media.XattrMetaInfo.*;
|
2016-02-02 12:22:24 -05:00
|
|
|
|
2015-07-26 07:52:11 -04:00
|
|
|
import java.io.File;
|
|
|
|
import java.io.FileFilter;
|
|
|
|
|
2016-11-27 17:10:42 -05:00
|
|
|
import javax.script.ScriptException;
|
|
|
|
|
2015-07-26 07:52:11 -04:00
|
|
|
public class ExpressionFileFilter implements FileFilter {
|
|
|
|
|
2016-11-27 17:10:42 -05:00
|
|
|
private ExpressionFilter filter;
|
2015-07-26 07:52:11 -04:00
|
|
|
|
2016-11-27 17:10:42 -05:00
|
|
|
public ExpressionFileFilter(String expression) throws ScriptException {
|
|
|
|
this.filter = new ExpressionFilter(expression);
|
2015-07-26 07:52:11 -04:00
|
|
|
}
|
|
|
|
|
2015-07-27 08:40:55 -04:00
|
|
|
public ExpressionFilter getExpressionFilter() {
|
|
|
|
return filter;
|
|
|
|
}
|
|
|
|
|
2015-07-26 07:52:11 -04:00
|
|
|
@Override
|
|
|
|
public boolean accept(File f) {
|
|
|
|
try {
|
2016-12-05 10:17:32 -05:00
|
|
|
return filter.matches(new MediaBindingBean(xattr.getMetaInfo(f), f));
|
2015-07-26 07:52:11 -04:00
|
|
|
} catch (Exception e) {
|
2016-11-27 17:10:42 -05:00
|
|
|
debug.warning("Filter expression failed: " + e);
|
2015-07-26 07:52:11 -04:00
|
|
|
}
|
2016-11-27 17:10:42 -05:00
|
|
|
return false;
|
2015-07-26 07:52:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|