com.adventnet.snmp.snmp2
Class SnmpEngineTable

java.lang.Object
  extended by com.adventnet.snmp.snmp2.SnmpEngineTable
All Implemented Interfaces:
java.io.Serializable

public class SnmpEngineTable
extends java.lang.Object
implements java.io.Serializable

The SnmpEngineTable maintains a lsit of SnmpEngineEntry objects and provides methods to operate on list. Methods are povided to add, retrive and remove SnmpEngineEntry objects. The API users need not instantiate this class as it is instantiated from the SnmpAPI constructor. The SnmpAPI provides methods to access the SnmpEngineTable instance.

This class also provides methods to serialize and deSerialize the list of SnmpEngineEntry objects. The SnmpEngineEntry objects are always serialized in the file EngineEntry.ser. The serialization will not work in case of applets using the serialization methods. This will be fixed in the future release.

See Also:
SnmpEngineEntry, SnmpAPI, Serialized Form

Field Summary
(package private) static int DBKEY
           
(package private) static int ENGINEBOOTS
           
(package private) static int ENGINEID
           
(package private) static int ENGINENAME
           
(package private) static int ENGINETIME
           
(package private)  com.adventnet.utils.DatabaseTableParams engParams
           
(package private) static int HOST
           
(package private) static int PORT
           
 
Constructor Summary
SnmpEngineTable()
           
 
Method Summary
 boolean addEntry(SnmpEngineEntry entry)
          Adds the SnmpEngineEntry to the list of SnmpEngineEntry objects maintained in this class.
 void deSerialize()
          DeSerializes the file "EngineEntry.ser" to get a list of SnmpEngineEntry objects.
(package private) static java.lang.String getByteString(byte[] array, int offset, int length)
           
(package private)  com.adventnet.utils.DatabaseOperations getDbOps()
           
 SnmpEngineEntry getEntry(java.lang.String address, int port)
          Returns the SnmpEngineEntry object corresponding to the particular host and port from the list SnmpEngineEntry objects.
 java.util.Enumeration getEnumeration()
          Returns an enumeration of all the SnmpEngineEntry objects maintained.
(package private) static java.lang.Object getKey(java.lang.String address, int port)
           
(package private)  SASClient getSASClient()
           
 boolean isV3DatabaseFlag()
          Gets the Database flag for this SnmpAPI instance.
 void readFromDatabase()
          Gets a list of SnmpEngineEntry objects and puts it in the hashtable.
 void removeEntry(SnmpEngineEntry entry)
          Delets the particular SnmpEngineEntry from the list of SnmpEngineEntry objects.
 void removeEntry(java.lang.String address, int port)
          Deletes the SnmpEngineEntry from the list of SnmpEngineEntry objects corresponding to the hostName and port specified.
 void serialize()
          Stores the list of SnmpEngineEntry objects in the serialized file "EngineEntry.ser".
(package private)  void setDBOperations(com.adventnet.utils.DatabaseOperations db)
           
 void setNullTable()
          Clears the list of SnmpEngineEntry objects.
(package private)  void setSASClient(SASClient sas)
           
 void setV3DatabaseFlag(boolean dbFlag)
          Sets the Database flag.
 void writeToDatabase()
          Stores the list of SnmpEngineEntry objects in the database
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DBKEY

static final int DBKEY
See Also:
Constant Field Values

HOST

static final int HOST
See Also:
Constant Field Values

PORT

static final int PORT
See Also:
Constant Field Values

ENGINENAME

static final int ENGINENAME
See Also:
Constant Field Values

ENGINEID

static final int ENGINEID
See Also:
Constant Field Values

ENGINETIME

static final int ENGINETIME
See Also:
Constant Field Values

ENGINEBOOTS

static final int ENGINEBOOTS
See Also:
Constant Field Values

engParams

com.adventnet.utils.DatabaseTableParams engParams
Constructor Detail

SnmpEngineTable

SnmpEngineTable()
Method Detail

setSASClient

void setSASClient(SASClient sas)

getSASClient

SASClient getSASClient()

getDbOps

com.adventnet.utils.DatabaseOperations getDbOps()

getEnumeration

public java.util.Enumeration getEnumeration()
Returns an enumeration of all the SnmpEngineEntry objects maintained.

Returns:
an enumeration of all the SnmpEngineEntry objects maintained by this class.

setDBOperations

void setDBOperations(com.adventnet.utils.DatabaseOperations db)

setNullTable

public void setNullTable()
Clears the list of SnmpEngineEntry objects. Removes all the SnmpEngineEntry objects maintained by this class.


setV3DatabaseFlag

public void setV3DatabaseFlag(boolean dbFlag)
Sets the Database flag.

Parameters:
dbFlag - the database flag to be set on this SnmpAPI instance.

isV3DatabaseFlag

public boolean isV3DatabaseFlag()
Gets the Database flag for this SnmpAPI instance.


addEntry

public boolean addEntry(SnmpEngineEntry entry)
Adds the SnmpEngineEntry to the list of SnmpEngineEntry objects maintained in this class.

Parameters:
entry - The SnmpEngineEntry which needs to be added to the list of SnmpEngineEntry objects.
Returns:
True if the SnmpEngineEntry is successfully added to the list. False if the SnmpEngineEntry object is already present in the list.

getEntry

public SnmpEngineEntry getEntry(java.lang.String address,
                                int port)
Returns the SnmpEngineEntry object corresponding to the particular host and port from the list SnmpEngineEntry objects.

Parameters:
adddress - The hostName of the SnmpEngineEntry object to be retrived.
port - The port of the SnmpEngineEntry object to be retrived. It should be passed as -1 in the case of independent protocol.
Returns:
The SnmpEngineEntry corresponding to the hostName and port specified in the input parameters. Returns Null if the corresponding SnmpEngineEntry is not in the list of SnmpEngineEntry objects.

removeEntry

public void removeEntry(java.lang.String address,
                        int port)
Deletes the SnmpEngineEntry from the list of SnmpEngineEntry objects corresponding to the hostName and port specified.

Parameters:
adddress - The hostName of the SnmpEngineEntry object to be deleted.
port - The port of the SnmpEngineEntry object to be deleted. It should be passed as -1 in the case of independent protocols.

removeEntry

public void removeEntry(SnmpEngineEntry entry)
Delets the particular SnmpEngineEntry from the list of SnmpEngineEntry objects.

Parameters:
entry - The SnmpEngineEntry which is to be deleted from the list of SnmpEngineEntry objects.

serialize

public void serialize()
Stores the list of SnmpEngineEntry objects in the serialized file "EngineEntry.ser".


deSerialize

public void deSerialize()
DeSerializes the file "EngineEntry.ser" to get a list of SnmpEngineEntry objects.


getByteString

static java.lang.String getByteString(byte[] array,
                                      int offset,
                                      int length)

writeToDatabase

public void writeToDatabase()
Stores the list of SnmpEngineEntry objects in the database


readFromDatabase

public void readFromDatabase()
                      throws java.sql.SQLException
Gets a list of SnmpEngineEntry objects and puts it in the hashtable.

Throws:
java.sql.SQLException

getKey

static java.lang.Object getKey(java.lang.String address,
                               int port)