* minor refactoring

This commit is contained in:
Reinhard Pointner 2009-07-26 11:15:46 +00:00
parent 57df9b1fbc
commit 7dc46efe68
3 changed files with 17 additions and 12 deletions

View File

@ -120,13 +120,13 @@
<!--
Short-lived memory cache for web responses. Time to live is 5 min. This cache is used by TheTVDBClient and TVRageClient.
Short-lived memory cache for web responses. Time to live is 10 min. This cache is used by TheTVDBClient.
-->
<cache name="web"
maxElementsInMemory="120"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="300"
timeToIdleSeconds="600"
timeToLiveSeconds="600"
overflowToDisk="false"
diskPersistent="false"
memoryStoreEvictionPolicy="LRU"

View File

@ -178,12 +178,9 @@ public class Matcher<V, C> {
// collect disjoint matches
List<Match<V, C>> disjointMatches = new ArrayList<Match<V, C>>();
for (Match<V, C> match : collection) {
List<Match<V, C>> matchListForValue = matchesByValue.get(match.getValue());
List<Match<V, C>> matchListForCandidate = matchesByCandidate.get(match.getCandidate());
for (List<Match<V, C>> 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));
}

View File

@ -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<SubtitleElement> decode(MemoryFile file) throws IOException {
Deque<SubtitleFormat> priorityList = new ArrayDeque<SubtitleFormat>();
LinkedList<SubtitleFormat> priorityList = new LinkedList<SubtitleFormat>();
// 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();