1 /* 2 * Copyright (C) 2007 Esmertec AG. 3 * Copyright (C) 2007 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package com.android.mms.dom.events; 19 20 import org.w3c.dom.events.Event; 21 import org.w3c.dom.events.EventTarget; 22 23 public class EventImpl implements Event { 24 25 // Event type informations 26 private String mEventType; 27 private boolean mCanBubble; 28 private boolean mCancelable; 29 30 // Flags whether the event type information was set 31 // FIXME: Can we use mEventType for this purpose? 32 private boolean mInitialized; 33 34 // Target of this event 35 private EventTarget mTarget; 36 37 // Event status variables 38 private short mEventPhase; 39 private boolean mStopPropagation; 40 private boolean mPreventDefault; 41 private EventTarget mCurrentTarget; 42 private int mSeekTo; 43 44 private final long mTimeStamp = System.currentTimeMillis(); 45 getBubbles()46 public boolean getBubbles() { 47 return mCanBubble; 48 } 49 getCancelable()50 public boolean getCancelable() { 51 return mCancelable; 52 } 53 getCurrentTarget()54 public EventTarget getCurrentTarget() { 55 return mCurrentTarget; 56 } 57 getEventPhase()58 public short getEventPhase() { 59 return mEventPhase; 60 } 61 getTarget()62 public EventTarget getTarget() { 63 return mTarget; 64 } 65 getTimeStamp()66 public long getTimeStamp() { 67 return mTimeStamp; 68 } 69 getType()70 public String getType() { 71 return mEventType; 72 } 73 initEvent(String eventTypeArg, boolean canBubbleArg, boolean cancelableArg)74 public void initEvent(String eventTypeArg, boolean canBubbleArg, 75 boolean cancelableArg) { 76 mEventType = eventTypeArg; 77 mCanBubble = canBubbleArg; 78 mCancelable = cancelableArg; 79 mInitialized = true; 80 } 81 initEvent(String eventTypeArg, boolean canBubbleArg, boolean cancelableArg, int seekTo)82 public void initEvent(String eventTypeArg, boolean canBubbleArg, boolean cancelableArg, 83 int seekTo) { 84 mSeekTo = seekTo; 85 initEvent(eventTypeArg, canBubbleArg, cancelableArg); 86 } 87 preventDefault()88 public void preventDefault() { 89 mPreventDefault = true; 90 } 91 stopPropagation()92 public void stopPropagation() { 93 mStopPropagation = true; 94 } 95 96 /* 97 * Internal Interface 98 */ 99 isInitialized()100 boolean isInitialized() { 101 return mInitialized; 102 } 103 isPreventDefault()104 boolean isPreventDefault() { 105 return mPreventDefault; 106 } 107 isPropogationStopped()108 boolean isPropogationStopped() { 109 return mStopPropagation; 110 } 111 setTarget(EventTarget target)112 void setTarget(EventTarget target) { 113 mTarget = target; 114 } 115 setEventPhase(short eventPhase)116 void setEventPhase(short eventPhase) { 117 mEventPhase = eventPhase; 118 } 119 setCurrentTarget(EventTarget currentTarget)120 void setCurrentTarget(EventTarget currentTarget) { 121 mCurrentTarget = currentTarget; 122 } 123 getSeekTo()124 public int getSeekTo() { 125 return mSeekTo; 126 } 127 } 128