com.objectxp.msg
Class MessageEvent

java.lang.Object
  extended byjava.util.EventObject
      extended bycom.objectxp.msg.MessageEvent
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class MessageEvent
extends java.util.EventObject
implements java.lang.Cloneable

A Message Event. Each event has a certain event type and eventually (depending on the type of event) a Message associated. to it.

In order to receive MessageEvents, you have to register yourself as MessageEventListener with the SmsService.

If the MessageEvent is of type STATUS_REPORT, the Message attached to this event (see getMessage()) can safely be cast to a StatusReportMessage in order to get additional status information.

See Also:
MessageEventListener, StatusReportMessage, Serialized Form

Field Summary
static int DEVICE_NOT_READY
          Event type: connection to the device has been closed (disconnected)
static int DEVICE_NOT_RESPONDING
          Event Type: Device not responding.
static int DEVICE_READY
          Event type: device is ready to use (connected)
static int INCOMING_CALL
          Event Type: Incoming call.
static int MESSAGE_NOT_SENT
          Event Type: Message Not Sent
static int MESSAGE_RECEIVED
          Event Type: Message Received
static int MESSAGE_SENT
          Event Type: Message Sent
static int MULTIPART_FAILURE
          Event Type: not all parts of a MultipartMessage received within a certain time
static int NETWORK_DISCONNECTED
          Event Type: Network registration not ready.
static int RECEIVING_STARTED
          Event Type: Receiving started
static int RECEIVING_STOPPED
          Event Type: Receiving stopped
static int STATUS_RECEIVED
          Event type: status report received
 
Constructor Summary
MessageEvent(int type, Message msg, java.lang.Object source)
          Constructs a MessageEvent with the specified event type and message.
MessageEvent(int type, Message msg, java.lang.Object source, java.lang.Exception exception)
          Constructs a MessageEvent with the specified event type and message.
 
Method Summary
 java.lang.Object clone()
          Create a "deep" copy of this MessageEvent.
 java.lang.Exception getException()
          Return the Exception that triggered this event.
 Message getMessage()
          Get the message associated to this event.
 int getType()
          Returns the type of event (e.g.
 void throwException()
          Throw exception eventually associated with this event.
 java.lang.String toString()
          Returns a "human" readable description of the message event type.
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MESSAGE_RECEIVED

public static final int MESSAGE_RECEIVED
Event Type: Message Received

See Also:
Constant Field Values

MESSAGE_SENT

public static final int MESSAGE_SENT
Event Type: Message Sent

See Also:
Constant Field Values

DEVICE_READY

public static final int DEVICE_READY
Event type: device is ready to use (connected)

See Also:
Constant Field Values

DEVICE_NOT_READY

public static final int DEVICE_NOT_READY
Event type: connection to the device has been closed (disconnected)

See Also:
Constant Field Values

STATUS_RECEIVED

public static final int STATUS_RECEIVED
Event type: status report received

See Also:
Constant Field Values

MESSAGE_NOT_SENT

public static final int MESSAGE_NOT_SENT
Event Type: Message Not Sent

See Also:
Constant Field Values

RECEIVING_STARTED

public static final int RECEIVING_STARTED
Event Type: Receiving started

See Also:
Constant Field Values

RECEIVING_STOPPED

public static final int RECEIVING_STOPPED
Event Type: Receiving stopped

See Also:
Constant Field Values

NETWORK_DISCONNECTED

public static final int NETWORK_DISCONNECTED
Event Type: Network registration not ready. This type of event is broadcasted only by the GsmSmsService

See Also:
Constant Field Values

DEVICE_NOT_RESPONDING

public static final int DEVICE_NOT_RESPONDING
Event Type: Device not responding. This type of event will occur if the keep-alive feature is enabled and keep-alive detects that the communication with the SMSC/GSM device is broken.

Since:
jSMS 1.6
See Also:
Constant Field Values

INCOMING_CALL

public static final int INCOMING_CALL
Event Type: Incoming call. This type of event is broadcasted only by the GsmSmsService when the modem indicates a "RING".

Since:
jSMS 1.6
See Also:
Constant Field Values

MULTIPART_FAILURE

public static final int MULTIPART_FAILURE
Event Type: not all parts of a MultipartMessage received within a certain time

Since:
jSMS 1.7
See Also:
Constant Field Values
Constructor Detail

MessageEvent

public MessageEvent(int type,
                    Message msg,
                    java.lang.Object source)
Constructs a MessageEvent with the specified event type and message. jSMS Applications should not directly create MessageEvent objects.

Parameters:
type - of this event
msg - the message
source - the object on wich the event occurred

MessageEvent

public MessageEvent(int type,
                    Message msg,
                    java.lang.Object source,
                    java.lang.Exception exception)
Constructs a MessageEvent with the specified event type and message. jSMS Applications should not directly create MessageEvent objects.

Parameters:
type - of this event
msg - the message
source - the object on wich the event occurred
exception - the exception that caused this MessageEvent
Method Detail

getType

public int getType()
Returns the type of event (e.g. DEVICE_READY).


getMessage

public Message getMessage()
Get the message associated to this event. If the MessageEvent is of type STATUS_REPORT, the returned Message can safely be cast to a StatusReportMessage.

Returns:
message the Message associated with this event or null for events not refering to a specific message.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Create a "deep" copy of this MessageEvent. The message associated with the event will also be copied.

Throws:
java.lang.CloneNotSupportedException

toString

public java.lang.String toString()
Returns a "human" readable description of the message event type.


getException

public java.lang.Exception getException()
Return the Exception that triggered this event.

Returns:
the Exception that caused the MessageEvent or null.

throwException

public void throwException()
                    throws java.lang.Exception
Throw exception eventually associated with this event. Currently, only the MESSAGE_NOT_SENT event has a exception associated. throwException() is implemented like this:
 Exception ex = getException();
 if( ex != null ) throw ex;
 

Throws:
java.lang.Exception


object XP, Inc. © 2000-2007. All rights reserved object XP