com.adventnet.utils.agent
Class AgentTableModel

java.lang.Object
  |
  +--com.adventnet.utils.agent.AgentTableModel

public class AgentTableModel
extends java.lang.Object

The AgentTableModel insulates the user from low level SNMP operations and storing of data in case of SNMP Tables

This is especially useful during SNMP Get Next where user need not store data


Field Summary
(package private)  TableModelListener modelListener
           
(package private)  int noOfColumns
           
(package private)  int rowStatusPos
           
 
Constructor Summary
AgentTableModel()
          Constructor for AgentTableModel
 
Method Summary
 void addRow(TableEntry tbl)
          Adds (TableEntry) the row to the Table Model.
 void addTableModelListener(TableModelListener modelListener)
          This method adds the Table Model Listener.
 void deleteRow(int[] inst)
          Deletes the row from the Model specified by the instanceOID.
 void deleteRow(TableEntry tbl)
          Deletes the row from the Model specified by the TableEntry.
 int findExactLocation(int[] prevOid)
          Method to find the Exact Location of the instance.
 int findInsertLocation(int[] prevOid)
          Returns the index at which the new Entry of instance OID prevOid has to be inserted (Uses Binary Search ).
 int findNextLocation(int[] prevOid)
          This method is to find the Next Location of the index.
 TableEntry get(int[] inst)
          API users would have to provide the instance oid for the Entry(Table Row).
 TableEntry getEntryAt(int index)
          This method is the Getter for the Table entry Values.
 TableEntry getFirstEntry()
          Method to Obtain the First entry of the Table.
 TableEntry getLastEntry()
          Method to Obtain the Last Entry from the Table Model.
 TableEntry getNext(int[] inst)
          Gets the next Element after this instance.
 TableEntry getNextEntry(TableEntry entry)
          Get the next Entry form the Table Model.
 java.util.Vector getTableElements()
          Getter for the TableElements from the TableModel.
 void insertRow(TableEntry tbl)
          Inserts (TableEntry) the row to the Table Model.
(package private)  void printEntryList()
           
 void removeTableModelListener()
          This method Removes the Table Model Listener.
 void setTableElements(java.util.Vector tableElements)
          Sets The Table Entries to the Table Model.
 int size()
          Number of rows in the Model.
 void tableDeleteRow(int[] inst)
          Deletes the row from the Model specified by the OID.
 void tableDeleteRow(TableEntry tbl)
          Deletes the row from the Model specified by the TableEntry.
 TableEntry tableGet(int[] inst)
          Method to get the Table Entry Object.
 TableEntry tableGetNext(int[] prevOid)
          Gets the next Element after this instance.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

noOfColumns

int noOfColumns

rowStatusPos

int rowStatusPos

modelListener

TableModelListener modelListener
Constructor Detail

AgentTableModel

public AgentTableModel()
Constructor for AgentTableModel
Method Detail

setTableElements

public void setTableElements(java.util.Vector tableElements)
Sets The Table Entries to the Table Model.
Parameters:
tableElements - The Table Elements to set.

getTableElements

public java.util.Vector getTableElements()
Getter for the TableElements from the TableModel.
Returns:
The Table Elements.

addRow

public void addRow(TableEntry tbl)
            throws AgentSnmpException
Adds (TableEntry) the row to the Table Model.
Parameters:
tbl - The row to be added.
Throws:
AgentSnmpException - This wraps all the exceptions thrown during this event.

deleteRow

public void deleteRow(TableEntry tbl)
               throws AgentSnmpException
Deletes the row from the Model specified by the TableEntry.
Parameters:
tbl - The row to be Deleted from the Table.
Throws:
AgentSnmpException - This Wraps all the exceptions thrown while Processing the Event.

deleteRow

public void deleteRow(int[] inst)
               throws AgentSnmpException
Deletes the row from the Model specified by the instanceOID.
Parameters:
The - instanceOid Value.
Throws:
AgentSnmpException - This Wraps all the Exceptions hrown while processing the Event.

