Module org.snmp4j

Class ResponseEvent<A extends Address>

java.lang.Object
java.util.EventObject
org.snmp4j.event.ResponseEvent<A>
Type Parameters:
A - type of the peer Address.
All Implemented Interfaces:
Serializable

public class ResponseEvent<A extends Address> extends EventObject
ResponseEvent associates a request PDU with the corresponding response and an optional user object.
Version:
3.7.5
Author:
Frank Fock
See Also:
  • Constructor Details

    • ResponseEvent

      public ResponseEvent(Object source, A peerAddress, PDU request, PDU response, Object userObject)
      Creates an ResponseEvent instance.
      Parameters:
      source - the event source.
      peerAddress - the transport address of the entity that send the response.
      request - the request PDU (must not be null).
      response - the response PDU or null if the request timed out.
      userObject - an optional user object.
    • ResponseEvent

      public ResponseEvent(Object source, A peerAddress, PDU request, PDU response, Object userObject, long durationNanos)
      Creates an ResponseEvent instance.
      Parameters:
      source - the event source.
      peerAddress - the transport address of the entity that send the response.
      request - the request PDU (must not be null).
      response - the response PDU or null if the request timed out.
      userObject - an optional user object.
      durationNanos - duration of receiving the response for provided request in nanoseconds.
    • ResponseEvent

      public ResponseEvent(Object source, A peerAddress, PDU request, PDU response, Object userObject, Exception error, long durationNanos)
      Creates an ResponseEvent instance with an exception object indicating a message processing error.
      Parameters:
      source - the event source.
      peerAddress - the transport address of the entity that send the response.
      request - the request PDU (must not be null).
      response - the response PDU or null if the request timed out.
      userObject - an optional user object.
      error - an Exception.
      durationNanos - duration of receiving the response for provided request in nanoseconds.
  • Method Details

    • getRequest

      public PDU getRequest()
      Gets the request PDU.
      Returns:
      a PDU.
    • setPeerAddress

      protected final void setPeerAddress(A peerAddress)
    • setRequest

      protected final void setRequest(PDU request)
    • setResponse

      protected final void setResponse(PDU response)
    • getResponse

      public PDU getResponse()
      Gets the response PDU.
      Returns:
      a PDU instance if a response has been received. If the request timed out then null will be returned.
    • setUserObject

      protected final void setUserObject(Object userObject)
    • getUserObject

      public Object getUserObject()
      Gets the user object that has been supplied to the asynchronous request Session.send(PDU pdu, org.snmp4j.Target target, Object userHandle, ResponseListener listener).
      Returns:
      an Object.
    • getError

      public Exception getError()
      Gets the exception object from the exception that has been generated when the request processing has failed due to an error.
      Returns:
      an Exception instance.
    • getPeerAddress

      public A getPeerAddress()
      Gets the transport address of the response sender.
      Returns:
      the transport Address of the command responder that send this response, or null if no response has been received within the time-out interval or if an error occured (see getError()).
    • getDurationNanos

      public long getDurationNanos()
      Gets the nanoseconds waited between request and response.
      Returns:
      a value greater than 0 represents the nanoseconds Snmp waited until the response was received.
      Since:
      3.7.5