diff options
author | 2012-09-20 20:44:31 -0700 | |
---|---|---|
committer | 2012-09-20 20:44:31 -0700 | |
commit | 39f4fca868e9bd4baa501a660daffcf6d51c90b8 (patch) | |
tree | 0a67e198dd5de7fa8d2d1dd63e59bd550e348f17 /java | |
parent | f01862c933fe03dbd411a668629b3ea367102830 (diff) | |
parent | 66597f5e5f3249f418665c1990fb539d2f5565d5 (diff) | |
download | latinime-39f4fca868e9bd4baa501a660daffcf6d51c90b8.tar.gz latinime-39f4fca868e9bd4baa501a660daffcf6d51c90b8.tar.xz latinime-39f4fca868e9bd4baa501a660daffcf6d51c90b8.zip |
am 66597f5e: Add deleteWord.
* commit '66597f5e5f3249f418665c1990fb539d2f5565d5':
Add deleteWord.
Diffstat (limited to 'java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java | 22 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java | 2 |
2 files changed, 23 insertions, 1 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); + } } diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java index 1d3e94bb7..7b8dc5cc5 100644 --- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java +++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java @@ -392,7 +392,7 @@ public class BinaryDictInputOutput { /** * Helper method to check whether the CharGroup has a parent address. */ - private static boolean hasParentAddress(final FormatOptions options) { + public static boolean hasParentAddress(final FormatOptions options) { return options.mVersion >= FormatSpec.FIRST_VERSION_WITH_PARENT_ADDRESS && options.mHasParentAddress; } |