aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/event/Event.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2013-01-09 05:11:26 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2013-01-09 05:11:26 -0800
commit02f580022d279394824d4901621bd8b855c1da3f (patch)
treed9c271692343ba51bbf17dbbaed75ca4ac501301 /java/src/com/android/inputmethod/event/Event.java
parentad61fc8f462644349bd35e9077c24fc98425f961 (diff)
parent125ad2237072745e4800b7a3907d5507024f35e5 (diff)
downloadlatinime-02f580022d279394824d4901621bd8b855c1da3f.tar.gz
latinime-02f580022d279394824d4901621bd8b855c1da3f.tar.xz
latinime-02f580022d279394824d4901621bd8b855c1da3f.zip
am 125ad223: Merge "Abandon the idea of an Event pool and make Event immutable (B1)"
* commit '125ad2237072745e4800b7a3907d5507024f35e5': Abandon the idea of an Event pool and make Event immutable (B1)
Diffstat (limited to '')
-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;
- }
}