# Class NetworkEvent

java.lang.Object
com.codename1.ui.events.ActionEvent
com.codename1.io.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.

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from class ActionEvent

  `ActionEvent.Type`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `PROGRESS_TYPE_COMPLETED`
  Indicates that the connection request has completed
  `static final int`
  `PROGRESS_TYPE_INITIALIZING`
  Indicates that a new request is initializing its connection
  `static final int`
  `PROGRESS_TYPE_INPUT`
  Indicates the value for the current input stream reading
  `static final int`
  `PROGRESS_TYPE_OUTPUT`
  Indicates the value for the current output stream writing

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `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
  `NetworkEvent(ConnectionRequest request, int responseCode, String message)`
  Constructs a response code even
  `NetworkEvent(ConnectionRequest source, Exception error)`
  Constructs an event for an error message
  `NetworkEvent(ConnectionRequest request, Object metaData)`
  Constructs a callback event from a connection request with some arbitrary associated meta data

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ConnectionRequest`
  `getConnectionRequest()`
  Equivalent to getSource() casted to connection request
  `Exception`
  `getError()`

  ###### Returns

  `int`
  `getLength()`
  Returns the length of the download event or the upload event in case it is known.
  `String`
  `getMessage()`

  ###### Returns

  `Object`
  `getMetaData()`

  ###### Returns

  `int`
  `getProgressPercentage()`
  Returns the percentage of progress for a download operation assuming length is known
  `int`
  `getProgressType()`
  Indicates the type of progres indication for this event
  `int`
  `getResponseCode()`
  Indicates the response code sent by the response code listener
  `int`
  `getSentReceived()`
  Returns the amount of data received up to this event or sent up to this event (depending on the event type).
  `void`
  `setError(Exception error)`

  ###### Parameters

  ### Methods inherited from class ActionEvent

  `consume, getActualComponent, getCommand, getComponent, getDraggedComponent, getDropTarget, getEventType, getKeyEvent, getProgress, getSource, getX, getY, isConsumed, isLongEvent, isPointerPressedDuringDrag, setPointerPressedDuringDrag`

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### PROGRESS_TYPE_INITIALIZING

    public static final int PROGRESS_TYPE_INITIALIZING
    Indicates that a new request is initializing its connection
    See Also:
      - Constant Field Values

  - ### PROGRESS_TYPE_OUTPUT

    public static final int PROGRESS_TYPE_OUTPUT
    Indicates the value for the current output stream writing
    See Also:
      - Constant Field Values

  - ### PROGRESS_TYPE_INPUT

    public static final int PROGRESS_TYPE_INPUT
    Indicates the value for the current input stream reading
    See Also:
      - Constant Field Values

  - ### PROGRESS_TYPE_COMPLETED

    public static final int PROGRESS_TYPE_COMPLETED
    Indicates that the connection request has completed
    See Also:
      - Constant Field Values

- ## 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