From: Reimar Döffinger Date: Tue, 21 Apr 2020 21:05:26 +0000 (+0200) Subject: Remove last Java-deserialization based code. X-Git-Url: http://gitweb.fperrin.net/?p=Dictionary.git;a=commitdiff_plain;h=5f7b259669237dad4cbfdec8536537815846979b Remove last Java-deserialization based code. Also remove several unused interface implementations. --- diff --git a/Util b/Util index 3e04251..1997607 160000 --- a/Util +++ b/Util @@ -1 +1 @@ -Subproject commit 3e042511775429bd219a95e7743d074ffd5e9b65 +Subproject commit 199760729eb2bd35b50f893b1814b5b44bfcbef7 diff --git a/src/com/hughes/android/dictionary/engine/Dictionary.java b/src/com/hughes/android/dictionary/engine/Dictionary.java index b9a46a0..cb73714 100644 --- a/src/com/hughes/android/dictionary/engine/Dictionary.java +++ b/src/com/hughes/android/dictionary/engine/Dictionary.java @@ -31,9 +31,8 @@ import com.hughes.util.CachingList; import com.hughes.util.DataInputBuffer; import com.hughes.util.raf.RAFList; import com.hughes.util.raf.RAFListSerializer; -import com.hughes.util.raf.RAFSerializable; -public class Dictionary implements RAFSerializable { +public class Dictionary { private static final int CACHE_SIZE = 5000; @@ -119,7 +118,6 @@ public class Dictionary implements RAFSerializable { } } - @Override public void write(DataOutput out) throws IOException { RandomAccessFile raf = (RandomAccessFile)out; if (dictFileVersion < 7) throw new RuntimeException("write function cannot write formats older than v7!"); diff --git a/src/com/hughes/android/dictionary/engine/Index.java b/src/com/hughes/android/dictionary/engine/Index.java index 364f5b8..5b7b43d 100644 --- a/src/com/hughes/android/dictionary/engine/Index.java +++ b/src/com/hughes/android/dictionary/engine/Index.java @@ -41,13 +41,11 @@ import com.hughes.util.DataInputBuffer; import com.hughes.util.StringUtil; import com.hughes.util.TransformingList; import com.hughes.util.raf.RAFList; -import com.hughes.util.raf.RAFSerializable; import com.hughes.util.raf.RAFSerializer; -import com.hughes.util.raf.SerializableSerializer; import com.hughes.util.raf.UniformRAFList; import com.ibm.icu.text.Transliterator; -public final class Index implements RAFSerializable { +public final class Index { private static final int CACHE_SIZE = 5000; @@ -138,7 +136,14 @@ public final class Index implements RAFSerializable { stoplist.add(raf.readUTF()); } } else if (dict.dictFileVersion >= 4) { - stoplist = new SerializableSerializer>().read(raf); + raf.readInt(); // length + raf.skipBytes(52); + stoplist = new HashSet<>(); + byte b; + while ((b = raf.readByte()) == 0x74) { + stoplist.add(raf.readUTF()); + } + if (b != 0x78) throw new IOException("Invalid data in dictionary stoplist!"); } else { stoplist = Collections.emptySet(); } @@ -147,7 +152,6 @@ public final class Index implements RAFSerializable { CACHE_SIZE, true); } - @Override public void write(final DataOutput out) throws IOException { RandomAccessFile raf = (RandomAccessFile)out; raf.writeUTF(shortName); @@ -182,7 +186,7 @@ public final class Index implements RAFSerializable { } } - public static final class IndexEntry implements RAFSerializable { + public static final class IndexEntry { public final String token; private final String normalizedToken; public final int startRow; diff --git a/src/com/hughes/android/dictionary/engine/PairEntry.java b/src/com/hughes/android/dictionary/engine/PairEntry.java index d779485..a0bcfee 100644 --- a/src/com/hughes/android/dictionary/engine/PairEntry.java +++ b/src/com/hughes/android/dictionary/engine/PairEntry.java @@ -25,11 +25,9 @@ import java.util.regex.Pattern; import com.hughes.util.StringUtil; import com.hughes.util.raf.RAFListSerializerSkippable; -import com.hughes.util.raf.RAFSerializable; import com.ibm.icu.text.Transliterator; -public class PairEntry extends AbstractEntry implements RAFSerializable, - Comparable { +public class PairEntry extends AbstractEntry implements Comparable { public final List pairs; diff --git a/src/com/hughes/android/dictionary/engine/TextEntry.java b/src/com/hughes/android/dictionary/engine/TextEntry.java index 8dd88f4..1856753 100644 --- a/src/com/hughes/android/dictionary/engine/TextEntry.java +++ b/src/com/hughes/android/dictionary/engine/TextEntry.java @@ -22,10 +22,9 @@ import java.util.List; import java.util.regex.Pattern; import com.hughes.util.raf.RAFListSerializer; -import com.hughes.util.raf.RAFSerializable; import com.ibm.icu.text.Transliterator; -public class TextEntry extends AbstractEntry implements RAFSerializable { +public class TextEntry extends AbstractEntry { public final String text;