]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - src/com/hughes/android/dictionary/Dictionary.java
1.6
[Dictionary.git] / src / com / hughes / android / dictionary / Dictionary.java
index 05881295287e4be5a1aecd0ae0027bc0ce4ec2ae..dfca94617d2327b67a307c48436ffada79dbd9af 100755 (executable)
@@ -15,6 +15,8 @@ import com.hughes.util.raf.RAFSerializer;
 import com.hughes.util.raf.UniformFileList;\r
 \r
 public final class Dictionary implements RAFSerializable<Dictionary> {\r
+  \r
+  private static final String VERSION_CODE = "DictionaryVersion=1.5";\r
 \r
   static final RAFSerializer<Entry> ENTRY_SERIALIZER = new RAFSerializableSerializer<Entry>(\r
       Entry.RAF_FACTORY);\r
@@ -40,6 +42,9 @@ public final class Dictionary implements RAFSerializable<Dictionary> {
         .getFilePointer()), 10000);\r
     languageDatas[0] = new LanguageData(this, raf, Entry.LANG1);\r
     languageDatas[1] = new LanguageData(this, raf, Entry.LANG2);\r
+    if (!VERSION_CODE.equals(raf.readUTF())) {\r
+      throw new IOException("Invalid dictionary version, expected: " + VERSION_CODE);\r
+    }\r
   }\r
 \r
   public void write(RandomAccessFile raf) throws IOException {\r
@@ -47,6 +52,7 @@ public final class Dictionary implements RAFSerializable<Dictionary> {
     FileList.write(raf, entries, ENTRY_SERIALIZER);\r
     languageDatas[0].write(raf);\r
     languageDatas[1].write(raf);\r
+    raf.writeUTF(VERSION_CODE);\r
   }\r
 \r
   final class LanguageData implements RAFSerializable<LanguageData> {\r
@@ -83,9 +89,9 @@ public final class Dictionary implements RAFSerializable<Dictionary> {
       FileList.write(raf, sortedIndex, INDEX_ENTRY_SERIALIZER);\r
     }\r
 \r
-    String rowToString(final Row row) {\r
+    String rowToString(final Row row, final boolean onlyFirstSubentry) {\r
       return row.isToken() ? sortedIndex.get(row.getIndex()).word : entries\r
-          .get(row.getIndex()).toString();\r
+          .get(row.getIndex()).getRawText(onlyFirstSubentry);\r
     }\r
 \r
     int lookup(String word, final AtomicBoolean interrupted) {\r