Class SnmpParameters

  • All Implemented Interfaces:
    Cloneable

    public class SnmpParameters
    extends Object
    implements Cloneable
    The SnmpParameters class is used to define the parameters for an SnmpSession. The parameters include the read/write community strings. The protocol version and the ASN.1 encoder used to encode/decode transmissions.
    Author:
    Brian Weaver
    • Field Detail

      • defaultEncoder

        public static final AsnEncoder defaultEncoder
        The AsnEncoder used by default.
      • defaultVersion

        public static final int defaultVersion
        The SNMP protocol version used by default.
        See Also:
        Constant Field Values
    • Constructor Detail

      • SnmpParameters

        public SnmpParameters()
        The default class constructor. Constructs the object with the publicly available default values. By default the write community string is left null.
        See Also:
        defaultCommunity, defaultEncoder, defaultVersion
      • SnmpParameters

        public SnmpParameters​(SnmpParameters second)
        Constructs a copy of the parameters defined in the object second.
        Parameters:
        second - The object to copy into self.
      • SnmpParameters

        public SnmpParameters​(int version)
        Constructs a default object with the specified SNMP protocol version.
        Parameters:
        version - The SNMP protocol version.
      • SnmpParameters

        public SnmpParameters​(String read)
        Constructs a default object with the specified read-only community string.
        Parameters:
        read - The read-only community string.
      • SnmpParameters

        public SnmpParameters​(String read,
                              String write)
        Constructs an object with the specified read-only and write-only community strings.
        Parameters:
        read - The read-only community string.
        write - The write-only community string.
    • Method Detail

      • getReadCommunity

        public String getReadCommunity()
        Retreives the current read community string from the parameters.
        Returns:
        The read community string.
      • setReadCommunity

        public void setReadCommunity​(String rd)
        Used to set the parameters read community string. NOTE: The community string is covnerted to a set of 8-bit characters by the String.getBytes() method.
        Parameters:
        rd - The new read community string.
        See Also:
        String.getBytes()
      • getWriteCommunity

        public String getWriteCommunity()
        Retreives the current write community string set in the parameters.
        Returns:
        The write community string.
      • setWriteCommunity

        public void setWriteCommunity​(String wr)
        Used to set the parameters write community string. The write community string is only used by SNMP SET packet. NOTE: The community string is covnerted to a set of 8-bit characters by the String.getBytes() method.
        Parameters:
        wr - The new write community string.
        See Also:
        String.getBytes()
      • getVersion

        public int getVersion()
        Returns the current SNMP version defined by the parameters.
        Returns:
        The current protocol version.
      • setVersion

        public void setVersion​(int ver)
        Use to set the SNMP protocol version. The version should be one of the constants within the SnmpSMI.
        Parameters:
        ver - The SNMP version protocol to use.
        See Also:
        SnmpSMI.SNMPV1, SnmpSMI.SNMPV2
      • getEncoder

        public AsnEncoder getEncoder()
        Retreives the current ASN.1 encoder object.
        Returns:
        The current AsnEncoder
      • setEncoder

        public void setEncoder​(AsnEncoder encoder)
        Sets the ASN.1 encoder.
        Parameters:
        encoder - The new encoder to use.
      • clone

        public Object clone()
        Used to get a newly created duplicate of the current object.
        Overrides:
        clone in class Object
        Returns:
        A newly created duplicate