FileDocCategorySizeDatePackage
SnmpParameters.javaAPI DocJava SE 5 API7549Fri Aug 26 14:55:04 BST 2005com.sun.jmx.snmp

SnmpParameters

public class SnmpParameters extends SnmpParams implements Serializable, Cloneable
Contains a set of resources that are used by while sending or receiving packets to and from an SnmpPeer. An SnmpPeer can be configured explicitly to use a specific SnmpParameter. A number of SnmpPeer objects can share a single parameter object.

Note: Changing values for an SnmpParameter object affects all SnmpPeer objects that share the parameter object.

version
4.17 12/19/03
author
Sun Microsystems, Inc
author
Cisco Systems, Inc.
see
com.sun.jmx.snmp.SnmpPeer

This API is a Sun Microsystems internal API and is subject to change without notice.

Fields Summary
static final String
defaultRdCommunity
Specify the default community string to use for get operations. By default, the value is "public".
private int
_protocolVersion
The protocol version. By default, the value is SNMP version 1.
private String
_readCommunity
The community to be used when issuing get operations.
private String
_writeCommunity
The community to be used when issuing set operations.
private String
_informCommunity
The community to be used when issuing inform requests.
Constructors Summary
public SnmpParameters()
Creates an SnmpParameters object with defaults set up. By default, set operations are not allowed, the read community and the inform community strings to use is "public" and the SNMP version is V1.

        _readCommunity = defaultRdCommunity ;
        _informCommunity = defaultRdCommunity ;
    
public SnmpParameters(String rdc, String wrc)
Creates an SnmpParameters object. This constructor allows the specification of the read/write community strings. The inform community string to use is "public".

param
rdc community string to use for get operations.
param
wrc community string to use for set operations.

        _readCommunity = rdc ;
        _writeCommunity = wrc ;
        _informCommunity = defaultRdCommunity ;
    
public SnmpParameters(String rdc, String wrc, String inform)
Creates an SnmpParameters object. This constructor allows the specification of the read/write/inform community strings.

param
rdc community string to use for get operations.
param
wrc community string to use for set operations.
param
inform community string to use for inform requests.

        _readCommunity = rdc ;
        _writeCommunity = wrc ;
        _informCommunity = inform ;
    
Methods Summary
public booleanallowSnmpSets()
Checks whether parameters are in place for an SNMP set operation.

return
true if parameters are in place, false otherwise.

        return _writeCommunity != null ;
    
public synchronized java.lang.Objectclone()
Clones the object and its content.

return
The object clone.

        SnmpParameters par = null ;
        try {
            par = (SnmpParameters) super.clone() ;
            //par._retryPolicy = _retryPolicy ;
            par._readCommunity = _readCommunity ;
            par._writeCommunity = _writeCommunity ;
            par._informCommunity = _informCommunity ;
        } catch (CloneNotSupportedException e) {
            throw new InternalError() ; // VM bug.
        }
        return par ;
    
public byte[]encodeAuthentication(int snmpCmd)
For SNMP Runtime internal use only.

        //
        // Returns the community string associated to the specified command.
        //
        try {
            if (snmpCmd == pduSetRequestPdu) 
                return _writeCommunity.getBytes("8859_1");
            else if (snmpCmd == pduInformRequestPdu)
                return _informCommunity.getBytes("8859_1") ;
            else
                return _readCommunity.getBytes("8859_1") ;
        }catch(UnsupportedEncodingException e) {
            throw new SnmpStatusException(e.getMessage());
        }
    
public synchronized booleanequals(java.lang.Object obj)
Compares two objects. Two SnmpParameters are equal if they correspond to the same protocol version, read community and write community.

param
obj The object to compare this with.
return
true if this and the specified object are equal, false otherwise.

        if (!( obj instanceof SnmpParameters))
            return false;

        if (this == obj)
            return true ;
        SnmpParameters param = (SnmpParameters) obj ;
        if (_protocolVersion == param._protocolVersion)
            if (_readCommunity.equals(param._readCommunity))
                return true ;
        return false ;
    
public java.lang.StringgetInformCommunity()
Gets the community to be used when issuing inform requests.

return
The community string.

        return _informCommunity ;
    
public java.lang.StringgetRdCommunity()
Gets the community to be used when issuing get operations.

return
The community string.

        return _readCommunity ;
    
public java.lang.StringgetWrCommunity()
Gets the community to be used when issuing set operations.

return
The community string.

        return _writeCommunity ;
    
public voidsetInformCommunity(java.lang.String inform)
Sets the community string to use when performing inform requests.

param
inform The community string.

        if (inform == null)
            _informCommunity = defaultRdCommunity ;
        else
            _informCommunity = inform ;
    
public synchronized voidsetRdCommunity(java.lang.String read)
Sets the community string to use when performing get operations.

param
read The community string.

        if (read == null)
            _readCommunity = defaultRdCommunity ;
        else
            _readCommunity = read ;
    
public voidsetWrCommunity(java.lang.String write)
Sets the community to be used when issuing set operations.

param
write The community string.

        _writeCommunity = write;