com.adventnet.snmp.beans
Class ResultEvent

java.lang.Object
  |
  +--java.util.EventObject
        |
        +--com.adventnet.snmp.beans.ResultEvent
All Implemented Interfaces:
java.io.Serializable

public class ResultEvent
extends java.util.EventObject

This class is the event generated by objects that execute SNMP requests, e.g. SnmpTarget and SNMP Poller bean classes. It contains the result data from a poll, or other SNMP request.

You can get the SNMP response values, or Object IDs ,using the methods of this event object. The response PDU itself can be obtained with

			(SnmpPDU) event.getResponse();
 
although it is usually not necessary since most data of interest is available more directly.

See Also:
SnmpRequestServer, SnmpTarget, SnmpPoller, Serialized Form

Fields inherited from class java.util.EventObject
source
 
Constructor Summary
ResultEvent(java.lang.Object o)
          This instantiates a result event with specified source
ResultEvent(java.lang.Object o, java.lang.Object response)
          This instantiates a result event with specified source, and specified response object, i.e, the SNMP PDU for SNMP requests.
ResultEvent(java.lang.Object o, java.lang.Object response, MibOperations mibOps)
          This instantiates a result event with specified source, and specified response object, i.e, the SNMP PDU for SNMP requests.
ResultEvent(java.lang.Object o, java.lang.Object response, java.lang.String error)
          This instantiates a result event with specified source, specified variable bindings, and specified error message.
ResultEvent(java.lang.Object o, java.lang.Object response, java.lang.String error, int failedreqid)
          This instantiates a result event with specified source, specified variable bindings, specified error message and failed reqestid.
ResultEvent(java.lang.Object o, java.lang.Object response, java.lang.String error, MibOperations mibOps)
          This instantiates a result event with specified source, specified variable bindings, and specified error message.
 
Method Summary
 java.lang.String getErrorString()
          Get the error string reported by the event generator.
 int getFailedRequestID()
          Returns the request ID for failed requests, which may be necessary to track failed requests.
 long getNumericValue()
          This returns the result Numeric value at index 0 as long.
 long getNumericValue(int index)
          This returns the result Numeric value at specified index as long.
 java.math.BigInteger getNumericValueAsBigInt()
          This returns the result Numeric value at index 0 as BigInteger.
 java.math.BigInteger getNumericValueAsBigInt(int index)
          This returns the result Numeric value at specified index as BigInteger.
 long[] getNumericValues()
          This returns the result Numeric values as long[].
 java.math.BigInteger[] getNumericValuesAsBigInt()
          This returns the result Numeric values as BigInteger[].
 int getRequestID()
          Returns the request ID, which may be necessary to track requests.
 java.lang.Object getResponse()
          This returns the response object - SnmpPDU for SNMP requests
 java.lang.String getStringValue()
          This returns the first result String value.
 java.lang.String getStringValue(int index)
          This returns the result String value at requested index.
 java.lang.String[] getStringValues()
          This returns the result String values as string array.
 java.lang.String getValue(int index)
          Returns value at specified index as a String variable.
 java.lang.String[] getValues()
          This returns the result variable values as string array.
 boolean isSuccess()
          Returns whether the request succeeded or failed.
 
Methods inherited from class java.util.EventObject
getSource, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResultEvent

public ResultEvent(java.lang.Object o)
This instantiates a result event with specified source

ResultEvent

public ResultEvent(java.lang.Object o,
                   java.lang.Object response)
This instantiates a result event with specified source, and specified response object, i.e, the SNMP PDU for SNMP requests.

ResultEvent

public ResultEvent(java.lang.Object o,
                   java.lang.Object response,
                   MibOperations mibOps)
This instantiates a result event with specified source, and specified response object, i.e, the SNMP PDU for SNMP requests. It uses MibOperations for specific types like Octet String.

ResultEvent

public ResultEvent(java.lang.Object o,
                   java.lang.Object response,
                   java.lang.String error)
This instantiates a result event with specified source, specified variable bindings, and specified error message. If the error message is null or not provided as an argument, isSuccess() will return true.

ResultEvent

public ResultEvent(java.lang.Object o,
                   java.lang.Object response,
                   java.lang.String error,
                   MibOperations mibOps)
This instantiates a result event with specified source, specified variable bindings, and specified error message. If the error message is null or not provided as an argument, isSuccess() will return true. It uses MibOperations for displaying specific types like Octet String.

