diff options
author | 2010-05-07 13:43:11 -0700 | |
---|---|---|
committer | 2010-05-07 13:43:11 -0700 | |
commit | 7e615228dedcdf2b390297e2cdfd04ecf9d6ba71 (patch) | |
tree | edb01d555ed689f5d02ceae3191f5281e20843d4 /java/src/com/android/inputmethod/latin/BinaryDictionary.java | |
parent | 4c3ff1a76022b1abab86f3fe42e3f7bbd0a341f3 (diff) | |
parent | e4e1130d003a75e3b5cbea1678755d2b71d7cb1d (diff) | |
download | latinime-7e615228dedcdf2b390297e2cdfd04ecf9d6ba71.tar.gz latinime-7e615228dedcdf2b390297e2cdfd04ecf9d6ba71.tar.xz latinime-7e615228dedcdf2b390297e2cdfd04ecf9d6ba71.zip |
Merge "Tests and some new constructors to help in testing."
Diffstat (limited to 'java/src/com/android/inputmethod/latin/BinaryDictionary.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/BinaryDictionary.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index 4901b210b..6473f4558 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -68,6 +68,26 @@ public class BinaryDictionary extends Dictionary { } } + /** + * Create a dictionary from a byte buffer. This is used for testing. + * @param context application context for reading resources + * @param resId the resource containing the raw binary dictionary + */ + public BinaryDictionary(Context context, ByteBuffer byteBuffer) { + if (byteBuffer != null) { + if (byteBuffer.isDirect()) { + mNativeDictDirectBuffer = byteBuffer; + } else { + mNativeDictDirectBuffer = ByteBuffer.allocateDirect(byteBuffer.capacity()); + byteBuffer.rewind(); + mNativeDictDirectBuffer.put(byteBuffer); + } + mDictLength = byteBuffer.capacity(); + mNativeDict = openNative(mNativeDictDirectBuffer, + TYPED_LETTER_MULTIPLIER, FULL_WORD_FREQ_MULTIPLIER); + } + } + private native int openNative(ByteBuffer bb, int typedLetterMultiplier, int fullWordMultiplier); private native void closeNative(int dict); private native boolean isValidWordNative(int nativeData, char[] word, int wordLength); |