diff options
author | 2012-10-23 17:14:12 +0900 | |
---|---|---|
committer | 2012-10-25 16:40:15 +0900 | |
commit | b3c98901c5fc1460b54cdf27d74405f27c88e74b (patch) | |
tree | 4b076617d541c97b05249c337b1aeb79980f0182 /java | |
parent | 77fe603a3d82f5fc28816520bac479ff48bf15e5 (diff) | |
download | latinime-b3c98901c5fc1460b54cdf27d74405f27c88e74b.tar.gz latinime-b3c98901c5fc1460b54cdf27d74405f27c88e74b.tar.xz latinime-b3c98901c5fc1460b54cdf27d74405f27c88e74b.zip |
Add auto detection and decoding of dictionary files. (A2)
Bug: 7388852
Change-Id: I25e755fc15f5b383acc046f668e9681efa4f0c2f
Diffstat (limited to 'java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java | 11 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java | 6 |
2 files changed, 15 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java index da5236974..031306e1d 100644 --- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java +++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java @@ -1699,6 +1699,14 @@ public final class BinaryDictInputOutput { } /** + * Helper method to pass a file name instead of a File object to isBinaryDictionary. + */ + public static boolean isBinaryDictionary(final String filename) { + final File file = new File(filename); + return isBinaryDictionary(file); + } + + /** * Basic test to find out whether the file is a binary dictionary or not. * * Concretely this only tests the magic number. @@ -1706,10 +1714,9 @@ public final class BinaryDictInputOutput { * @param filename The name of the file to test. * @return true if it's a binary dictionary, false otherwise */ - public static boolean isBinaryDictionary(final String filename) { + public static boolean isBinaryDictionary(final File file) { FileInputStream inStream = null; try { - final File file = new File(filename); inStream = new FileInputStream(file); final ByteBuffer buffer = inStream.getChannel().map( FileChannel.MapMode.READ_ONLY, 0, file.length()); diff --git a/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java b/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java index 7fd13d78b..44537986b 100644 --- a/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java +++ b/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java @@ -16,6 +16,7 @@ package com.android.inputmethod.latin.makedict; +import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.latin.Constants; import java.util.ArrayList; @@ -141,6 +142,11 @@ public final class FusionDictionary implements Iterable<Word> { return NOT_A_TERMINAL != mFrequency; } + @UsedForTesting + public int getFrequency() { + return mFrequency; + } + public boolean hasSeveralChars() { assert(mChars.length > 0); return 1 < mChars.length; |