Package org.opennms.protocols.snmp
Class SnmpParameters
- java.lang.Object
-
- org.opennms.protocols.snmp.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 Summary
Fields Modifier and Type Field Description static String
defaultCommunity
The default read-only community stringstatic AsnEncoder
defaultEncoder
The AsnEncoder used by default.static int
defaultVersion
The SNMP protocol version used by default.
-
Constructor Summary
Constructors Constructor Description SnmpParameters()
The default class constructor.SnmpParameters(int version)
Constructs a default object with the specified SNMP protocol version.SnmpParameters(String read)
Constructs a default object with the specified read-only community string.SnmpParameters(String read, String write)
Constructs an object with the specified read-only and write-only community strings.SnmpParameters(SnmpParameters second)
Constructs a copy of the parameters defined in the object second.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
clone()
Used to get a newly created duplicate of the current object.AsnEncoder
getEncoder()
Retreives the current ASN.1 encoder object.String
getReadCommunity()
Retreives the current read community string from the parameters.int
getVersion()
Returns the current SNMP version defined by the parameters.String
getWriteCommunity()
Retreives the current write community string set in the parameters.void
setEncoder(AsnEncoder encoder)
Sets the ASN.1 encoder.void
setReadCommunity(String rd)
Used to set the parameters read community string.void
setVersion(int ver)
Use to set the SNMP protocol version.void
setWriteCommunity(String wr)
Used to set the parameters write community string.
-
-
-
Field Detail
-
defaultCommunity
public static final String defaultCommunity
The default read-only community string- See Also:
- Constant Field Values
-
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.
-
-
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.
-
-