X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=src%2Fcom%2Fhughes%2Fandroid%2Fdictionary%2Fengine%2FDictionary.java;h=c378f8d6edee7e34ae6eff490f5a756c7e2dcdee;hb=83d9dc7cd871082a82c2dd0dbb7a0ceabd7c83a0;hp=4543b7bbc7866a8f0ad022cc52225cfcb26e032e;hpb=0d6b69d8819c937eed8a911f491146b76a9b1300;p=Dictionary.git diff --git a/src/com/hughes/android/dictionary/engine/Dictionary.java b/src/com/hughes/android/dictionary/engine/Dictionary.java index 4543b7b..c378f8d 100644 --- a/src/com/hughes/android/dictionary/engine/Dictionary.java +++ b/src/com/hughes/android/dictionary/engine/Dictionary.java @@ -16,7 +16,6 @@ package com.hughes.android.dictionary.engine; import com.hughes.android.dictionary.DictionaryInfo; import com.hughes.util.CachingList; -import com.hughes.util.StringUtil; import com.hughes.util.raf.RAFList; import com.hughes.util.raf.RAFListSerializer; import com.hughes.util.raf.RAFSerializable; @@ -36,14 +35,14 @@ import java.util.List; public class Dictionary implements RAFSerializable { - static final int CACHE_SIZE = 5000; + private static final int CACHE_SIZE = 5000; - static final int CURRENT_DICT_VERSION = 7; - static final String END_OF_DICTIONARY = "END OF DICTIONARY"; + private static final int CURRENT_DICT_VERSION = 7; + private static final String END_OF_DICTIONARY = "END OF DICTIONARY"; // persisted final int dictFileVersion; - final long creationMillis; + private final long creationMillis; public final String dictInfo; public final List pairEntries; public final List textEntries; @@ -61,12 +60,12 @@ public class Dictionary implements RAFSerializable { this.dictFileVersion = CURRENT_DICT_VERSION; this.creationMillis = System.currentTimeMillis(); this.dictInfo = dictInfo; - pairEntries = new ArrayList(); - textEntries = new ArrayList(); - htmlEntries = new ArrayList(); + pairEntries = new ArrayList<>(); + textEntries = new ArrayList<>(); + htmlEntries = new ArrayList<>(); htmlData = null; - sources = new ArrayList(); - indices = new ArrayList(); + sources = new ArrayList<>(); + indices = new ArrayList<>(); } public Dictionary(final FileChannel ch) throws IOException { @@ -83,7 +82,7 @@ public class Dictionary implements RAFSerializable { try { final RAFList rafSources = RAFList.create(ch, new EntrySource.Serializer( this), ch.position(), dictFileVersion, dictInfo + " sources: "); - sources = new ArrayList(rafSources); + sources = new ArrayList<>(rafSources); ch.position(rafSources.getEndOffset()); pairEntries = CachingList.create( @@ -95,7 +94,7 @@ public class Dictionary implements RAFSerializable { if (dictFileVersion >= 5) { htmlEntries = CachingList.create( RAFList.create(ch, new HtmlEntry.Serializer(this, ch), ch.position(), dictFileVersion, dictInfo + " html: "), - CACHE_SIZE, true); + CACHE_SIZE, false); } else { htmlEntries = Collections.emptyList(); } @@ -107,9 +106,7 @@ public class Dictionary implements RAFSerializable { indices = CachingList.createFullyCached(RAFList.create(ch, new IndexSerializer(ch), ch.position(), dictFileVersion, dictInfo + " index: ")); } catch (RuntimeException e) { - final IOException ioe = new IOException("RuntimeException loading dictionary"); - ioe.initCause(e); - throw ioe; + throw new IOException("RuntimeException loading dictionary", e); } final String end = raf.readUTF(); if (!end.equals(END_OF_DICTIONARY)) { @@ -143,7 +140,7 @@ public class Dictionary implements RAFSerializable { private final class IndexSerializer implements RAFListSerializer { private final FileChannel ch; - public IndexSerializer(FileChannel ch) { + IndexSerializer(FileChannel ch) { this.ch = ch; } @@ -156,11 +153,11 @@ public class Dictionary implements RAFSerializable { public void write(DataOutput raf, Index t) throws IOException { t.write(raf); } - }; + } final RAFListSerializer htmlEntryIndexSerializer = new RAFListSerializer() { @Override - public void write(DataOutput raf, HtmlEntry t) throws IOException { + public void write(DataOutput raf, HtmlEntry t) { assert false; }