001: /*
002: *
003: *
004: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026:
027: package com.sun.midp.events;
028:
029: /**
030: * This class represents a union of the parameters of all native events.
031: * <p>
032: * Since KNI does not allow creation of Java objects an empty object
033: * must be create at the Java level to be filled in by the native level.
034: * Because the Java level may not know what native event is pending (this
035: * to save native method calls) it the object sent down must be able to
036: * handle the data of any native event.</p>
037: */
038: public class NativeEvent extends Event {
039: /** Construct a native event. */
040: NativeEvent() {
041: /* The native code will fill in the type field. */
042: super (0);
043: }
044:
045: /**
046: * Construct a native event.
047: *
048: * @param type Type ID of the event
049: */
050: public NativeEvent(int type) {
051: super (type);
052: }
053:
054: /** First int parameter for the event. Event dependent. */
055: public int intParam1;
056:
057: /** Second int parameter for the event. Event dependent. */
058: public int intParam2;
059:
060: /** Third int parameter for the event. Event dependent. */
061: public int intParam3;
062:
063: /** Fourth int parameter for the event. Event dependent. */
064: public int intParam4;
065:
066: /** Fifth int parameter for the event. Event dependent. */
067: public int intParam5;
068:
069: /** First string parameter for the event. Event dependent. */
070: public String stringParam1;
071:
072: /** Second string parameter for the event. Event dependent. */
073: public String stringParam2;
074:
075: /** Third string parameter for the event. Event dependent. */
076: public String stringParam3;
077:
078: /** Third string parameter for the event. Event dependent. */
079: public String stringParam4;
080:
081: /** Third string parameter for the event. Event dependent. */
082: public String stringParam5;
083:
084: /** Third string parameter for the event. Event dependent. */
085: public String stringParam6;
086:
087: /**
088: * Clears the parameters, so the event can be reused.
089: */
090: public void clear() {
091: type = 0;
092:
093: intParam1 = 0;
094: intParam2 = 0;
095: intParam3 = 0;
096: intParam4 = 0;
097:
098: stringParam1 = null;
099: stringParam2 = null;
100: stringParam3 = null;
101: stringParam4 = null;
102: stringParam5 = null;
103: stringParam6 = null;
104: }
105:
106: /**
107: * Print the event.
108: *
109: * @return string containing a list of the parameter values
110: */
111: public String toString() {
112: return "Native Event: t = " + type + ", i1 = " + intParam1
113: + ", i2 = " + intParam2 + ", i3 = " + intParam3
114: + ", i4 = " + intParam4 + "\n s1 = " + stringParam1
115: + "\n s2 = " + stringParam2 + "\n s3 = "
116: + stringParam3 + "\n s4 = " + stringParam4
117: + "\n s5 = " + stringParam5 + "\n s6 = "
118: + stringParam6;
119: }
120: }
|