* String.join works slightly different than our own join() method, so to avoid any hidden issues keep using our own as before
This commit is contained in:
parent
ea26287b92
commit
aa5d5c901c
|
@ -1,6 +1,7 @@
|
|||
package net.filebot;
|
||||
|
||||
import static net.filebot.util.FileUtilities.*;
|
||||
import static net.filebot.util.StringUtilities.*;
|
||||
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.io.File;
|
||||
|
@ -285,14 +286,14 @@ public final class Settings {
|
|||
}
|
||||
|
||||
public static String getApplicationIdentifier() {
|
||||
return String.join(" ", getApplicationName(), getApplicationVersion(), String.format("(r%s)", getApplicationRevisionNumber()));
|
||||
return join(" ", getApplicationName(), getApplicationVersion(), String.format("(r%s)", getApplicationRevisionNumber()));
|
||||
}
|
||||
|
||||
public static String getJavaRuntimeIdentifier() {
|
||||
String name = System.getProperty("java.runtime.name");
|
||||
String version = System.getProperty("java.version");
|
||||
String headless = GraphicsEnvironment.isHeadless() ? "(headless)" : null;
|
||||
return String.join(" ", name, version, headless);
|
||||
return join(" ", name, version, headless);
|
||||
}
|
||||
|
||||
private static String[] applicationArgumentArray;
|
||||
|
|
|
@ -5,6 +5,7 @@ import static java.util.Collections.*;
|
|||
import static net.filebot.Settings.*;
|
||||
import static net.filebot.media.MediaDetection.*;
|
||||
import static net.filebot.util.FileUtilities.*;
|
||||
import static net.filebot.util.StringUtilities.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashSet;
|
||||
|
@ -256,7 +257,7 @@ public final class WebServices {
|
|||
if (LOGIN_OPENSUBTITLES.equals(id)) {
|
||||
String password_md5 = md5(password);
|
||||
OpenSubtitles.setUser(user, password_md5);
|
||||
Settings.forPackage(WebServices.class).put(id, String.join(LOGIN_SEPARATOR, user, password_md5));
|
||||
Settings.forPackage(WebServices.class).put(id, join(LOGIN_SEPARATOR, user, password_md5));
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ public class MediaBindingBean {
|
|||
for (Episode it : getEpisodes()) {
|
||||
title.add(removeTrailingBrackets(it.getTitle()));
|
||||
}
|
||||
return truncateText(String.join(" & ", title), limit);
|
||||
return truncateText(join(title, " & "), limit);
|
||||
}
|
||||
|
||||
@Define("d")
|
||||
|
@ -353,7 +353,7 @@ public class MediaBindingBean {
|
|||
return null;
|
||||
|
||||
// e.g. 1280x720
|
||||
return String.join("x", dim.get(0).toString(), dim.get(1).toString());
|
||||
return join(dim, "x");
|
||||
}
|
||||
|
||||
@Define("ws")
|
||||
|
|
|
@ -7,6 +7,7 @@ import static net.filebot.Settings.*;
|
|||
import static net.filebot.similarity.CommonSequenceMatcher.*;
|
||||
import static net.filebot.similarity.Normalization.*;
|
||||
import static net.filebot.util.FileUtilities.*;
|
||||
import static net.filebot.util.StringUtilities.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
|
@ -1046,7 +1047,7 @@ public class MediaDetection {
|
|||
relativePath.addFirst(it.getName());
|
||||
}
|
||||
|
||||
return relativePath.isEmpty() ? null : new File(String.join(File.separator, relativePath));
|
||||
return relativePath.isEmpty() ? null : new File(join(relativePath, File.separator));
|
||||
}
|
||||
|
||||
public static Map<File, List<File>> mapByMediaFolder(Collection<File> files) {
|
||||
|
|
|
@ -38,7 +38,6 @@ import net.filebot.web.CachedResource;
|
|||
import net.filebot.web.Movie;
|
||||
import net.filebot.web.SubtitleSearchResult;
|
||||
import net.filebot.web.TheTVDBSearchResult;
|
||||
import net.filebot.web.SubtitleSearchResult.Kind;
|
||||
|
||||
import org.tukaani.xz.XZInputStream;
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import static java.util.Collections.*;
|
|||
import static java.util.regex.Pattern.*;
|
||||
import static net.filebot.similarity.Normalization.*;
|
||||
import static net.filebot.util.FileUtilities.*;
|
||||
import static net.filebot.util.StringUtilities.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -435,7 +436,7 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
|||
while (scanner.hasNextInt()) {
|
||||
numbers.add(String.valueOf(scanner.nextInt()));
|
||||
}
|
||||
return String.join(" ", numbers);
|
||||
return join(numbers, " ");
|
||||
}
|
||||
}),
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import static java.util.Collections.*;
|
|||
import static java.util.regex.Pattern.*;
|
||||
import static net.filebot.similarity.CommonSequenceMatcher.*;
|
||||
import static net.filebot.similarity.Normalization.*;
|
||||
import static net.filebot.util.StringUtilities.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.CollationKey;
|
||||
|
@ -99,7 +100,7 @@ public class SeriesNameMatcher {
|
|||
whitelist.addAll(deepMatchAll(focus, threshold));
|
||||
|
||||
// 1. use pattern matching
|
||||
seriesNames.addAll(flatMatchAll(names, compile(String.join("|", whitelist), CASE_INSENSITIVE | UNICODE_CHARACTER_CLASS), threshold, false));
|
||||
seriesNames.addAll(flatMatchAll(names, compile(join(whitelist, "|"), CASE_INSENSITIVE | UNICODE_CHARACTER_CLASS), threshold, false));
|
||||
|
||||
// 2. use common word sequences
|
||||
seriesNames.addAll(whitelist);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package net.filebot.subtitle;
|
||||
|
||||
import static net.filebot.util.StringUtilities.*;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
|
@ -48,7 +50,7 @@ public class SubRipReader extends SubtitleReader {
|
|||
lines.add(line);
|
||||
}
|
||||
|
||||
return new SubtitleElement(t1, t2, resolve(String.join("\n", lines)));
|
||||
return new SubtitleElement(t1, t2, resolve(join(lines, "\n")));
|
||||
}
|
||||
|
||||
protected String resolve(String text) {
|
||||
|
|
|
@ -6,6 +6,7 @@ import static net.filebot.Settings.*;
|
|||
import static net.filebot.WebServices.*;
|
||||
import static net.filebot.media.MediaDetection.*;
|
||||
import static net.filebot.util.FileUtilities.*;
|
||||
import static net.filebot.util.StringUtilities.*;
|
||||
import static net.filebot.util.ui.SwingUI.*;
|
||||
|
||||
import java.awt.Component;
|
||||
|
@ -285,7 +286,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
|
|||
if (episodes.isEmpty() && !strict) {
|
||||
List<String> detectedSeriesNames = detectSeriesNames(files, useSeriesIndex, useAnimeIndex, locale);
|
||||
String parentPathHint = normalizePathSeparators(getRelativePathTail(files.get(0).getParentFile(), 2).getPath());
|
||||
String suggestion = detectedSeriesNames.size() > 0 ? String.join("; ", detectedSeriesNames) : parentPathHint;
|
||||
String suggestion = detectedSeriesNames.size() > 0 ? join(detectedSeriesNames, "; ") : parentPathHint;
|
||||
|
||||
List<String> input;
|
||||
synchronized (inputMemory) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package net.filebot.ui.rename;
|
||||
|
||||
import static net.filebot.util.ui.SwingUI.*;
|
||||
import static java.awt.Font.*;
|
||||
import static java.util.Arrays.*;
|
||||
import static java.util.Collections.*;
|
||||
|
@ -9,6 +8,7 @@ import static javax.swing.JOptionPane.*;
|
|||
import static net.filebot.Settings.*;
|
||||
import static net.filebot.UserFiles.*;
|
||||
import static net.filebot.util.FileUtilities.*;
|
||||
import static net.filebot.util.ui.SwingUI.*;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package net.filebot.ui.rename;
|
||||
|
||||
import static net.filebot.util.ui.SwingUI.*;
|
||||
import static java.util.Collections.*;
|
||||
import static net.filebot.util.ui.SwingUI.*;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
|
|
@ -61,8 +61,6 @@ import javax.swing.table.DefaultTableCellRenderer;
|
|||
|
||||
import net.filebot.ResourceManager;
|
||||
import net.filebot.mac.MacAppUtilities;
|
||||
import net.filebot.similarity.EpisodeMetrics;
|
||||
import net.filebot.similarity.MetricCascade;
|
||||
import net.filebot.similarity.SimilarityMetric;
|
||||
import net.filebot.subtitle.SubtitleMetrics;
|
||||
import net.filebot.subtitle.SubtitleNaming;
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.util.regex.Pattern;
|
|||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
|
|
|
@ -4,7 +4,6 @@ import static java.util.Arrays.*;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
|
||||
public final class StringUtilities {
|
||||
|
||||
|
@ -16,6 +15,14 @@ public final class StringUtilities {
|
|||
return object == null || object.toString().length() == 0;
|
||||
}
|
||||
|
||||
public static String join(Iterable<?> values, CharSequence delimiter) {
|
||||
return join(values, delimiter, "", "");
|
||||
}
|
||||
|
||||
public static String join(CharSequence delimiter, Object... values) {
|
||||
return join(asList(values), delimiter, "", "");
|
||||
}
|
||||
|
||||
public static String join(Object[] values, CharSequence delimiter) {
|
||||
return join(asList(values), delimiter, "", "");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package net.filebot.web;
|
||||
|
||||
import static net.filebot.util.StringUtilities.*;
|
||||
|
||||
import java.text.FieldPosition;
|
||||
import java.text.Format;
|
||||
import java.text.ParseException;
|
||||
|
@ -108,8 +110,7 @@ public class EpisodeFormat extends Format {
|
|||
sxe.add(formatSxE(it));
|
||||
title.add(it.getTitle().replaceAll("[(]([^)]*)[)]$", "").trim());
|
||||
}
|
||||
|
||||
return String.format("%s - %s - %s", String.join(" & ", name), String.join(" & ", sxe), String.join(" & ", title));
|
||||
return String.format("%s - %s - %s", join(name, " & "), join(" & ", sxe), join(" & ", title));
|
||||
}
|
||||
|
||||
public String formatMultiSxE(Iterable<Episode> episodes) {
|
||||
|
|
Loading…
Reference in New Issue