getFirstEntry

public TableEntry getFirstEntry()
Method to Obtain the First entry of the Table.
Returns:
The first Entry from the table model.

getLastEntry

public TableEntry getLastEntry()
Method to Obtain the Last Entry from the Table Model.
Returns:
The last Entry from the table.

getEntryAt

public TableEntry getEntryAt(int index)
This method is the Getter for the Table entry Values.
Parameters:
index - The Table Entry Index.
Returns:
The TableEntry at index. Note that the entrys are all in sorted order with respect to to thier instance OID.

size

public int size()
Number of rows in the Model.
Returns:
The Sicze of the Table Model.

get

public TableEntry get(int[] inst)
API users would have to provide the instance oid for the Entry(Table Row). Can be used in SNMP getRequests operation.
Parameters:
inst - The instance OID of the Table row.
Returns:
The Requested Table Row Entry values.

getNext

public TableEntry getNext(int[] inst)
Gets the next Element after this instance.
Parameters:
inst - The Instance whose next entry is needed.
Returns:
The Required element.

getNextEntry

public TableEntry getNextEntry(TableEntry entry)
Get the next Entry form the Table Model.
Parameters:
entry - The Entry Value whose nextEntry is needed.
Returns:
The Needed Entry.

printEntryList

void printEntryList()

addTableModelListener

public void addTableModelListener(TableModelListener modelListener)
This method adds the Table Model Listener.
Parameters:
modelListener - The Listener to be added.

removeTableModelListener

public void removeTableModelListener()
This method Removes the Table Model Listener.

insertRow

public void insertRow(TableEntry tbl)
               throws AgentSnmpException
Inserts (TableEntry) the row to the Table Model.
Parameters:
tbl - The Row Entry to be Inserted.
Throws:
AgentSnmpException - This Wraps all the Exceptions thrown while Executing the event.

findInsertLocation

public int findInsertLocation(int[] prevOid)
Returns the index at which the new Entry of instance OID prevOid has to be inserted (Uses Binary Search ).
Parameters:
PrevOid - The prevOid.
Returns:
The Insert Location Index.

tableGetNext

public TableEntry tableGetNext(int[] prevOid)
Gets the next Element after this instance.
Parameters:
prevOid - The Oid whose next entry is needed.
Returns:
The Entry needed.

findNextLocation

public int findNextLocation(int[] prevOid)
This method is to find the Next Location of the index.
Parameters:
prevOid - Oid for which GetNext Request has come . WARNING : This function does not have direct capability to indicate failure. How to check failure : if integer returned is outOfBoundsIndex( i mean vector size is 3 but integer returned is 4 0r -1 ) it means that "THERE IS NO ENTRY with instance > prevOid (incoming parameter ) "
Returns:
The index in vector tblElements at which prevOid[] < entry.getInstance[].

findExactLocation

public int findExactLocation(int[] prevOid)
Method to find the Exact Location of the instance.
Parameters:
prevOid - The Oid for which the Location is required.
Returns:
'-1' if such an instance is not there else index of Vector tblElements where instance prevOid is present.

tableGet

public TableEntry tableGet(int[] inst)
Method to get the Table Entry Object.
Parameters:
inst[] - The Table instance to get the entry.
Returns:
NULL if inst does not exist else its corresponing TableEntry object.

tableDeleteRow

public void tableDeleteRow(TableEntry tbl)
                    throws AgentSnmpException
Deletes the row from the Model specified by the TableEntry.
Parameters:
tbl - The table entry specification for deletion.
Throws:
AgentSnmpException - This Wraps all the Exceptions thrown while Processing this Event.

tableDeleteRow

public void tableDeleteRow(int[] inst)
                    throws AgentSnmpException
Deletes the row from the Model specified by the OID.
Parameters:
inst - The instance Oid specification for deletion.
Throws:
AgentSnmpException - This wraps all the Exceptions thrown while processing this Event.