diff options
author | 2013-01-09 05:07:41 -0800 | |
---|---|---|
committer | 2013-01-09 05:07:42 -0800 | |
commit | 125ad2237072745e4800b7a3907d5507024f35e5 (patch) | |
tree | 0e532db075d05924409912bfcebc41ce326be107 /java/src/com/android/inputmethod/event/Event.java | |
parent | e4d07ac75aabb3efe0dc7f7a4c602baf5d2ad668 (diff) | |
parent | ae74b8cf67ca569b5686214276d56b992cf4557e (diff) | |
download | latinime-125ad2237072745e4800b7a3907d5507024f35e5.tar.gz latinime-125ad2237072745e4800b7a3907d5507024f35e5.tar.xz latinime-125ad2237072745e4800b7a3907d5507024f35e5.zip |
Merge "Abandon the idea of an Event pool and make Event immutable (B1)"
Diffstat (limited to 'java/src/com/android/inputmethod/event/Event.java')
-rw-r--r-- | java/src/com/android/inputmethod/event/Event.java | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/java/src/com/android/inputmethod/event/Event.java b/java/src/com/android/inputmethod/event/Event.java index 215e4dee5..3fe5d5b68 100644 --- a/java/src/com/android/inputmethod/event/Event.java +++ b/java/src/com/android/inputmethod/event/Event.java @@ -54,39 +54,33 @@ public class Event { final private static int NOT_A_CODE_POINT = 0; - private int mType; // The type of event - one of the constants above + final private int mType; // The type of event - one of the constants above // The code point associated with the event, if relevant. This is a unicode code point, and // has nothing to do with other representations of the key. It is only relevant if this event // is the right type: COMMITTABLE or DEAD or TOGGLE, but for a mode key like hankaku/zenkaku or // ctrl, there is no code point associated so this should be NOT_A_CODE_POINT to avoid // unintentional use of its value when it's not relevant. - private int mCodePoint; + final public int mCodePoint; - static Event obtainEvent() { - // TODO: create an event pool instead - return new Event(); + // This method is private - to create a new event, use one of the create* utility methods. + private Event(final int type, final int codePoint) { + mType = type; + mCodePoint = codePoint; } - public void setDeadEvent(final int codePoint) { - mType = EVENT_DEAD; - mCodePoint = codePoint; + public static Event createDeadEvent(final int codePoint) { + return new Event(EVENT_DEAD, codePoint); } - public void setCommittableEvent(final int codePoint) { - mType = EVENT_COMMITTABLE; - mCodePoint = codePoint; + public static Event createCommittableEvent(final int codePoint) { + return new Event(EVENT_COMMITTABLE, codePoint); } - public void setNotHandledEvent() { - mType = EVENT_NOT_HANDLED; - mCodePoint = NOT_A_CODE_POINT; // Just in case + public static Event createNotHandledEvent() { + return new Event(EVENT_NOT_HANDLED, NOT_A_CODE_POINT); } public boolean isCommittable() { return EVENT_COMMITTABLE == mType; } - - public int getCodePoint() { - return mCodePoint; - } } |