diff options
author | 2013-10-09 19:31:47 -0700 | |
---|---|---|
committer | 2013-10-09 19:31:47 -0700 | |
commit | f7b2afdd82d6c98bc3cde22f126cc2129f74f00b (patch) | |
tree | 313317b59b040ba9579e123eef6a7d0838507428 /java/src/com/android/inputmethod/latin/makedict/Ver3DictDecoder.java | |
parent | 80e1b915b95da33b3ae6f44f95d29ffeb406d0a1 (diff) | |
parent | b04568b460837c01f99cc04be81f10077b54c473 (diff) | |
download | latinime-f7b2afdd82d6c98bc3cde22f126cc2129f74f00b.tar.gz latinime-f7b2afdd82d6c98bc3cde22f126cc2129f74f00b.tar.xz latinime-f7b2afdd82d6c98bc3cde22f126cc2129f74f00b.zip |
am b04568b4: am 1522e7be: am cc81a93b: Merge "Add skipPtNode to DictDecoders."
* commit 'b04568b460837c01f99cc04be81f10077b54c473':
Add skipPtNode to DictDecoders.
Diffstat (limited to 'java/src/com/android/inputmethod/latin/makedict/Ver3DictDecoder.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/makedict/Ver3DictDecoder.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/makedict/Ver3DictDecoder.java b/java/src/com/android/inputmethod/latin/makedict/Ver3DictDecoder.java index 848277cd4..75d1058ad 100644 --- a/java/src/com/android/inputmethod/latin/makedict/Ver3DictDecoder.java +++ b/java/src/com/android/inputmethod/latin/makedict/Ver3DictDecoder.java @@ -231,4 +231,40 @@ public class Ver3DictDecoder extends DictDecoder { public boolean hasNextPtNodeArray() { return mDictBuffer.position() != FormatSpec.NO_FORWARD_LINK_ADDRESS; } + + @Override + public void skipPtNode(final FormatOptions formatOptions) { + final int flags = PtNodeReader.readPtNodeOptionFlags(mDictBuffer); + PtNodeReader.readParentAddress(mDictBuffer, formatOptions); + BinaryDictIOUtils.skipString(mDictBuffer, + (flags & FormatSpec.FLAG_HAS_MULTIPLE_CHARS) != 0); + PtNodeReader.readChildrenAddress(mDictBuffer, flags, formatOptions); + if ((flags & FormatSpec.FLAG_IS_TERMINAL) != 0) PtNodeReader.readFrequency(mDictBuffer); + if ((flags & FormatSpec.FLAG_HAS_SHORTCUT_TARGETS) != 0) { + final int shortcutsSize = mDictBuffer.readUnsignedShort(); + mDictBuffer.position(mDictBuffer.position() + shortcutsSize + - FormatSpec.PTNODE_SHORTCUT_LIST_SIZE_SIZE); + } + if ((flags & FormatSpec.FLAG_HAS_BIGRAMS) != 0) { + int bigramCount = 0; + while (bigramCount++ < FormatSpec.MAX_BIGRAMS_IN_A_PTNODE) { + final int bigramFlags = mDictBuffer.readUnsignedByte(); + switch (bigramFlags & FormatSpec.MASK_BIGRAM_ATTR_ADDRESS_TYPE) { + case FormatSpec.FLAG_BIGRAM_ATTR_ADDRESS_TYPE_ONEBYTE: + mDictBuffer.readUnsignedByte(); + break; + case FormatSpec.FLAG_BIGRAM_ATTR_ADDRESS_TYPE_TWOBYTES: + mDictBuffer.readUnsignedShort(); + break; + case FormatSpec.FLAG_BIGRAM_ATTR_ADDRESS_TYPE_THREEBYTES: + mDictBuffer.readUnsignedInt24(); + break; + } + if ((bigramFlags & FormatSpec.FLAG_BIGRAM_SHORTCUT_ATTR_HAS_NEXT) == 0) break; + } + if (bigramCount >= FormatSpec.MAX_BIGRAMS_IN_A_PTNODE) { + throw new RuntimeException("Too many bigrams in a PtNode."); + } + } + } } |