aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/BinaryDictionary.java
diff options
context:
space:
mode:
authorsatok <satok@google.com>2010-05-11 10:37:11 +0900
committersatok <satok@google.com>2010-05-11 10:37:11 +0900
commit912fb384da5fe3b84ac0ef8e5d1d3a70a84c7b5b (patch)
tree86d176921943215c6ff688f5fd7475b1ca30573e /java/src/com/android/inputmethod/latin/BinaryDictionary.java
parentee2ab40c7a5609f5bc7a8a066b666fcb86d2f498 (diff)
parent44357b74a3b7b3eaa5390d1a7427642bcf52dcf9 (diff)
downloadlatinime-912fb384da5fe3b84ac0ef8e5d1d3a70a84c7b5b.tar.gz
latinime-912fb384da5fe3b84ac0ef8e5d1d3a70a84c7b5b.tar.xz
latinime-912fb384da5fe3b84ac0ef8e5d1d3a70a84c7b5b.zip
Merge commit 'goog/master'
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 dc5417e8e..5d3df4e6c 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);