diff --git a/source/net/filebot/Settings.java b/source/net/filebot/Settings.java index 8eb42750..9d2f1c7d 100644 --- a/source/net/filebot/Settings.java +++ b/source/net/filebot/Settings.java @@ -1,7 +1,6 @@ package net.filebot; import static net.filebot.util.FileUtilities.*; -import static net.filebot.util.StringUtilities.*; import java.awt.GraphicsEnvironment; import java.io.File; @@ -286,14 +285,14 @@ public final class Settings { } public static String getApplicationIdentifier() { - return joinBy(" ", getApplicationName(), getApplicationVersion(), String.format("(r%s)", getApplicationRevisionNumber())); + return String.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 joinBy(" ", name, version, headless); + return String.join(" ", name, version, headless); } private static String[] applicationArgumentArray; diff --git a/source/net/filebot/format/MediaBindingBean.java b/source/net/filebot/format/MediaBindingBean.java index e07398ab..d3850de2 100644 --- a/source/net/filebot/format/MediaBindingBean.java +++ b/source/net/filebot/format/MediaBindingBean.java @@ -157,7 +157,7 @@ public class MediaBindingBean { for (Episode it : getEpisodes()) { title.add(removeTrailingBrackets(it.getTitle())); } - return truncateText(join(title, " & "), limit); + return truncateText(String.join(" & ", title), limit); } @Define("d") @@ -353,7 +353,7 @@ public class MediaBindingBean { return null; // e.g. 1280x720 - return join(dim, "x"); + return String.join("x", dim.get(0).toString(), dim.get(1).toString()); } @Define("ws") diff --git a/source/net/filebot/media/MediaDetection.java b/source/net/filebot/media/MediaDetection.java index 8a5dda55..039f79aa 100644 --- a/source/net/filebot/media/MediaDetection.java +++ b/source/net/filebot/media/MediaDetection.java @@ -59,7 +59,6 @@ import net.filebot.similarity.SeriesNameMatcher; import net.filebot.similarity.SimilarityComparator; import net.filebot.similarity.SimilarityMetric; import net.filebot.similarity.StringEqualsMetric; -import net.filebot.util.StringUtilities; import net.filebot.vfs.FileInfo; import net.filebot.web.Episode; import net.filebot.web.Movie; @@ -948,7 +947,7 @@ public class MediaDetection { querySet = getUniqueQuerySet(stripBlacklistedTerms(querySet)); // DEBUG - // System.out.format("Query %s: %s%n", queryLookupService.getName(), querySet); + System.out.format("Query %s: %s%n", queryLookupService.getName(), querySet); final Map probabilityMap = new LinkedHashMap(); final SimilarityMetric metric = getMovieMatchMetric(); @@ -1047,7 +1046,7 @@ public class MediaDetection { relativePath.addFirst(it.getName()); } - return relativePath.isEmpty() ? null : new File(StringUtilities.join(relativePath, File.separator)); + return relativePath.isEmpty() ? null : new File(String.join(File.separator, relativePath)); } public static Map> mapByMediaFolder(Collection files) { diff --git a/source/net/filebot/similarity/EpisodeMetrics.java b/source/net/filebot/similarity/EpisodeMetrics.java index a6be89a4..03c9feb7 100644 --- a/source/net/filebot/similarity/EpisodeMetrics.java +++ b/source/net/filebot/similarity/EpisodeMetrics.java @@ -5,7 +5,6 @@ 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; @@ -431,12 +430,12 @@ public enum EpisodeMetrics implements SimilarityMetric { } // simplify file name if possible and extract numbers - List numbers = new ArrayList(4); + List numbers = new ArrayList(4); Scanner scanner = new Scanner(normalizeObject(object)).useDelimiter("\\D+"); while (scanner.hasNextInt()) { - numbers.add(scanner.nextInt()); + numbers.add(String.valueOf(scanner.nextInt())); } - return join(numbers, " "); + return String.join(" ", numbers); } }), diff --git a/source/net/filebot/similarity/SeriesNameMatcher.java b/source/net/filebot/similarity/SeriesNameMatcher.java index 2db34ce0..13be182d 100644 --- a/source/net/filebot/similarity/SeriesNameMatcher.java +++ b/source/net/filebot/similarity/SeriesNameMatcher.java @@ -4,7 +4,6 @@ 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; @@ -100,7 +99,7 @@ public class SeriesNameMatcher { whitelist.addAll(deepMatchAll(focus, threshold)); // 1. use pattern matching - seriesNames.addAll(flatMatchAll(names, compile(join(whitelist, "|"), CASE_INSENSITIVE | UNICODE_CHARACTER_CLASS), threshold, false)); + seriesNames.addAll(flatMatchAll(names, compile(String.join("|", whitelist), CASE_INSENSITIVE | UNICODE_CHARACTER_CLASS), threshold, false)); // 2. use common word sequences seriesNames.addAll(whitelist); diff --git a/source/net/filebot/subtitle/SubRipReader.java b/source/net/filebot/subtitle/SubRipReader.java index 79158437..be6b7a4b 100644 --- a/source/net/filebot/subtitle/SubRipReader.java +++ b/source/net/filebot/subtitle/SubRipReader.java @@ -1,9 +1,5 @@ - package net.filebot.subtitle; - -import static net.filebot.util.StringUtilities.*; - import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -12,56 +8,52 @@ import java.util.Locale; import java.util.TimeZone; import java.util.regex.Pattern; - public class SubRipReader extends SubtitleReader { - + private final DateFormat timeFormat; private final Pattern tag; - public SubRipReader(Readable source) { super(source); - + // format used to parse time stamps (e.g. 00:02:26,407 --> 00:02:31,356) timeFormat = new SimpleDateFormat("HH:mm:ss,SSS", Locale.ROOT); timeFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - + // pattern for , , , and corresponding end tags tag = Pattern.compile("]*)>", Pattern.CASE_INSENSITIVE); } - @Override protected SubtitleElement readNext() throws Exception { String number = scanner.nextLine(); - + // ignore illegal lines if (!number.matches("\\d+")) return null; - + String[] interval = scanner.nextLine().split("-->", 2); - + // ignore illegal lines if (interval.length < 2) return null; - + long t1 = timeFormat.parse(interval[0].trim()).getTime(); long t2 = timeFormat.parse(interval[1].trim()).getTime(); - + List lines = new ArrayList(2); - + // read all lines until the next empty line for (String line = scanner.nextLine(); line.length() > 0; line = scanner.hasNextLine() ? scanner.nextLine() : "") { lines.add(line); } - - return new SubtitleElement(t1, t2, resolve(join(lines, "\n"))); + + return new SubtitleElement(t1, t2, resolve(String.join("\n", lines))); } - protected String resolve(String text) { // remove tags return tag.matcher(text).replaceAll("").trim(); } - + } diff --git a/source/net/filebot/ui/rename/EpisodeListMatcher.java b/source/net/filebot/ui/rename/EpisodeListMatcher.java index fb702103..add4485c 100644 --- a/source/net/filebot/ui/rename/EpisodeListMatcher.java +++ b/source/net/filebot/ui/rename/EpisodeListMatcher.java @@ -6,7 +6,6 @@ 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; @@ -286,7 +285,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher { if (episodes.isEmpty() && !strict) { List detectedSeriesNames = detectSeriesNames(files, useSeriesIndex, useAnimeIndex, locale); String parentPathHint = normalizePathSeparators(getRelativePathTail(files.get(0).getParentFile(), 2).getPath()); - String suggestion = detectedSeriesNames.size() > 0 ? join(detectedSeriesNames, "; ") : parentPathHint; + String suggestion = detectedSeriesNames.size() > 0 ? String.join("; ", detectedSeriesNames) : parentPathHint; List input; synchronized (inputMemory) { diff --git a/source/net/filebot/ui/rename/FormatDialog.java b/source/net/filebot/ui/rename/FormatDialog.java index 5d1863f9..b3741e08 100644 --- a/source/net/filebot/ui/rename/FormatDialog.java +++ b/source/net/filebot/ui/rename/FormatDialog.java @@ -22,7 +22,6 @@ import java.awt.event.WindowEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; -import java.io.IOException; import java.net.URI; import java.text.Format; import java.util.LinkedHashSet; diff --git a/source/net/filebot/util/UnicodeReader.java b/source/net/filebot/util/UnicodeReader.java index 92b1a3bf..c1f6434e 100644 --- a/source/net/filebot/util/UnicodeReader.java +++ b/source/net/filebot/util/UnicodeReader.java @@ -1,12 +1,14 @@ package net.filebot.util; -import java.io.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; import java.nio.CharBuffer; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import com.ibm.icu.text.CharsetDetector; -import com.ibm.icu.text.CharsetMatch; public class UnicodeReader extends Reader { diff --git a/source/net/filebot/web/EpisodeFormat.java b/source/net/filebot/web/EpisodeFormat.java index 917a592d..4ea1e3d6 100644 --- a/source/net/filebot/web/EpisodeFormat.java +++ b/source/net/filebot/web/EpisodeFormat.java @@ -1,7 +1,5 @@ package net.filebot.web; -import static net.filebot.util.StringUtilities.*; - import java.text.FieldPosition; import java.text.Format; import java.text.ParseException; @@ -111,7 +109,7 @@ public class EpisodeFormat extends Format { title.add(it.getTitle().replaceAll("[(]([^)]*)[)]$", "").trim()); } - return String.format("%s - %s - %s", join(name, " & "), join(sxe, " & "), join(title, " & ")); + return String.format("%s - %s - %s", String.join(" & ", name), String.join(" & ", sxe), String.join(" & ", title)); } public String formatMultiSxE(Iterable episodes) {