X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=src%2Fcom%2Fhughes%2Fandroid%2Fdictionary%2FDictionary.java;h=dfca94617d2327b67a307c48436ffada79dbd9af;hb=2a44e23be1341d10761765f749788f335555d124;hp=05881295287e4be5a1aecd0ae0027bc0ce4ec2ae;hpb=772787ee263d3df5e54761b134db03f5fe813d26;p=Dictionary.git diff --git a/src/com/hughes/android/dictionary/Dictionary.java b/src/com/hughes/android/dictionary/Dictionary.java index 0588129..dfca946 100755 --- a/src/com/hughes/android/dictionary/Dictionary.java +++ b/src/com/hughes/android/dictionary/Dictionary.java @@ -15,6 +15,8 @@ import com.hughes.util.raf.RAFSerializer; import com.hughes.util.raf.UniformFileList; public final class Dictionary implements RAFSerializable { + + private static final String VERSION_CODE = "DictionaryVersion=1.5"; static final RAFSerializer ENTRY_SERIALIZER = new RAFSerializableSerializer( Entry.RAF_FACTORY); @@ -40,6 +42,9 @@ public final class Dictionary implements RAFSerializable { .getFilePointer()), 10000); languageDatas[0] = new LanguageData(this, raf, Entry.LANG1); languageDatas[1] = new LanguageData(this, raf, Entry.LANG2); + if (!VERSION_CODE.equals(raf.readUTF())) { + throw new IOException("Invalid dictionary version, expected: " + VERSION_CODE); + } } public void write(RandomAccessFile raf) throws IOException { @@ -47,6 +52,7 @@ public final class Dictionary implements RAFSerializable { FileList.write(raf, entries, ENTRY_SERIALIZER); languageDatas[0].write(raf); languageDatas[1].write(raf); + raf.writeUTF(VERSION_CODE); } final class LanguageData implements RAFSerializable { @@ -83,9 +89,9 @@ public final class Dictionary implements RAFSerializable { FileList.write(raf, sortedIndex, INDEX_ENTRY_SERIALIZER); } - String rowToString(final Row row) { + String rowToString(final Row row, final boolean onlyFirstSubentry) { return row.isToken() ? sortedIndex.get(row.getIndex()).word : entries - .get(row.getIndex()).toString(); + .get(row.getIndex()).getRawText(onlyFirstSubentry); } int lookup(String word, final AtomicBoolean interrupted) {