aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/BinaryDictionary.java
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2010-05-07 13:43:11 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-05-07 13:43:11 -0700
commit7e615228dedcdf2b390297e2cdfd04ecf9d6ba71 (patch)
treeedb01d555ed689f5d02ceae3191f5281e20843d4 /java/src/com/android/inputmethod/latin/BinaryDictionary.java
parent4c3ff1a76022b1abab86f3fe42e3f7bbd0a341f3 (diff)
parente4e1130d003a75e3b5cbea1678755d2b71d7cb1d (diff)
downloadlatinime-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.java20
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);