From 7dc46efe68972cb99900eb58e26cbd9352b07dde Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sun, 26 Jul 2009 11:15:46 +0000 Subject: [PATCH] * minor refactoring --- source/ehcache.xml | 6 +++--- .../sourceforge/filebot/similarity/Matcher.java | 7 ++----- .../ui/panel/subtitle/SubtitleUtilities.java | 16 ++++++++++++---- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/source/ehcache.xml b/source/ehcache.xml index 0028ab21..1c0ac1a2 100644 --- a/source/ehcache.xml +++ b/source/ehcache.xml @@ -120,13 +120,13 @@ { // collect disjoint matches List> disjointMatches = new ArrayList>(); - for (Match match : collection) { - List> matchListForValue = matchesByValue.get(match.getValue()); - List> matchListForCandidate = matchesByCandidate.get(match.getCandidate()); - + for (List> matchListForValue : matchesByValue.values()) { // check if match is the only element in both lists - if (matchListForValue.size() == 1 && matchListForValue.equals(matchListForCandidate)) { + if (matchListForValue.size() == 1 && matchListForValue.equals(matchesByCandidate.get(matchListForValue.get(0).getCandidate()))) { // match is disjoint :) disjointMatches.add(matchListForValue.get(0)); } diff --git a/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitleUtilities.java b/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitleUtilities.java index c4d62fc2..f4f1ec56 100644 --- a/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitleUtilities.java +++ b/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitleUtilities.java @@ -13,9 +13,8 @@ import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import java.util.ArrayDeque; import java.util.ArrayList; -import java.util.Deque; +import java.util.LinkedList; import java.util.List; import net.sourceforge.filebot.subtitle.SubtitleElement; @@ -26,8 +25,11 @@ import net.sourceforge.tuned.ByteBufferInputStream; final class SubtitleUtilities { + /** + * Decode subtitle file even if extension is invalid. + */ public static List decode(MemoryFile file) throws IOException { - Deque priorityList = new ArrayDeque(); + LinkedList priorityList = new LinkedList(); // gather all formats, put likely formats first for (SubtitleFormat format : SubtitleFormat.values()) { @@ -65,9 +67,12 @@ final class SubtitleUtilities { } + /** + * Calculate MD5 hash. + */ public static String md5(ByteBuffer data) { try { - MessageDigest hash = MessageDigest.getInstance("md-5"); + MessageDigest hash = MessageDigest.getInstance("MD5"); hash.update(data); // return hex string @@ -99,6 +104,9 @@ final class SubtitleUtilities { } + /** + * Write {@link ByteBuffer} to {@link File}. + */ public static void write(ByteBuffer data, File destination) throws IOException { FileChannel fileChannel = new FileOutputStream(destination).getChannel();