ResultEvent

public ResultEvent(java.lang.Object o,
                   java.lang.Object response,
                   java.lang.String error,
                   int failedreqid)
This instantiates a result event with specified source, specified variable bindings, specified error message and failed reqestid. If the error message is null or not provided as an argument, isSuccess() will return true.
Method Detail

isSuccess

public boolean isSuccess()
Returns whether the request succeeded or failed. Timeouts and other failure events are generated if the sendTimeoutEvents parameter is set to true in the generator of this event.

getStringValue

public java.lang.String getStringValue()
                                throws DataException
This returns the first result String value. This will be returned even if the requested variable is a numeric variable, e.g. SnmpInt.
Throws:
DataException - is thrown upon failure

getStringValue

public java.lang.String getStringValue(int index)
                                throws DataException
This returns the result String value at requested index. This will be returned even if the requested variable is a numeric variable, e.g. SnmpInt.
Throws:
DataException - is thrown upon failure

getStringValues

public java.lang.String[] getStringValues()
                                   throws DataException
This returns the result String values as string array. This will be returned even if the requested variable is a numeric variable, e.g. SnmpInt.
Throws:
DataException - is thrown upon failure

getValues

public java.lang.String[] getValues()
                             throws DataException
This returns the result variable values as string array.
Throws:
DataException - is thrown upon failure

getNumericValues

public long[] getNumericValues()
                        throws DataException
This returns the result Numeric values as long[]. Value will be -1 if the requested variable is a not a numeric valued variable, e.g. -1 will be returned for OCTET STRING. Use the getNumericValue(int index) method if you need to verify that the value is non-numeric, as that method throws an exception for non-numeric values.
Throws:
DataException - is thrown upon failure

getNumericValue

public long getNumericValue()
                     throws DataException
This returns the result Numeric value at index 0 as long. An exception will be thrown if the requested variable is a numeric variable, e.g. SnmpString
Throws:
DataException - is thrown upon failure

getNumericValue

public long getNumericValue(int index)
                     throws DataException
This returns the result Numeric value at specified index as long. An exception will be thrown if the requested variable is a numeric variable, e.g. SnmpString
Throws:
DataException - is thrown upon failure or non-numeric value

getNumericValuesAsBigInt

public java.math.BigInteger[] getNumericValuesAsBigInt()
                                                throws DataException
This returns the result Numeric values as BigInteger[]. Value will be -1 if the requested variable is a not a numeric valued variable, e.g. -1 will be returned for OCTET STRING. Use the getNumericValueAsBigInt(int index) method if you need to verify that the value is non-numeric, as that method throws an exception for non-numeric values.
Returns:
an array of BigInteger values holding all the numeric values including Counter64 values and -1 in case of string values.
Throws:
DataException - is thrown upon failure

getNumericValueAsBigInt

public java.math.BigInteger getNumericValueAsBigInt()
                                             throws DataException
This returns the result Numeric value at index 0 as BigInteger. An exception will be thrown if the requested variable is a numeric variable, e.g. SnmpString
Returns:
the numerive value at index 0 as BigInteger
Throws:
DataException - is thrown upon failure

getNumericValueAsBigInt

public java.math.BigInteger getNumericValueAsBigInt(int index)
                                             throws DataException
This returns the result Numeric value at specified index as BigInteger. An exception will be thrown if the requested variable is a numeric variable, e.g. SnmpString
Returns:
the numerive value at the specified index as BigInteger
Throws:
DataException - is thrown upon failure or non-numeric value

getValue

public java.lang.String getValue(int index)
                          throws DataException
Returns value at specified index as a String variable. Works for both numeric and non-numeric.
Throws:
DataException - if the data is not valid

getFailedRequestID

public int getFailedRequestID()
Returns the request ID for failed requests, which may be necessary to track failed requests. A -1 is returned if Request ID not found.

getRequestID

public int getRequestID()
Returns the request ID, which may be necessary to track requests. In case the message version is SNMPv3, then the message ID is returned. A -1 is returned if RequestID/MessageID not found.

getResponse

public java.lang.Object getResponse()
This returns the response object - SnmpPDU for SNMP requests

getErrorString

public java.lang.String getErrorString()
Get the error string reported by the event generator.


Copyright (c)AdventNet Inc., 1996-2004