- java.lang.Object
-
- java.util.EventObject
-
- org.snmp4j.util.RetrievalEvent
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
TableEvent
,TreeEvent
public abstract class RetrievalEvent extends java.util.EventObject
TheRetrievalEvent
is an abstract class representing the result of one or more GET/GETNEXT/GETBULK requests.- Since:
- 1.8
- Version:
- 1.8
- Author:
- Frank Fock
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Exception
exception
protected PDU
reportPDU
protected int
status
static int
STATUS_EXCEPTION
An exception occurred during retrieval operation.static int
STATUS_OK
Retrieval operation was successful.static int
STATUS_REPORT
A report has been received from the agent.static int
STATUS_TIMEOUT
A request to the agent timed out.static int
STATUS_WRONG_ORDER
The agent failed to return the objects in lexicographic order.protected java.lang.Object
userObject
protected VariableBinding[]
vbs
-
Constructor Summary
Constructors Modifier Constructor Description protected
RetrievalEvent(java.util.EventListener source, java.lang.Object userObject)
RetrievalEvent(ResponseListener source, java.lang.Object userObject, VariableBinding[] variableBindings)
Creates a retrieval event with row data.RetrievalEvent(org.snmp4j.util.TreeUtils.TreeRequest source, java.lang.Object userObject, int status)
Creates a retrieval event with a status.RetrievalEvent(org.snmp4j.util.TreeUtils.TreeRequest source, java.lang.Object userObject, java.lang.Exception exception)
Creates a retrieval event with an exception.RetrievalEvent(org.snmp4j.util.TreeUtils.TreeRequest source, java.lang.Object userObject, PDU report)
Creates a retrieval event with a report PDU.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getErrorMessage()
Returns a textual error message for the error.java.lang.Exception
getException()
Gets the exception associated with this event.PDU
getReportPDU()
Gets the report PDU associated with this event.int
getStatus()
Gets the status of the table operation.java.lang.Object
getUserObject()
Gets the user object that has been specified by the user when the retrieval operation that fired this event has been requested.boolean
isError()
Indicates whether the event reports an error or not.java.lang.String
toString()
-
-
-
Field Detail
-
STATUS_OK
public static final int STATUS_OK
Retrieval operation was successful.- See Also:
- Constant Field Values
-
STATUS_TIMEOUT
public static final int STATUS_TIMEOUT
A request to the agent timed out.- See Also:
- Constant Field Values
-
STATUS_WRONG_ORDER
public static final int STATUS_WRONG_ORDER
The agent failed to return the objects in lexicographic order.- See Also:
- Constant Field Values
-
STATUS_REPORT
public static final int STATUS_REPORT
A report has been received from the agent.- See Also:
getReportPDU()
, Constant Field Values
-
STATUS_EXCEPTION
public static final int STATUS_EXCEPTION
An exception occurred during retrieval operation.- See Also:
getException()
, Constant Field Values
-
vbs
protected VariableBinding[] vbs
-
status
protected int status
-
userObject
protected java.lang.Object userObject
-
exception
protected java.lang.Exception exception
-
reportPDU
protected PDU reportPDU
-
-
Constructor Detail
-
RetrievalEvent
protected RetrievalEvent(java.util.EventListener source, java.lang.Object userObject)
-
RetrievalEvent
public RetrievalEvent(org.snmp4j.util.TreeUtils.TreeRequest source, java.lang.Object userObject, int status)
Creates a retrieval event with a status.- Parameters:
source
- the source of the event.userObject
- the user object ornull
.status
- one of the status constants defined for this object.
-
RetrievalEvent
public RetrievalEvent(org.snmp4j.util.TreeUtils.TreeRequest source, java.lang.Object userObject, java.lang.Exception exception)
Creates a retrieval event with an exception.- Parameters:
source
- the source of the event.userObject
- the user object ornull
.exception
- an exception instance.
-
RetrievalEvent
public RetrievalEvent(org.snmp4j.util.TreeUtils.TreeRequest source, java.lang.Object userObject, PDU report)
Creates a retrieval event with a report PDU.- Parameters:
source
- the source of the event.userObject
- the user object ornull
.report
- a PDU of typePDU.REPORT
.
-
RetrievalEvent
public RetrievalEvent(ResponseListener source, java.lang.Object userObject, VariableBinding[] variableBindings)
Creates a retrieval event with row data.- Parameters:
source
- the source of the event.userObject
- the user object ornull
.variableBindings
- an array ofVariableBinding
instances.
-
-
Method Detail
-
getStatus
public int getStatus()
Gets the status of the table operation.- Returns:
- one of the status constants defined for this object.
STATUS_OK
indicates success, all other values indicate failure of the operation which corresponds to a SNMP error status as defined byPDU.getErrorStatus()
.
-
isError
public boolean isError()
Indicates whether the event reports an error or not.- Returns:
true
if the operation failed with an error.
-
getUserObject
public java.lang.Object getUserObject()
Gets the user object that has been specified by the user when the retrieval operation that fired this event has been requested.- Returns:
- an object instance if an user object has been specified or
null
otherwise.
-
getException
public java.lang.Exception getException()
Gets the exception associated with this event.- Returns:
- an Exception instance if there has been an exception instance
associated with this event (
getStatus()
returnsSTATUS_EXCEPTION
), ornull
otherwise.
-
getReportPDU
public PDU getReportPDU()
Gets the report PDU associated with this event.- Returns:
- a
ScopedPDU
instance if there has been a report PDU instance associated with this event (getStatus()
returnsSTATUS_REPORT
), ornull
otherwise.
-
getErrorMessage
public java.lang.String getErrorMessage()
Returns a textual error message for the error.- Returns:
- an error message or an empty string if no error occurred.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.util.EventObject
-
-