mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-22 07:48:52 -05:00
Allow custom parallelism for formats
This commit is contained in:
parent
b6251a7aa5
commit
d28df06818
@ -18,7 +18,7 @@ import net.filebot.similarity.Match;
|
|||||||
|
|
||||||
class ExpressionFormatter implements MatchFormatter {
|
class ExpressionFormatter implements MatchFormatter {
|
||||||
|
|
||||||
private final String expression;
|
private String expression;
|
||||||
private ExpressionFileFormat format;
|
private ExpressionFileFormat format;
|
||||||
|
|
||||||
private Format preview;
|
private Format preview;
|
||||||
@ -41,6 +41,13 @@ class ExpressionFormatter implements MatchFormatter {
|
|||||||
this.format = format;
|
this.format = format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized ExpressionFileFormat getFormat() throws ScriptException {
|
||||||
|
if (format == null) {
|
||||||
|
format = new ExpressionFileFormat(expression);
|
||||||
|
}
|
||||||
|
return format;
|
||||||
|
}
|
||||||
|
|
||||||
public Class<?> getTargetClass() {
|
public Class<?> getTargetClass() {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
@ -57,15 +64,12 @@ class ExpressionFormatter implements MatchFormatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized String format(Match<?, ?> match, boolean extension, Map<?, ?> context) throws ScriptException {
|
public String format(Match<?, ?> match, boolean extension, Map<?, ?> context) throws ScriptException {
|
||||||
// lazy initialize script engine
|
|
||||||
if (format == null) {
|
|
||||||
format = new ExpressionFileFormat(expression);
|
|
||||||
}
|
|
||||||
|
|
||||||
// evaluate the expression using the given bindings
|
// evaluate the expression using the given bindings
|
||||||
Object bindingBean = new MediaBindingBean(match.getValue(), (File) match.getCandidate(), (Map) context);
|
Object bindingBean = new MediaBindingBean(match.getValue(), (File) match.getCandidate(), (Map) context);
|
||||||
String destination = format.format(bindingBean);
|
|
||||||
|
// lazy initialize script engine
|
||||||
|
String destination = getFormat().format(bindingBean);
|
||||||
|
|
||||||
return getPath((File) match.getCandidate(), destination);
|
return getPath((File) match.getCandidate(), destination);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user