Class NetworkEvent


public class NetworkEvent extends ActionEvent
Event containing more meta data for network events which may be error events or an update for progress indication code.
  • Field Details

    • PROGRESS_TYPE_INITIALIZING

      public static final int PROGRESS_TYPE_INITIALIZING
      Indicates that a new request is initializing its connection
      See Also:
    • PROGRESS_TYPE_OUTPUT

      public static final int PROGRESS_TYPE_OUTPUT
      Indicates the value for the current output stream writing
      See Also:
    • PROGRESS_TYPE_INPUT

      public static final int PROGRESS_TYPE_INPUT
      Indicates the value for the current input stream reading
      See Also:
    • PROGRESS_TYPE_COMPLETED

      public static final int PROGRESS_TYPE_COMPLETED
      Indicates that the connection request has completed
      See Also:
  • Constructor Details

    • NetworkEvent

      public NetworkEvent(ConnectionRequest source, Exception error)

      Constructs an event for an error message

      Parameters
      • source: source of the error message

      • error: the exception

    • NetworkEvent

      public NetworkEvent(ConnectionRequest request, int responseCode, String message)

      Constructs a response code even

      Parameters
      • request: the connection request indicating progress

      • responseCode: the code

      • message: 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
      • request: the connection request indicating progress

      • progressType

    • NetworkEvent

      public NetworkEvent(ConnectionRequest request, Object metaData)

      Constructs a callback event from a connection request with some arbitrary associated meta data

      Parameters
      • request: the connection request

      • metaData: 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
      • error: the error to set
    • getProgressType

      public int getProgressType()

      Indicates the type of progres indication for this event

      Returns
      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