org.opennms.protocols.snmp
Class SnmpParameters

java.lang.Object
  extended byorg.opennms.protocols.snmp.SnmpParameters
All Implemented Interfaces:
java.lang.Cloneable

public class SnmpParameters
extends java.lang.Object
implements java.lang.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.


Field Summary
static java.lang.String defaultCommunity
          The default read-only community string
static org.opennms.protocols.snmp.asn1.AsnEncoder defaultEncoder
          The AsnEncoder used by default.
static int defaultVersion
          The SNMP protocol version used by default.
 
Constructor Summary
SnmpParameters()
          The default class constructor.
SnmpParameters(int version)
          Constructs a default object with the specified SNMP protocol version.
SnmpParameters(SnmpParameters second)
          Constructs a copy of the parameters defined in the object second.
SnmpParameters(java.lang.String read)
          Constructs a default object with the specified read-only community string.
SnmpParameters(java.lang.String read, java.lang.String write)
          Constructs an object with the specified read-only and write-only community strings.
 
Method Summary
 java.lang.Object clone()
          Used to get a newly created duplicate of the current object.
 org.opennms.protocols.snmp.asn1.AsnEncoder getEncoder()
          Retreives the current ASN.1 encoder object.
 java.lang.String getReadCommunity()
          Retreives the current read community string from the parameters.
 int getVersion()
          Returns the current SNMP version defined by the parameters.
 java.lang.String getWriteCommunity()
          Retreives the current write community string set in the parameters.
 void setEncoder(org.opennms.protocols.snmp.asn1.AsnEncoder encoder)
          Sets the ASN.1 encoder.
 void setReadCommunity(java.lang.String rd)
          Used to set the parameters read community string.
 void setVersion(int ver)
          Use to set the SNMP protocol version.
 void setWriteCommunity(java.lang.String wr)
          Used to set the parameters write community string.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultCommunity

public static final java.lang.String defaultCommunity
The default read-only community string

See Also:
Constant Field Values

defaultEncoder

public static final org.opennms.protocols.snmp.asn1.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(java.lang.String read)
Constructs a default object with the specified read-only community string.

Parameters:
read - The read-only community string.

SnmpParameters

public SnmpParameters(java.lang.String read,
                      java.lang.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 java.lang.String getReadCommunity()
Retreives the current read community string from the parameters.

Returns:
The read community string.

setReadCommunity

public void setReadCommunity(java.lang.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 java.lang.String getWriteCommunity()
Retreives the current write community string set in the parameters.

Returns:
The write community string.

setWriteCommunity

public void setWriteCommunity(java.lang.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 org.opennms.protocols.snmp.asn1.AsnEncoder getEncoder()
Retreives the current ASN.1 encoder object.

Returns:
The current AsnEncoder

setEncoder

public void setEncoder(org.opennms.protocols.snmp.asn1.AsnEncoder encoder)
Sets the ASN.1 encoder.

Parameters:
encoder - The new encoder to use.

clone

public java.lang.Object clone()
Used to get a newly created duplicate of the current object.

Returns:
A newly created duplicate