diff options
author | 2012-09-20 14:27:33 +0900 | |
---|---|---|
committer | 2012-09-21 12:40:07 +0900 | |
commit | 66597f5e5f3249f418665c1990fb539d2f5565d5 (patch) | |
tree | 0a67e198dd5de7fa8d2d1dd63e59bd550e348f17 /java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java | |
parent | 73779f7631d41f16f89c62cae09a1b27d8189dc3 (diff) | |
download | latinime-66597f5e5f3249f418665c1990fb539d2f5565d5.tar.gz latinime-66597f5e5f3249f418665c1990fb539d2f5565d5.tar.xz latinime-66597f5e5f3249f418665c1990fb539d2f5565d5.zip |
Add deleteWord.
bug: 6669677
Change-Id: I1a5b90ee05e5cffd74a5c140384a3e37c79e7e70
Diffstat (limited to 'java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java index 406071071..397532933 100644 --- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java +++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java @@ -201,4 +201,26 @@ public class BinaryDictIOUtils { } return FormatSpec.NOT_VALID_WORD; } + + /** + * Delete the word from the binary file. + * + * @param buffer the buffer to write. + * @param word the word we delete + * @throws IOException + * @throws UnsupportedFormatException + */ + public static void deleteWord(final FusionDictionaryBufferInterface buffer, + final String word) throws IOException, UnsupportedFormatException { + buffer.position(0); + final FileHeader header = BinaryDictInputOutput.readHeader(buffer); + final int wordPosition = getTerminalPosition(buffer, word); + if (wordPosition == FormatSpec.NOT_VALID_WORD) return; + + buffer.position(wordPosition); + final int flags = buffer.readUnsignedByte(); + final int newFlags = flags ^ FormatSpec.FLAG_IS_TERMINAL; + buffer.position(wordPosition); + buffer.put((byte)newFlags); + } } |