Package org.astrogrid.samp.gui
Class Transmission
- java.lang.Object
-
- org.astrogrid.samp.gui.Transmission
-
public class Transmission extends java.lang.Object
Describes the properties of a message which has been sent from one client to another. Methods which might change the state of instances of this class should be invoked only from the AWT event dispatch thread.- Since:
- 20 Nov 2008
- Author:
- Mark Taylor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Transmission.Status
Describes the status of a transmission in terms that can be presented in the GUI.
-
Field Summary
Fields Modifier and Type Field Description private long
doneTime_
private java.lang.Throwable
error_
private javax.swing.event.ChangeEvent
evt_
private java.util.List
listenerList_
private static java.util.logging.Logger
logger_
private Message
msg_
private java.lang.String
msgId_
private java.lang.String
msgTag_
private Client
receiver_
private boolean
receiverUnreg_
private Response
response_
private Client
sender_
private boolean
senderUnreg_
-
Constructor Summary
Constructors Constructor Description Transmission(Client sender, Client receiver, Message msg, java.lang.String msgTag, java.lang.String msgId)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChangeListener(javax.swing.event.ChangeListener listener)
Adds a listener which will be notified if the state of this transmission changes (if a response or failure is signalled).private void
fireChange()
Notifies listeners of a state change.long
getDoneTime()
Returns the epoch at which this transmission was completed.java.lang.Throwable
getError()
Returns a Throwable which prevented normal resolution of this transmission.Message
getMessage()
Returns the message which was sent.java.lang.String
getMessageId()
Returns the message ID associated with this message.java.lang.String
getMessageTag()
Returns the message tag corresponding to this transmission.Client
getReceiver()
Returns the client to which this transmission was sent.Response
getResponse()
Returns the response for this transmission.Client
getSender()
Returns the client which sent this transmission.Transmission.Status
getStatus()
Returns an object which describes the current status of this transmission in terms which can be presented to the GUI.boolean
isDone()
Indicates whether further changes to the state of this object are expected, that is if a response/failure is yet to be received.void
removeChangeListener(javax.swing.event.ChangeListener listener)
Removes a listener previously added byaddChangeListener(javax.swing.event.ChangeListener)
.void
setError(java.lang.Throwable error)
Associates an error with this transmission.void
setReceiverUnregistered()
Indicates that the receiver of this transmission has unregistered.void
setResponse(Response response)
Sets the response for this transmission.void
setSenderUnregistered()
Indicates that the sender of this transmission has unregistered.
-
-
-
Field Detail
-
sender_
private final Client sender_
-
receiver_
private final Client receiver_
-
msg_
private final Message msg_
-
msgId_
private final java.lang.String msgId_
-
msgTag_
private final java.lang.String msgTag_
-
listenerList_
private final java.util.List listenerList_
-
evt_
private final javax.swing.event.ChangeEvent evt_
-
response_
private Response response_
-
error_
private java.lang.Throwable error_
-
senderUnreg_
private boolean senderUnreg_
-
receiverUnreg_
private boolean receiverUnreg_
-
doneTime_
private long doneTime_
-
logger_
private static final java.util.logging.Logger logger_
-
-
Method Detail
-
getSender
public Client getSender()
Returns the client which sent this transmission.- Returns:
- sender
-
getReceiver
public Client getReceiver()
Returns the client to which this transmission was sent.- Returns:
- receiver
-
getMessage
public Message getMessage()
Returns the message which was sent.- Returns:
- message
-
getMessageTag
public java.lang.String getMessageTag()
Returns the message tag corresponding to this transmission. Will be null for notify-type sends.- Returns:
- msg tag
-
getMessageId
public java.lang.String getMessageId()
Returns the message ID associated with this message. This is the identifier passed to the receiver which it uses to match messages with responses; it will be null iff the transmission used the notify delivery pattern (no response expected).- Returns:
- msgId; possibly null
-
setResponse
public void setResponse(Response response)
Sets the response for this transmission.- Parameters:
response
- response
-
getResponse
public Response getResponse()
Returns the response for this transmission. Will be null if no response has (yet) arrived.- Returns:
- response
-
setError
public void setError(java.lang.Throwable error)
Associates an error with this transmission. This is probably an indication that the send failed or some other non-SAMP event intervened to prevent normal resolution.- Parameters:
error
- throwable causing the failure
-
getError
public java.lang.Throwable getError()
Returns a Throwable which prevented normal resolution of this transmission.- Returns:
- error
-
setSenderUnregistered
public void setSenderUnregistered()
Indicates that the sender of this transmission has unregistered.
-
setReceiverUnregistered
public void setReceiverUnregistered()
Indicates that the receiver of this transmission has unregistered.
-
getDoneTime
public long getDoneTime()
Returns the epoch at which this transmission was completed. If it is still pending (isDone()
==false), the returned value will be (way) in the future.- Returns:
- value of
System.currentTimeMillis()
at whichisDone()
first returned true
-
isDone
public boolean isDone()
Indicates whether further changes to the state of this object are expected, that is if a response/failure is yet to be received.- Returns:
- true iff no further changes are expected
-
getStatus
public Transmission.Status getStatus()
Returns an object which describes the current status of this transmission in terms which can be presented to the GUI.
-
addChangeListener
public void addChangeListener(javax.swing.event.ChangeListener listener)
Adds a listener which will be notified if the state of this transmission changes (if a response or failure is signalled). TheChangeEvent
s sent to these listeners will have a source which is this Transmission.- Parameters:
listener
- listener to add
-
removeChangeListener
public void removeChangeListener(javax.swing.event.ChangeListener listener)
Removes a listener previously added byaddChangeListener(javax.swing.event.ChangeListener)
.- Parameters:
listener
- listener to remove
-
fireChange
private void fireChange()
Notifies listeners of a state change.
-
-