com.h3c.util.snmp

## Class SnmpRequest

- java.lang.Object
- - com.h3c.util.snmp.SnmpField
  - - com.h3c.util.snmp.SnmpRequest

- Direct Known Subclasses:
    SnmpTrapRequest

      public class SnmpRequest
      extends SnmpField

  SNMP request message. A request is NOT thread safe it must be worked on by a single thread at a time.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `SnmpRequest.ErrorType`

  - ### Field Summary

    - ### Fields inherited from class com.h3c.util.snmp.SnmpField

      `NULL_FIELD`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Object` | `getAttachedObject()` Returns the attached object associated with this request (if one has been set).
    `SnmpRequest.ErrorType` | `getError()` Returns the current response error.
    `String` | `getLocalizedErrorDescription()` Returns the localized error description for the request.
    `String` | `getLocalizedRequestResponseErrorDescription()` Returns the entire error description which is a combination of the request and response errors.
    `SnmpPdu` | `getPdu()`
    `SnmpPduTrapV1` | `getPduTrapV1()`
    `SnmpResponse` | `getResponse()` Returns the response received for this request (or null)
    `SnmpWalkTable` | `getWalkTable()` Returns the walk table or null if it doesn't exist.
    `boolean` | `isOk()` Query the state of the request.
    `void` | `prepareBulkWalk()` Helper method to prepare the bulk walk.
    `void` | `prepareGetNextWalk()` Helper method to prepare the non-bulk walk.
    `void` | `prepareWalk()`
    `SnmpRequest` | `setAttachedObject(Object attachedObject)` Attaches an object to this request so that it can be recovered when the listner is called back.
    `SnmpRequest` | `setBulkWalkMaxReps(int bulkWalkMaxReps)` Used to configure a bulk walk request before sending.
    `SnmpRequest` | `setBulkWalkType()` Sets the request type as `SnmpFieldType.GET_BULK_REQ`.
    `SnmpRequest` | `setGetType()` Sets the request type as `SnmpFieldType.GET_REQ`.
    `SnmpRequest` | `setSetType()` Sets the request type as `SnmpFieldType.SET_REQ`.
    `SnmpRequest` | `setWalkType()` Sets the request type as `SnmpFieldType.GET_NEXT_REQ`.
    `SnmpRequest` | `setWalkTypeByVersion()` Sets the request type as `SnmpFieldType.GET_NEXT_REQ` or `SnmpFieldType.GET_BULK_REQ` based on version.
    `SnmpRequest` | `setWalkTypeByVersion(int bulkWalkMaxReps)` Sets the request type as `SnmpFieldType.GET_NEXT_REQ` or `SnmpFieldType.GET_BULK_REQ` based on version.
    `String` | `toString()`

    - ### Methods inherited from class com.h3c.util.snmp.SnmpField

      `asBoolean, asBytes, asInt, asIpAddress, asLong, asMacAddress, asOid, asString, asStringValue, asTimeTicksString, getType, read, set, set, set, set, set, set, set, set, setNull, setType, setU32, toDebugString, write`

    - ### Methods inherited from class java.lang.Object

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

- - ### Method Detail

    - #### setBulkWalkMaxReps

          public SnmpRequest setBulkWalkMaxReps(int bulkWalkMaxReps)

      Used to configure a bulk walk request before sending.
      Parameters:
        `bulkWalkMaxReps` - bulk walk max repetition count
      Returns:
        this instance

    - #### setGetType

          public SnmpRequest setGetType()

      Sets the request type as `SnmpFieldType.GET_REQ`.
      Returns:
        this instance

    - #### setSetType

          public SnmpRequest setSetType()

      Sets the request type as `SnmpFieldType.SET_REQ`.
      Returns:
        this instance

    - #### setBulkWalkType

          public SnmpRequest setBulkWalkType()

      Sets the request type as `SnmpFieldType.GET_BULK_REQ`.
      Returns:
        this instance

    - #### setWalkTypeByVersion

          public SnmpRequest setWalkTypeByVersion()

      Sets the request type as `SnmpFieldType.GET_NEXT_REQ` or `SnmpFieldType.GET_BULK_REQ` based on version. If bulk walk is available for this SNMP version the `DEFAULT_BULK_WALK_MAX_REPS` value will be used.
      Returns:
        this instance

    - #### setWalkTypeByVersion

          public SnmpRequest setWalkTypeByVersion(int bulkWalkMaxReps)

      Sets the request type as `SnmpFieldType.GET_NEXT_REQ` or `SnmpFieldType.GET_BULK_REQ` based on version. If bulk walk is available for this SNMP version the passed in max repetition count will be used.
      Parameters:
        `bulkWalkMaxReps` - bulk walk max repetition count
      Returns:
        this instance

    - #### setWalkType

          public SnmpRequest setWalkType()

      Sets the request type as `SnmpFieldType.GET_NEXT_REQ`.
      Returns:
        this instance

    - #### setAttachedObject

          public SnmpRequest setAttachedObject(Object attachedObject)

      Attaches an object to this request so that it can be recovered when the listner is called back.
      Parameters:
        `attachedObject` - attached object
      Returns:
        this instance

    - #### getResponse

          public SnmpResponse getResponse()

      Returns the response received for this request (or null)
      Returns:
        SNMP response message or null if an error occurred

    - #### getError

          public SnmpRequest.ErrorType getError()

      Returns the current response error.
      Returns:
        request error state (could be OK)

    - #### getLocalizedErrorDescription

          public String getLocalizedErrorDescription()

      Returns the localized error description for the request. For both request and response use the request-response method.
      Returns:
        localized error description

    - #### getLocalizedRequestResponseErrorDescription

          public String getLocalizedRequestResponseErrorDescription()

      Returns the entire error description which is a combination of the request and response errors. The error string is localized based on the resource bundle.
      Returns:
        full error description for this request and response pair.
      Throws:
        `MissingResourceException` - if there is a problem with the resource bundle

    - #### isOk

          public boolean isOk()

      Query the state of the request.
      Returns:
        true if the request is not in the error state

    - #### getWalkTable

          public SnmpWalkTable getWalkTable()

      Returns the walk table or null if it doesn't exist.
      Returns:
        walk table or null

    - #### getAttachedObject

          public Object getAttachedObject()

      Returns the attached object associated with this request (if one has been set).
      Returns:
        attached object or null

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `SnmpField`

    - #### prepareWalk

          public void prepareWalk()

    - #### prepareBulkWalk

          public void prepareBulkWalk()

      Helper method to prepare the bulk walk.

    - #### prepareGetNextWalk

          public void prepareGetNextWalk()

      Helper method to prepare the non-bulk walk.

    - #### getPdu

          public SnmpPdu getPdu()

    - #### getPduTrapV1

          public SnmpPduTrapV1 getPduTrapV1()

Copyright © 2014. All Rights Reserved.