aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/event/Event.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2013-01-09 21:08:58 +0900
committerJean Chalard <jchalard@google.com>2013-01-09 21:08:58 +0900
commitae74b8cf67ca569b5686214276d56b992cf4557e (patch)
treea5b9a58d9294ce04776542e9fb2995c992e8ba19 /java/src/com/android/inputmethod/event/Event.java
parent8315e8168b135599237f5493f72e667f39503006 (diff)
downloadlatinime-ae74b8cf67ca569b5686214276d56b992cf4557e.tar.gz
latinime-ae74b8cf67ca569b5686214276d56b992cf4557e.tar.xz
latinime-ae74b8cf67ca569b5686214276d56b992cf4557e.zip
Abandon the idea of an Event pool and make Event immutable (B1)
Change-Id: I750a07c0c564a95ceac734afa873ca3da9626a7f
Diffstat (limited to 'java/src/com/android/inputmethod/event/Event.java')
-rw-r--r--java/src/com/android/inputmethod/event/Event.java30
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;
- }
}