From 82d9deaaf252cd20f8918adbc7a4b9b8f2647c38 Mon Sep 17 00:00:00 2001
From: Yuichiro Hanada
Date: Fri, 21 Sep 2012 21:21:58 +0900
Subject: Combine mHasParentAddress with mHasLinkedListNode into
mSupportsDynamicUpdate.
bug: 6669677
Change-Id: I82799af199358420f09ac34fc005091e202c5d3b
---
.../inputmethod/latin/makedict/FormatSpec.java | 33 ++++++----------------
1 file changed, 8 insertions(+), 25 deletions(-)
(limited to 'java/src/com/android/inputmethod/latin/makedict/FormatSpec.java')
diff --git a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java
index adc6037bb..63a61b46f 100644
--- a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java
+++ b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java
@@ -145,17 +145,14 @@ public final class FormatSpec {
static final int MAXIMUM_SUPPORTED_VERSION = 3;
static final int NOT_A_VERSION_NUMBER = -1;
static final int FIRST_VERSION_WITH_HEADER_SIZE = 2;
- static final int FIRST_VERSION_WITH_PARENT_ADDRESS = 3;
- static final int FIRST_VERSION_WITH_LINKEDLIST_NODE = 3;
+ static final int FIRST_VERSION_WITH_DYNAMIC_UPDATE = 3;
// These options need to be the same numeric values as the one in the native reading code.
static final int GERMAN_UMLAUT_PROCESSING_FLAG = 0x1;
// TODO: Make the native reading code read this variable.
- static final int HAS_PARENT_ADDRESS = 0x2;
+ static final int SUPPORTS_DYNAMIC_UPDATE = 0x2;
static final int FRENCH_LIGATURE_PROCESSING_FLAG = 0x4;
static final int CONTAINS_BIGRAMS_FLAG = 0x8;
- // TODO: Make the native reading code read this variable.
- static final int HAS_LINKEDLIST_NODE = 0x10;
// TODO: Make this value adaptative to content data, store it in the header, and
// use it in the reading code.
@@ -215,31 +212,17 @@ public final class FormatSpec {
*/
public static class FormatOptions {
public final int mVersion;
- public final boolean mHasParentAddress;
- public final boolean mHasLinkedListNode;
+ public final boolean mSupportsDynamicUpdate;
public FormatOptions(final int version) {
this(version, false);
}
- public FormatOptions(final int version, final boolean hasParentAddress) {
- this(version, hasParentAddress, false);
- }
- public FormatOptions(final int version, final boolean hasParentAddress,
- final boolean hasLinkedListNode) {
+ public FormatOptions(final int version, final boolean supportsDynamicUpdate) {
mVersion = version;
- if (version < FIRST_VERSION_WITH_PARENT_ADDRESS && hasParentAddress) {
- throw new RuntimeException("Parent addresses are only supported with versions "
- + FIRST_VERSION_WITH_PARENT_ADDRESS + " and ulterior.");
- }
- mHasParentAddress = hasParentAddress;
-
- if (version < FIRST_VERSION_WITH_LINKEDLIST_NODE && hasLinkedListNode) {
- throw new RuntimeException("Linked list nodes are only supported with versions "
- + FIRST_VERSION_WITH_LINKEDLIST_NODE + " and ulterior.");
- }
- if (!hasParentAddress && hasLinkedListNode) {
- throw new RuntimeException("Linked list nodes need parent addresses.");
+ if (version < FIRST_VERSION_WITH_DYNAMIC_UPDATE && supportsDynamicUpdate) {
+ throw new RuntimeException("Dynamic updates are only supported with versions "
+ + FIRST_VERSION_WITH_DYNAMIC_UPDATE + " and ulterior.");
}
- mHasLinkedListNode = hasLinkedListNode;
+ mSupportsDynamicUpdate = supportsDynamicUpdate;
}
}
--
cgit v1.2.3-83-g751a
From 8ec0064c49e80945dbe1bb31129eb890478b7e06 Mon Sep 17 00:00:00 2001
From: Yuichiro Hanada
Date: Thu, 20 Sep 2012 16:21:40 +0900
Subject: Make children addresses and parent addresses use signed addresses.
Signed addresses are used only in version 3 with dynamic update.
bug: 6669677
Change-Id: Iadaeab199b5019d2330b4573c24da74d64f0945e
---
.../latin/makedict/BinaryDictInputOutput.java | 212 +++++++++++++++------
.../inputmethod/latin/makedict/FormatSpec.java | 21 +-
2 files changed, 166 insertions(+), 67 deletions(-)
(limited to 'java/src/com/android/inputmethod/latin/makedict/FormatSpec.java')
diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java
index 4806bf9dc..d4a4d7cda 100644
--- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java
+++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java
@@ -36,7 +36,6 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import java.util.Stack;
import java.util.TreeMap;
/**
@@ -412,6 +411,10 @@ public class BinaryDictInputOutput {
}
}
+ private static final int UINT8_MAX = 0xFF;
+ private static final int UINT16_MAX = 0xFFFF;
+ private static final int UINT24_MAX = 0xFFFFFF;
+
/**
* Compute the size, in bytes, that an address will occupy.
*
@@ -423,17 +426,25 @@ public class BinaryDictInputOutput {
* @return the byte size.
*/
private static int getByteSize(final int address) {
- assert(address < 0x1000000);
+ assert(address <= UINT24_MAX);
if (!hasChildrenAddress(address)) {
return 0;
- } else if (Math.abs(address) < 0x100) {
+ } else if (Math.abs(address) <= UINT8_MAX) {
return 1;
- } else if (Math.abs(address) < 0x10000) {
+ } else if (Math.abs(address) <= UINT16_MAX) {
return 2;
} else {
return 3;
}
}
+
+ private static final int SINT8_MAX = 0x7F;
+ private static final int SINT16_MAX = 0x7FFF;
+ private static final int SINT24_MAX = 0x7FFFFF;
+ private static final int MSB8 = 0x80;
+ private static final int MSB16 = 0x8000;
+ private static final int MSB24 = 0x800000;
+
// End utility methods.
// This method is responsible for finding a nice ordering of the nodes that favors run-time
@@ -509,13 +520,19 @@ public class BinaryDictInputOutput {
}
int groupSize = getGroupHeaderSize(group, formatOptions);
if (group.isTerminal()) groupSize += FormatSpec.GROUP_FREQUENCY_SIZE;
- if (null != group.mChildren) {
+ if (null == group.mChildren && formatOptions.mSupportsDynamicUpdate) {
+ groupSize += FormatSpec.SIGNED_CHILDREN_ADDRESS_SIZE;
+ } else if (null != group.mChildren) {
final int offsetBasePoint = groupSize + node.mCachedAddress + size;
final int offset = group.mChildren.mCachedAddress - offsetBasePoint;
// assign my address to children's parent address
group.mChildren.mCachedParentAddress = group.mCachedAddress
- group.mChildren.mCachedAddress;
- groupSize += getByteSize(offset);
+ if (formatOptions.mSupportsDynamicUpdate) {
+ groupSize += FormatSpec.SIGNED_CHILDREN_ADDRESS_SIZE;
+ } else {
+ groupSize += getByteSize(offset);
+ }
}
groupSize += getShortcutListSize(group.mShortcutTargets);
if (null != group.mBigrams) {
@@ -669,27 +686,52 @@ public class BinaryDictInputOutput {
}
}
+ /**
+ * Helper method to write a variable-size signed address to a file.
+ *
+ * @param buffer the buffer to write to.
+ * @param index the index in the buffer to write the address to.
+ * @param address the address to write.
+ * @return the size in bytes the address actually took.
+ */
+ private static int writeVariableSignedAddress(final byte[] buffer, int index,
+ final int address) {
+ if (!hasChildrenAddress(address)) {
+ buffer[index] = buffer[index + 1] = buffer[index + 2] = 0;
+ } else {
+ final int absAddress = Math.abs(address);
+ buffer[index++] = (byte)((address < 0 ? MSB8 : 0) | (0xFF & (absAddress >> 16)));
+ buffer[index++] = (byte)(0xFF & (absAddress >> 8));
+ buffer[index++] = (byte)(0xFF & absAddress);
+ }
+ return 3;
+ }
+
private static byte makeCharGroupFlags(final CharGroup group, final int groupAddress,
- final int childrenOffset) {
+ final int childrenOffset, final FormatOptions formatOptions) {
byte flags = 0;
if (group.mChars.length > 1) flags |= FormatSpec.FLAG_HAS_MULTIPLE_CHARS;
if (group.mFrequency >= 0) {
flags |= FormatSpec.FLAG_IS_TERMINAL;
}
if (null != group.mChildren) {
- switch (getByteSize(childrenOffset)) {
- case 1:
- flags |= FormatSpec.FLAG_GROUP_ADDRESS_TYPE_ONEBYTE;
- break;
- case 2:
- flags |= FormatSpec.FLAG_GROUP_ADDRESS_TYPE_TWOBYTES;
- break;
- case 3:
- flags |= FormatSpec.FLAG_GROUP_ADDRESS_TYPE_THREEBYTES;
- break;
- default:
- throw new RuntimeException("Node with a strange address");
- }
+ final int byteSize = formatOptions.mSupportsDynamicUpdate
+ ? FormatSpec.SIGNED_CHILDREN_ADDRESS_SIZE : getByteSize(childrenOffset);
+ switch (byteSize) {
+ case 1:
+ flags |= FormatSpec.FLAG_GROUP_ADDRESS_TYPE_ONEBYTE;
+ break;
+ case 2:
+ flags |= FormatSpec.FLAG_GROUP_ADDRESS_TYPE_TWOBYTES;
+ break;
+ case 3:
+ flags |= FormatSpec.FLAG_GROUP_ADDRESS_TYPE_THREEBYTES;
+ break;
+ default:
+ throw new RuntimeException("Node with a strange address");
+ }
+ } else if (formatOptions.mSupportsDynamicUpdate) {
+ flags |= FormatSpec.FLAG_GROUP_ADDRESS_TYPE_THREEBYTES;
}
if (null != group.mShortcutTargets) {
if (DBG && 0 == group.mShortcutTargets.size()) {
@@ -808,6 +850,25 @@ public class BinaryDictInputOutput {
+ (frequency & FormatSpec.FLAG_ATTRIBUTE_FREQUENCY);
}
+ private static final int writeParentAddress(final byte[] buffer, final int index,
+ final int address, final FormatOptions formatOptions) {
+ if (supportsDynamicUpdate(formatOptions)) {
+ if (address == FormatSpec.NO_PARENT_ADDRESS) {
+ buffer[index] = buffer[index + 1] = buffer[index + 2] = 0;
+ } else {
+ final int absAddress = Math.abs(address);
+ assert(absAddress <= SINT24_MAX);
+ buffer[index] = (byte)((address < 0 ? MSB8 : 0)
+ | ((absAddress >> 16) & 0xFF));
+ buffer[index + 1] = (byte)((absAddress >> 8) & 0xFF);
+ buffer[index + 2] = (byte)(absAddress & 0xFF);
+ }
+ return index + 3;
+ } else {
+ return index;
+ }
+ }
+
/**
* Write a node to memory. The node is expected to have its final position cached.
*
@@ -854,22 +915,15 @@ public class BinaryDictInputOutput {
final int childrenOffset = null == group.mChildren
? FormatSpec.NO_CHILDREN_ADDRESS
: group.mChildren.mCachedAddress - groupAddress;
- byte flags = makeCharGroupFlags(group, groupAddress, childrenOffset);
+ byte flags = makeCharGroupFlags(group, groupAddress, childrenOffset, formatOptions);
buffer[index++] = flags;
- if (supportsDynamicUpdate(formatOptions)) {
- if (parentAddress == FormatSpec.NO_PARENT_ADDRESS) {
- // this node is the root node.
- buffer[index] = buffer[index + 1] = buffer[index + 2] = 0;
- } else {
- // write parent address. (version 3)
- final int actualParentAddress = Math.abs(parentAddress
- + (node.mCachedAddress - group.mCachedAddress));
- buffer[index] = (byte)((actualParentAddress >> 16) & 0xFF);
- buffer[index + 1] = (byte)((actualParentAddress >> 8) & 0xFF);
- buffer[index + 2] = (byte)(actualParentAddress & 0xFF);
- }
- index += 3;
+ if (parentAddress == FormatSpec.NO_PARENT_ADDRESS) {
+ index = writeParentAddress(buffer, index, parentAddress, formatOptions);
+ } else {
+ index = writeParentAddress(buffer, index,
+ parentAddress + (node.mCachedAddress - group.mCachedAddress),
+ formatOptions);
}
index = CharEncoding.writeCharArray(group.mChars, buffer, index);
@@ -879,7 +933,13 @@ public class BinaryDictInputOutput {
if (group.mFrequency >= 0) {
buffer[index++] = (byte) group.mFrequency;
}
- final int shift = writeVariableAddress(buffer, index, childrenOffset);
+
+ final int shift;
+ if (formatOptions.mSupportsDynamicUpdate) {
+ shift = writeVariableSignedAddress(buffer, index, childrenOffset);
+ } else {
+ shift = writeVariableAddress(buffer, index, childrenOffset);
+ }
index += shift;
groupAddress += shift;
@@ -1104,6 +1164,58 @@ public class BinaryDictInputOutput {
// Input methods: Read a binary dictionary to memory.
// readDictionaryBinary is the public entry point for them.
+ private static int getChildrenAddressSize(final int optionFlags,
+ final FormatOptions formatOptions) {
+ if (formatOptions.mSupportsDynamicUpdate) return FormatSpec.SIGNED_CHILDREN_ADDRESS_SIZE;
+ switch (optionFlags & FormatSpec.MASK_GROUP_ADDRESS_TYPE) {
+ case FormatSpec.FLAG_GROUP_ADDRESS_TYPE_ONEBYTE:
+ return 1;
+ case FormatSpec.FLAG_GROUP_ADDRESS_TYPE_TWOBYTES:
+ return 2;
+ case FormatSpec.FLAG_GROUP_ADDRESS_TYPE_THREEBYTES:
+ return 3;
+ case FormatSpec.FLAG_GROUP_ADDRESS_TYPE_NOADDRESS:
+ default:
+ return 0;
+ }
+ }
+
+ private static int readChildrenAddress(final FusionDictionaryBufferInterface buffer,
+ final int optionFlags, final FormatOptions options) {
+ if (options.mSupportsDynamicUpdate) {
+ final int address = buffer.readUnsignedInt24();
+ if (address == 0) return FormatSpec.NO_CHILDREN_ADDRESS;
+ if ((address & MSB24) != 0) {
+ return -(address & SINT24_MAX);
+ } else {
+ return address;
+ }
+ }
+ int address;
+ switch (optionFlags & FormatSpec.MASK_GROUP_ADDRESS_TYPE) {
+ case FormatSpec.FLAG_GROUP_ADDRESS_TYPE_ONEBYTE:
+ return buffer.readUnsignedByte();
+ case FormatSpec.FLAG_GROUP_ADDRESS_TYPE_TWOBYTES:
+ return buffer.readUnsignedShort();
+ case FormatSpec.FLAG_GROUP_ADDRESS_TYPE_THREEBYTES:
+ return buffer.readUnsignedInt24();
+ case FormatSpec.FLAG_GROUP_ADDRESS_TYPE_NOADDRESS:
+ default:
+ return FormatSpec.NO_CHILDREN_ADDRESS;
+ }
+ }
+
+ private static int readParentAddress(final FusionDictionaryBufferInterface buffer,
+ final FormatOptions formatOptions) {
+ if (supportsDynamicUpdate(formatOptions)) {
+ final int parentAddress = buffer.readUnsignedInt24();
+ final int sign = ((parentAddress & MSB24) != 0) ? -1 : 1;
+ return sign * (parentAddress & SINT24_MAX);
+ } else {
+ return FormatSpec.NO_PARENT_ADDRESS;
+ }
+ }
+
private static final int[] CHARACTER_BUFFER = new int[FormatSpec.MAX_WORD_LENGTH];
public static CharGroupInfo readCharGroup(final FusionDictionaryBufferInterface buffer,
final int originalGroupAddress, final FormatOptions options) {
@@ -1111,13 +1223,9 @@ public class BinaryDictInputOutput {
final int flags = buffer.readUnsignedByte();
++addressPointer;
- final int parentAddress;
+ final int parentAddress = readParentAddress(buffer, options);
if (supportsDynamicUpdate(options)) {
- // read the parent address. (version 3)
- parentAddress = -buffer.readUnsignedInt24();
addressPointer += 3;
- } else {
- parentAddress = FormatSpec.NO_PARENT_ADDRESS;
}
final int characters[];
@@ -1146,25 +1254,11 @@ public class BinaryDictInputOutput {
} else {
frequency = CharGroup.NOT_A_TERMINAL;
}
- int childrenAddress = addressPointer;
- switch (flags & FormatSpec.MASK_GROUP_ADDRESS_TYPE) {
- case FormatSpec.FLAG_GROUP_ADDRESS_TYPE_ONEBYTE:
- childrenAddress += buffer.readUnsignedByte();
- addressPointer += 1;
- break;
- case FormatSpec.FLAG_GROUP_ADDRESS_TYPE_TWOBYTES:
- childrenAddress += buffer.readUnsignedShort();
- addressPointer += 2;
- break;
- case FormatSpec.FLAG_GROUP_ADDRESS_TYPE_THREEBYTES:
- childrenAddress += buffer.readUnsignedInt24();
- addressPointer += 3;
- break;
- case FormatSpec.FLAG_GROUP_ADDRESS_TYPE_NOADDRESS:
- default:
- childrenAddress = FormatSpec.NO_CHILDREN_ADDRESS;
- break;
+ int childrenAddress = readChildrenAddress(buffer, flags, options);
+ if (childrenAddress != FormatSpec.NO_CHILDREN_ADDRESS) {
+ childrenAddress += addressPointer;
}
+ addressPointer += getChildrenAddressSize(flags, options);
ArrayList shortcutTargets = null;
if (0 != (flags & FormatSpec.FLAG_HAS_SHORTCUT_TARGETS)) {
final int pointerBefore = buffer.position();
@@ -1250,6 +1344,7 @@ public class BinaryDictInputOutput {
final String result;
final int originalPointer = buffer.position();
+ buffer.position(address);
if (supportsDynamicUpdate(formatOptions)) {
result = getWordAtAddressWithParentAddress(buffer, headerSize, address, formatOptions);
@@ -1279,7 +1374,6 @@ public class BinaryDictInputOutput {
sGetWordBuffer[index--] =
currentInfo.mCharacters[currentInfo.mCharacters.length - i - 1];
}
-
if (currentInfo.mParentAddress == FormatSpec.NO_PARENT_ADDRESS) break;
currentAddress = currentInfo.mParentAddress + currentInfo.mOriginalAddress;
}
diff --git a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java
index 63a61b46f..cab0661f6 100644
--- a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java
+++ b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java
@@ -42,11 +42,13 @@ public final class FormatSpec {
* ps
*
* f |
- * o | IF HAS_LINKEDLIST_NODE (defined in the file header)
+ * o | IF SUPPORTS_DYNAMIC_UPDATE (defined in the file header)
* r | forward link address, 3byte
- * w | the address must be positive.
- * a |
- * rdlinkaddress
+ * w | 1 byte = bbbbbbbb match
+ * a | case 1xxxxxxx => -((xxxxxxx << 16) + (next byte << 8) + next byte)
+ * r | otherwise => (xxxxxxx << 16) + (next byte << 8) + next byte
+ * d |
+ * linkaddress
*/
/* Node(CharGroup) layout is as follows:
@@ -63,11 +65,13 @@ public final class FormatSpec {
* | is blacklisted ? 1 bit, 1 = yes, 0 = no : FLAG_IS_BLACKLISTED
*
* p |
- * a | IF HAS_PARENT_ADDRESS (defined in the file header)
+ * a | IF SUPPORTS_DYNAMIC_UPDATE (defined in the file header)
* r | parent address, 3byte
- * e | the address must be negative, so the absolute value of the address is stored.
- * n |
- * taddress
+ * e | 1 byte = bbbbbbbb match
+ * n | case 1xxxxxxx => -((0xxxxxxx << 16) + (next byte << 8) + next byte)
+ * t | otherwise => (bbbbbbbb << 16) + (next byte << 8) + next byte
+ * a |
+ * ddress
*
* c | IF FLAG_HAS_MULTIPLE_CHARS
* h | char, char, char, char n * (1 or 3 bytes) : use CharGroupInfo for i/o helpers
@@ -206,6 +210,7 @@ public final class FormatSpec {
// This option needs to be the same numeric value as the one in binary_format.h.
static final int NOT_VALID_WORD = -99;
+ static final int SIGNED_CHILDREN_ADDRESS_SIZE = 3;
/**
* Options about file format.
--
cgit v1.2.3-83-g751a
From 2ee70804e92b17016a2f042c4f6b0e94b5d23e88 Mon Sep 17 00:00:00 2001
From: Yuichiro Hanada
Date: Tue, 25 Sep 2012 20:48:25 +0900
Subject: Add moved char groups.
bug: 6669677
Change-Id: I372f841044fe8e076a50a80ac10b715e5f8fd4eb
---
.../latin/makedict/BinaryDictIOUtils.java | 11 +++++++++--
.../latin/makedict/BinaryDictInputOutput.java | 23 ++++++++++++++++++++--
.../inputmethod/latin/makedict/FormatSpec.java | 20 ++++++++++++-------
3 files changed, 43 insertions(+), 11 deletions(-)
(limited to 'java/src/com/android/inputmethod/latin/makedict/FormatSpec.java')
diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java
index 19da5124a..e2c1254ce 100644
--- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java
+++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java
@@ -85,7 +85,10 @@ public class BinaryDictIOUtils {
}
p.mPosition++;
- if (info.mFrequency != FusionDictionary.CharGroup.NOT_A_TERMINAL) { // found word
+ final boolean isMovedGroup = BinaryDictInputOutput.isMovedGroup(info.mFlags,
+ formatOptions);
+ if (!isMovedGroup
+ && info.mFrequency != FusionDictionary.CharGroup.NOT_A_TERMINAL) {// found word
words.put(info.mOriginalAddress, new String(pushedChars, 0, index));
frequencies.put(info.mOriginalAddress, info.mFrequency);
if (info.mBigrams != null) bigrams.put(info.mOriginalAddress, info.mBigrams);
@@ -109,7 +112,7 @@ public class BinaryDictIOUtils {
p.mAddress = buffer.position();
}
- if (BinaryDictInputOutput.hasChildrenAddress(info.mChildrenAddress)) {
+ if (!isMovedGroup && BinaryDictInputOutput.hasChildrenAddress(info.mChildrenAddress)) {
Position childrenPos = new Position(info.mChildrenAddress + headerSize, index);
stack.push(childrenPos);
}
@@ -168,6 +171,10 @@ public class BinaryDictIOUtils {
final int charGroupPos = buffer.position();
final CharGroupInfo currentInfo = BinaryDictInputOutput.readCharGroup(buffer,
buffer.position(), header.mFormatOptions);
+ if (BinaryDictInputOutput.isMovedGroup(currentInfo.mFlags,
+ header.mFormatOptions)) {
+ continue;
+ }
boolean same = true;
for (int p = 0, j = word.offsetByCodePoints(0, wordPos);
p < currentInfo.mCharacters.length;
diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java
index f9339de08..9fc694218 100644
--- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java
+++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java
@@ -53,6 +53,7 @@ public class BinaryDictInputOutput {
// If the number of passes exceeds this number, makedict bails with an exception on
// suspicion that a bug might be causing an infinite loop.
private static final int MAX_PASSES = 24;
+ private static final int MAX_JUMPS = 12;
public interface FusionDictionaryBufferInterface {
public int readUnsignedByte();
@@ -394,6 +395,13 @@ public class BinaryDictInputOutput {
return FormatSpec.NO_CHILDREN_ADDRESS != address;
}
+ /**
+ * Helper method to check whether the group is moved.
+ */
+ public static boolean isMovedGroup(final int flags, final FormatOptions options) {
+ return options.mSupportsDynamicUpdate && ((flags & FormatSpec.FLAG_IS_MOVED) == 1);
+ }
+
/**
* Helper method to check whether the dictionary can be updated dynamically.
*/
@@ -1374,8 +1382,18 @@ public class BinaryDictInputOutput {
int index = FormatSpec.MAX_WORD_LENGTH - 1;
// the length of the path from the root to the leaf is limited by MAX_WORD_LENGTH
for (int count = 0; count < FormatSpec.MAX_WORD_LENGTH; ++count) {
- buffer.position(currentAddress + headerSize);
- final CharGroupInfo currentInfo = readCharGroup(buffer, currentAddress, options);
+ CharGroupInfo currentInfo;
+ int loopCounter = 0;
+ do {
+ buffer.position(currentAddress + headerSize);
+ currentInfo = readCharGroup(buffer, currentAddress, options);
+ if (isMovedGroup(currentInfo.mFlags, options)) {
+ currentAddress = currentInfo.mParentAddress + currentInfo.mOriginalAddress;
+ }
+ if (DBG && loopCounter++ > MAX_JUMPS) {
+ MakedictLog.d("Too many jumps - probably a bug");
+ }
+ } while (isMovedGroup(currentInfo.mFlags, options));
for (int i = 0; i < currentInfo.mCharacters.length; ++i) {
sGetWordBuffer[index--] =
currentInfo.mCharacters[currentInfo.mCharacters.length - i - 1];
@@ -1457,6 +1475,7 @@ public class BinaryDictInputOutput {
int groupOffset = nodeHeadPosition + getGroupCountSize(count);
for (int i = count; i > 0; --i) { // Scan the array of CharGroup.
CharGroupInfo info = readCharGroup(buffer, groupOffset, options);
+ if (isMovedGroup(info.mFlags, options)) continue;
ArrayList shortcutTargets = info.mShortcutTargets;
ArrayList bigrams = null;
if (null != info.mBigrams) {
diff --git a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java
index cab0661f6..35311f0c2 100644
--- a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java
+++ b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java
@@ -52,13 +52,18 @@ public final class FormatSpec {
*/
/* Node(CharGroup) layout is as follows:
- * | addressType xx : mask with MASK_GROUP_ADDRESS_TYPE
- * 2 bits, 00 = no children : FLAG_GROUP_ADDRESS_TYPE_NOADDRESS
- * f | 01 = 1 byte : FLAG_GROUP_ADDRESS_TYPE_ONEBYTE
- * l | 10 = 2 bytes : FLAG_GROUP_ADDRESS_TYPE_TWOBYTES
- * a | 11 = 3 bytes : FLAG_GROUP_ADDRESS_TYPE_THREEBYTES
- * g | has several chars ? 1 bit, 1 = yes, 0 = no : FLAG_HAS_MULTIPLE_CHARS
- * s | has a terminal ? 1 bit, 1 = yes, 0 = no : FLAG_IS_TERMINAL
+ * | IF !SUPPORTS_DYNAMIC_UPDATE
+ * | addressType xx : mask with MASK_GROUP_ADDRESS_TYPE
+ * | 2 bits, 00 = no children : FLAG_GROUP_ADDRESS_TYPE_NOADDRESS
+ * f | 01 = 1 byte : FLAG_GROUP_ADDRESS_TYPE_ONEBYTE
+ * l | 10 = 2 bytes : FLAG_GROUP_ADDRESS_TYPE_TWOBYTES
+ * a | 11 = 3 bytes : FLAG_GROUP_ADDRESS_TYPE_THREEBYTES
+ * g | ELSE
+ * s | is moved ? 2 bits, 11 = no
+ * | 01 = yes
+ * | the new address is stored in the same place as the parent address
+ * | has several chars ? 1 bit, 1 = yes, 0 = no : FLAG_HAS_MULTIPLE_CHARS
+ * | has a terminal ? 1 bit, 1 = yes, 0 = no : FLAG_IS_TERMINAL
* | has shortcut targets ? 1 bit, 1 = yes, 0 = no : FLAG_HAS_SHORTCUT_TARGETS
* | has bigrams ? 1 bit, 1 = yes, 0 = no : FLAG_HAS_BIGRAMS
* | is not a word ? 1 bit, 1 = yes, 0 = no : FLAG_IS_NOT_A_WORD
@@ -178,6 +183,7 @@ public final class FormatSpec {
static final int FLAG_HAS_BIGRAMS = 0x04;
static final int FLAG_IS_NOT_A_WORD = 0x02;
static final int FLAG_IS_BLACKLISTED = 0x01;
+ static final int FLAG_IS_MOVED = 0x40;
static final int FLAG_ATTRIBUTE_HAS_NEXT = 0x80;
static final int FLAG_ATTRIBUTE_OFFSET_NEGATIVE = 0x40;
--
cgit v1.2.3-83-g751a
From a28a05e971cc242b338331a3b78276fa95188d19 Mon Sep 17 00:00:00 2001
From: "Tadashi G. Takaoka"
Date: Thu, 27 Sep 2012 18:16:16 +0900
Subject: Cleanup: Make some classes as final
Change-Id: I6009b3c1950ba32b7f1e205a3db2307fe0cd688e
---
.../accessibility/AccessibilityEntityProvider.java | 2 +-
.../accessibility/AccessibleKeyboardViewProxy.java | 2 +-
.../accessibility/KeyCodeDescriptionMapper.java | 2 +-
.../inputmethod/compat/AudioManagerCompatWrapper.java | 2 +-
.../compat/InputMethodManagerCompatWrapper.java | 2 +-
java/src/com/android/inputmethod/keyboard/Key.java | 2 +-
.../com/android/inputmethod/keyboard/KeyboardId.java | 2 +-
.../inputmethod/keyboard/KeyboardLayoutSet.java | 10 +++++-----
.../android/inputmethod/keyboard/KeyboardSwitcher.java | 4 ++--
.../android/inputmethod/keyboard/MainKeyboardView.java | 4 ++--
.../android/inputmethod/keyboard/MoreKeysDetector.java | 2 +-
.../android/inputmethod/keyboard/MoreKeysKeyboard.java | 2 +-
.../inputmethod/keyboard/MoreKeysKeyboardView.java | 2 +-
.../android/inputmethod/keyboard/PointerTracker.java | 4 ++--
.../keyboard/internal/AlphabetShiftState.java | 2 +-
.../internal/GestureStrokeWithPreviewPoints.java | 2 +-
.../inputmethod/keyboard/internal/KeySpecParser.java | 4 ++--
.../inputmethod/keyboard/internal/KeyStylesSet.java | 6 +++---
.../keyboard/internal/KeyVisualAttributes.java | 2 +-
.../keyboard/internal/KeyboardCodesSet.java | 2 +-
.../keyboard/internal/KeyboardIconsSet.java | 2 +-
.../inputmethod/keyboard/internal/KeyboardRow.java | 2 +-
.../inputmethod/keyboard/internal/KeyboardState.java | 4 ++--
.../inputmethod/keyboard/internal/KeysCache.java | 2 +-
.../keyboard/internal/PointerTrackerQueue.java | 2 +-
.../keyboard/internal/PreviewPlacerView.java | 4 ++--
.../inputmethod/keyboard/internal/ShiftKeyState.java | 2 +-
.../internal/SuddenJumpingTouchEventHandler.java | 2 +-
.../inputmethod/latin/AdditionalSubtypeSettings.java | 2 +-
.../android/inputmethod/latin/AssetFileAddress.java | 2 +-
.../latin/AudioAndHapticFeedbackManager.java | 2 +-
.../com/android/inputmethod/latin/AutoCorrection.java | 2 +-
.../src/com/android/inputmethod/latin/BackupAgent.java | 2 +-
.../android/inputmethod/latin/BinaryDictionary.java | 2 +-
.../inputmethod/latin/BinaryDictionaryFileDumper.java | 3 +--
.../inputmethod/latin/BinaryDictionaryGetter.java | 6 +++---
.../com/android/inputmethod/latin/BoundedTreeSet.java | 2 +-
.../com/android/inputmethod/latin/DebugSettings.java | 2 +-
.../inputmethod/latin/DebugSettingsActivity.java | 2 +-
.../android/inputmethod/latin/DicTraverseSession.java | 2 +-
.../inputmethod/latin/DictionaryCollection.java | 2 +-
.../android/inputmethod/latin/DictionaryFactory.java | 2 +-
.../latin/DictionaryPackInstallBroadcastReceiver.java | 2 +-
.../inputmethod/latin/ExpandableDictionary.java | 10 +++++-----
.../com/android/inputmethod/latin/FileTransforms.java | 2 +-
.../com/android/inputmethod/latin/InputAttributes.java | 2 +-
.../com/android/inputmethod/latin/InputPointers.java | 2 +-
java/src/com/android/inputmethod/latin/InputView.java | 2 +-
.../android/inputmethod/latin/LastComposedWord.java | 2 +-
java/src/com/android/inputmethod/latin/LatinIME.java | 4 ++--
.../com/android/inputmethod/latin/LatinImeLogger.java | 2 +-
.../android/inputmethod/latin/ResizableIntArray.java | 2 +-
.../android/inputmethod/latin/RichInputConnection.java | 4 ++--
.../android/inputmethod/latin/SettingsActivity.java | 2 +-
.../com/android/inputmethod/latin/SubtypeLocale.java | 2 +-
.../com/android/inputmethod/latin/SubtypeSwitcher.java | 4 ++--
java/src/com/android/inputmethod/latin/Suggest.java | 5 +++--
.../com/android/inputmethod/latin/SuggestedWords.java | 4 ++--
.../SuggestionSpanPickedNotificationReceiver.java | 2 +-
.../SynchronouslyLoadedContactsBinaryDictionary.java | 2 +-
.../latin/SynchronouslyLoadedUserBinaryDictionary.java | 2 +-
.../inputmethod/latin/TargetApplicationGetter.java | 4 ++--
.../inputmethod/latin/UserHistoryDictIOUtils.java | 2 +-
.../inputmethod/latin/UserHistoryDictionary.java | 4 ++--
.../latin/UserHistoryDictionaryBigramList.java | 2 +-
.../latin/UserHistoryForgettingCurveUtils.java | 4 ++--
.../com/android/inputmethod/latin/WordComposer.java | 2 +-
.../com/android/inputmethod/latin/WordListInfo.java | 2 +-
.../com/android/inputmethod/latin/XmlParseUtils.java | 8 ++++----
.../inputmethod/latin/makedict/BinaryDictIOUtils.java | 4 ++--
.../latin/makedict/BinaryDictInputOutput.java | 4 ++--
.../inputmethod/latin/makedict/CharGroupInfo.java | 2 +-
.../android/inputmethod/latin/makedict/FormatSpec.java | 2 +-
.../inputmethod/latin/makedict/FusionDictionary.java | 18 ++++++++----------
.../inputmethod/latin/makedict/MakedictLog.java | 2 +-
.../inputmethod/latin/makedict/PendingAttribute.java | 2 +-
.../latin/makedict/UnsupportedFormatException.java | 2 +-
.../com/android/inputmethod/latin/makedict/Word.java | 2 +-
.../latin/spellcheck/AndroidSpellCheckerService.java | 6 +++---
.../latin/spellcheck/AndroidSpellCheckerSession.java | 2 +-
.../AndroidWordLevelSpellCheckerSession.java | 4 ++--
.../inputmethod/latin/spellcheck/DictAndProximity.java | 2 +-
.../inputmethod/latin/spellcheck/DictionaryPool.java | 2 +-
.../latin/spellcheck/SpellCheckerProximityInfo.java | 6 +++---
.../latin/spellcheck/SpellCheckerSettingsActivity.java | 2 +-
.../latin/spellcheck/SpellCheckerSettingsFragment.java | 2 +-
.../inputmethod/latin/suggestions/MoreSuggestions.java | 8 ++++----
.../latin/suggestions/MoreSuggestionsView.java | 2 +-
.../latin/suggestions/SuggestionStripView.java | 6 +++---
89 files changed, 138 insertions(+), 140 deletions(-)
(limited to 'java/src/com/android/inputmethod/latin/makedict/FormatSpec.java')
diff --git a/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java b/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java
index 5af5d044f..b9b6362fc 100644
--- a/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java
+++ b/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java
@@ -47,7 +47,7 @@ import com.android.inputmethod.latin.CollectionUtils;
* virtual views, thus conveying their logical structure.
*
*/
-public class AccessibilityEntityProvider extends AccessibilityNodeProviderCompat {
+public final class AccessibilityEntityProvider extends AccessibilityNodeProviderCompat {
private static final String TAG = AccessibilityEntityProvider.class.getSimpleName();
private static final int UNDEFINED = Integer.MIN_VALUE;
diff --git a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
index 01220a58a..fcfa6d4e4 100644
--- a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
+++ b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
@@ -32,7 +32,7 @@ import com.android.inputmethod.keyboard.MainKeyboardView;
import com.android.inputmethod.keyboard.PointerTracker;
import com.android.inputmethod.latin.R;
-public class AccessibleKeyboardViewProxy extends AccessibilityDelegateCompat {
+public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateCompat {
private static final AccessibleKeyboardViewProxy sInstance = new AccessibleKeyboardViewProxy();
private InputMethodService mInputMethod;
diff --git a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java
index 5c45448a5..32618ad85 100644
--- a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java
+++ b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java
@@ -30,7 +30,7 @@ import com.android.inputmethod.latin.R;
import java.util.HashMap;
-public class KeyCodeDescriptionMapper {
+public final class KeyCodeDescriptionMapper {
private static final String TAG = KeyCodeDescriptionMapper.class.getSimpleName();
// The resource ID of the string spoken for obscured keys
diff --git a/java/src/com/android/inputmethod/compat/AudioManagerCompatWrapper.java b/java/src/com/android/inputmethod/compat/AudioManagerCompatWrapper.java
index b6c3e2a88..40eed91f2 100644
--- a/java/src/com/android/inputmethod/compat/AudioManagerCompatWrapper.java
+++ b/java/src/com/android/inputmethod/compat/AudioManagerCompatWrapper.java
@@ -20,7 +20,7 @@ import android.media.AudioManager;
import java.lang.reflect.Method;
-public class AudioManagerCompatWrapper {
+public final class AudioManagerCompatWrapper {
private static final Method METHOD_isWiredHeadsetOn = CompatUtils.getMethod(
AudioManager.class, "isWiredHeadsetOn");
private static final Method METHOD_isBluetoothA2dpOn = CompatUtils.getMethod(
diff --git a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java
index cc10a4ed2..a01c301ee 100644
--- a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java
+++ b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java
@@ -27,7 +27,7 @@ import java.lang.reflect.Method;
// TODO: Override this class with the concrete implementation if we need to take care of the
// performance.
-public class InputMethodManagerCompatWrapper {
+public final class InputMethodManagerCompatWrapper {
private static final String TAG = InputMethodManagerCompatWrapper.class.getSimpleName();
private static final Method METHOD_switchToNextInputMethod = CompatUtils.getMethod(
InputMethodManager.class, "switchToNextInputMethod", IBinder.class, Boolean.TYPE);
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index cb120a33e..30812e8c3 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -138,7 +138,7 @@ public class Key implements Comparable {
private final OptionalAttributes mOptionalAttributes;
- private static class OptionalAttributes {
+ private static final class OptionalAttributes {
/** Text to output when pressed. This can be multiple characters, like ".com" */
public final String mOutputText;
public final int mAltCode;
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
index 1e5277345..5e8a8f6bb 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
@@ -33,7 +33,7 @@ import java.util.Locale;
/**
* Unique identifier for each keyboard type.
*/
-public class KeyboardId {
+public final class KeyboardId {
public static final int MODE_TEXT = 0;
public static final int MODE_URL = 1;
public static final int MODE_EMAIL = 2;
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
index d97df7491..c7813ab02 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
@@ -61,7 +61,7 @@ import java.util.HashMap;
* A {@link KeyboardLayoutSet} needs to be created for each
* {@link android.view.inputmethod.EditorInfo}.
*/
-public class KeyboardLayoutSet {
+public final class KeyboardLayoutSet {
private static final String TAG = KeyboardLayoutSet.class.getSimpleName();
private static final boolean DEBUG_CACHE = LatinImeLogger.sDBG;
@@ -77,7 +77,7 @@ public class KeyboardLayoutSet {
CollectionUtils.newHashMap();
private static final KeysCache sKeysCache = new KeysCache();
- public static class KeyboardLayoutSetException extends RuntimeException {
+ public static final class KeyboardLayoutSetException extends RuntimeException {
public final KeyboardId mKeyboardId;
public KeyboardLayoutSetException(final Throwable cause, final KeyboardId keyboardId) {
@@ -86,13 +86,13 @@ public class KeyboardLayoutSet {
}
}
- private static class ElementParams {
+ private static final class ElementParams {
int mKeyboardXmlId;
boolean mProximityCharsCorrectionEnabled;
public ElementParams() {}
}
- private static class Params {
+ private static final class Params {
String mKeyboardLayoutSetName;
int mMode;
EditorInfo mEditorInfo;
@@ -203,7 +203,7 @@ public class KeyboardLayoutSet {
params.mLanguageSwitchKeyEnabled);
}
- public static class Builder {
+ public static final class Builder {
private final Context mContext;
private final String mPackageName;
private final Resources mResources;
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index fd789f029..88d7b667f 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -39,12 +39,12 @@ import com.android.inputmethod.latin.SettingsValues;
import com.android.inputmethod.latin.SubtypeSwitcher;
import com.android.inputmethod.latin.WordComposer;
-public class KeyboardSwitcher implements KeyboardState.SwitchActions {
+public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
private static final String TAG = KeyboardSwitcher.class.getSimpleName();
public static final String PREF_KEYBOARD_LAYOUT = "pref_keyboard_layout_20110916";
- static class KeyboardTheme {
+ static final class KeyboardTheme {
public final int mThemeId;
public final int mStyleId;
diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
index f1fcfe785..b4c9c7d6f 100644
--- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
@@ -83,7 +83,7 @@ import java.util.WeakHashMap;
* @attr ref R.styleable#MainKeyboardView_ignoreAltCodeKeyTimeout
* @attr ref R.styleable#MainKeyboardView_showMoreKeysKeyboardAtTouchPoint
*/
-public class MainKeyboardView extends KeyboardView implements PointerTracker.KeyEventHandler,
+public final class MainKeyboardView extends KeyboardView implements PointerTracker.KeyEventHandler,
SuddenJumpingTouchEventHandler.ProcessMotionEvent {
private static final String TAG = MainKeyboardView.class.getSimpleName();
@@ -136,7 +136,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
private final KeyTimerHandler mKeyTimerHandler;
- private static class KeyTimerHandler extends StaticInnerHandlerWrapper
+ private static final class KeyTimerHandler extends StaticInnerHandlerWrapper
implements TimerProxy {
private static final int MSG_TYPING_STATE_EXPIRED = 0;
private static final int MSG_REPEAT_KEY = 1;
diff --git a/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java b/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java
index cd4e3001e..a2001cb8f 100644
--- a/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java
+++ b/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java
@@ -16,7 +16,7 @@
package com.android.inputmethod.keyboard;
-public class MoreKeysDetector extends KeyDetector {
+public final class MoreKeysDetector extends KeyDetector {
private final int mSlideAllowanceSquare;
private final int mSlideAllowanceSquareTop;
diff --git a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java
index c9af888f9..d7d4be40b 100644
--- a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java
@@ -27,7 +27,7 @@ import com.android.inputmethod.keyboard.internal.MoreKeySpec;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.StringUtils;
-public class MoreKeysKeyboard extends Keyboard {
+public final class MoreKeysKeyboard extends Keyboard {
private final int mDefaultKeyCoordX;
MoreKeysKeyboard(final MoreKeysKeyboardParams params) {
diff --git a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java
index e513a1477..a50617693 100644
--- a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java
@@ -33,7 +33,7 @@ import com.android.inputmethod.latin.R;
* A view that renders a virtual {@link MoreKeysKeyboard}. It handles rendering of keys and
* detecting key presses and touch movements.
*/
-public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel {
+public final class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel {
private final int[] mCoordinates = new int[2];
private final KeyDetector mKeyDetector;
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index ec8f65994..9dae40a93 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -34,7 +34,7 @@ import com.android.inputmethod.research.ResearchLogger;
import java.util.ArrayList;
-public class PointerTracker implements PointerTrackerQueue.Element {
+public final class PointerTracker implements PointerTrackerQueue.Element {
private static final String TAG = PointerTracker.class.getSimpleName();
private static final boolean DEBUG_EVENT = false;
private static final boolean DEBUG_MOVE_EVENT = false;
@@ -121,7 +121,7 @@ public class PointerTracker implements PointerTrackerQueue.Element {
}
}
- static class PointerTrackerParams {
+ static final class PointerTrackerParams {
public final boolean mSlidingKeyInputEnabled;
public final int mTouchNoiseThresholdTime;
public final float mTouchNoiseThresholdDistance;
diff --git a/java/src/com/android/inputmethod/keyboard/internal/AlphabetShiftState.java b/java/src/com/android/inputmethod/keyboard/internal/AlphabetShiftState.java
index 5712df1fc..44aa72a0a 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/AlphabetShiftState.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/AlphabetShiftState.java
@@ -18,7 +18,7 @@ package com.android.inputmethod.keyboard.internal;
import android.util.Log;
-public class AlphabetShiftState {
+public final class AlphabetShiftState {
private static final String TAG = AlphabetShiftState.class.getSimpleName();
private static final boolean DEBUG = false;
diff --git a/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeWithPreviewPoints.java b/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeWithPreviewPoints.java
index 3487b5018..5b3f31805 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeWithPreviewPoints.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeWithPreviewPoints.java
@@ -16,7 +16,7 @@ package com.android.inputmethod.keyboard.internal;
import com.android.inputmethod.latin.ResizableIntArray;
-public class GestureStrokeWithPreviewPoints extends GestureStroke {
+public final class GestureStrokeWithPreviewPoints extends GestureStroke {
public static final int PREVIEW_CAPACITY = 256;
private final ResizableIntArray mPreviewEventTimes = new ResizableIntArray(PREVIEW_CAPACITY);
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java b/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java
index 2a57caa5f..2caa5eb02 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java
@@ -46,7 +46,7 @@ import java.util.Locale;
* Note that the '\' is also parsed by XML parser and CSV parser as well.
* See {@link KeyboardIconsSet} about icon_name.
*/
-public class KeySpecParser {
+public final class KeySpecParser {
private static final boolean DEBUG = LatinImeLogger.sDBG;
private static final int MAX_STRING_REFERENCE_INDIRECTION = 10;
@@ -318,7 +318,7 @@ public class KeySpecParser {
}
@SuppressWarnings("serial")
- public static class KeySpecParserError extends RuntimeException {
+ public static final class KeySpecParserError extends RuntimeException {
public KeySpecParserError(final String message) {
super(message);
}
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyStylesSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyStylesSet.java
index 71fd30563..563d22414 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyStylesSet.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyStylesSet.java
@@ -29,7 +29,7 @@ import org.xmlpull.v1.XmlPullParserException;
import java.util.HashMap;
-public class KeyStylesSet {
+public final class KeyStylesSet {
private static final String TAG = KeyStylesSet.class.getSimpleName();
private static final boolean DEBUG = false;
@@ -45,7 +45,7 @@ public class KeyStylesSet {
mStyles.put(EMPTY_STYLE_NAME, mEmptyKeyStyle);
}
- private static class EmptyKeyStyle extends KeyStyle {
+ private static final class EmptyKeyStyle extends KeyStyle {
EmptyKeyStyle(final KeyboardTextsSet textsSet) {
super(textsSet);
}
@@ -71,7 +71,7 @@ public class KeyStylesSet {
}
}
- private static class DeclaredKeyStyle extends KeyStyle {
+ private static final class DeclaredKeyStyle extends KeyStyle {
private final HashMap mStyles;
private final String mParentStyleName;
private final SparseArray