public class NetworkEvent
- Object
- ActionEvent
- NetworkEvent
Event containing more meta data for network events which may be error events or
an update for progress indication code.
Fields
public static final int PROGRESS_TYPE_INITIALIZING = 1 | Indicates that a new request is initializing its connection |
public static final int PROGRESS_TYPE_OUTPUT = 2 | Indicates the value for the current output stream writing |
public static final int PROGRESS_TYPE_INPUT = 3 | Indicates the value for the current input stream reading |
public static final int PROGRESS_TYPE_COMPLETED = 4 | Indicates that the connection request has completed |
Constructors
public NetworkEvent(ConnectionRequest source, Exception error) | Constructs an event for an error message |
public NetworkEvent(ConnectionRequest request, int responseCode, String message) | Constructs a response code even |
public NetworkEvent(ConnectionRequest request, int progressType) | Constructs a network status update event used to update progress indicators and application logic of the current state in the NetworkManager |
public NetworkEvent(ConnectionRequest request, Object metaData) | Constructs a callback event from a connection request with some arbitrary associated meta data |
Methods
public ConnectionRequest getConnectionRequest() | Equivalent to getSource() casted to connection request |
public Exception getError() | |
public void setError(Exception error) | |
public int getProgressType() | Indicates the type of progres indication for this event |
public int getResponseCode() | Indicates the response code sent by the response code listener |
public int getLength() | Returns the length of the download event or the upload event in case it is known. |
public int getSentReceived() | Returns the amount of data received up to this event or sent up to this event (depending on the event type). |
public int getProgressPercentage() | Returns the percentage of progress for a download operation assuming length is known |
public Object getMetaData() | |
public String getMessage() |
Inherited nested types
Inherited methods
Field details
PROGRESS_TYPE_INITIALIZING
public static final int PROGRESS_TYPE_INITIALIZING = 1Indicates that a new request is initializing its connection
PROGRESS_TYPE_OUTPUT
public static final int PROGRESS_TYPE_OUTPUT = 2Indicates the value for the current output stream writing
PROGRESS_TYPE_INPUT
public static final int PROGRESS_TYPE_INPUT = 3Indicates the value for the current input stream reading
PROGRESS_TYPE_COMPLETED
public static final int PROGRESS_TYPE_COMPLETED = 4Indicates that the connection request has completed
Constructor details
NetworkEvent
public NetworkEvent(ConnectionRequest source, Exception error)Constructs an event for an error message
Parameters
sourceConnectionRequest- source of the error message
errorException- the exception
NetworkEvent
public NetworkEvent(ConnectionRequest request, int responseCode, String message)Constructs a response code even
Parameters
requestConnectionRequest- the connection request indicating progress
responseCodeint- the code
messageString- the error message
NetworkEvent
public NetworkEvent(ConnectionRequest request, int progressType)Constructs a network status update event used to update progress indicators
and application logic of the current state in the NetworkManager
Parameters
requestConnectionRequest- the connection request indicating progress
progressTypeint- Not documented.
NetworkEvent
public NetworkEvent(ConnectionRequest request, Object metaData)Constructs a callback event from a connection request with some arbitrary associated meta data
Parameters
requestConnectionRequest- the connection request
metaDataObject- the data associated with the event
Method details
getConnectionRequest
public ConnectionRequest getConnectionRequest()Equivalent to getSource() casted to connection request
Returns
the source connection request
getError
public Exception getError()Returns
the error
setError
public void setError(Exception error)Parameters
errorException- the error to set
getProgressType
public int getProgressType()Indicates the type of progres indication for this event
Returns
One of PROGRESS_TYPE_COMPLETED, PROGRESS_TYPE_INITIALIZING, PROGRESS_TYPE_INPUT,
PROGRESS_TYPE_OUTPUT
getResponseCode
public int getResponseCode()Indicates the response code sent by the response code listener
Returns
HTTP error code
getLength
public int getLength()Returns the length of the download event or the upload event in case it is known.
-1 is returned when the value is unknown.
Returns
the length length in bytes or -1
getSentReceived
public int getSentReceived()Returns the amount of data received up to this event or sent up to this event (depending on the
event type).
Returns
the receieved or sent value
getProgressPercentage
public int getProgressPercentage()Returns the percentage of progress for a download operation assuming length is known
Returns
the percentage of the download or -1
getMetaData
public Object getMetaData()Returns
the metaData
getMessage
public String getMessage()Returns
the message