com.adventnet.snmp.snmp2.agent
Class XMLToVector

java.lang.Object
  extended by com.adventnet.snmp.snmp2.agent.XMLToVector
All Implemented Interfaces:
UpdateListener, AgentEventListener, java.lang.Runnable
Direct Known Subclasses:
V3XMLToVector

public class XMLToVector
extends java.lang.Object
implements java.lang.Runnable, UpdateListener

This class contains the Persistency data handling of the V1V2TrapForwardingTable in XML and Text format


Field Summary
(package private) static java.lang.String[] columnNames
          All the column names as present in the persistent file
(package private) static int COMMUNITY
           
protected  java.lang.String fieldSeparator
          Separator between Table parameters in FToV format.
protected  ForwardingTable forTable
          The forwarding Table associated with this XMLToVector
protected  boolean fToVPersistence
          FileToVector persistence flag
protected  SimpleTrapForwardingTable handler
          The Handler associated with this
(package private)  long lastModified
           
(package private) static int MANAGERHOST
          Int value of the column managerHost
(package private) static int MANAGERHOSTTYPE
           
(package private) static int MANAGERPORT
          Int value of the column managerPort
protected  java.lang.String name
          The filename with the location
(package private)  int refreshTime
           
(package private) static int RETRIES
           
(package private) static int ROWSTATUS
           
protected  java.util.Vector tableVector
          The Table Vector holding the entries.
(package private) static int TIMEOUT
           
(package private) static int VERSION
          Int value of the column rowStatus
 
Constructor Summary
XMLToVector()
          Primary constructor
XMLToVector(java.lang.String dirStr, java.lang.String fileName)
          This is the primary constructor with speification of directory name and fileName
XMLToVector(java.lang.String dirStr, java.lang.String fileName, ForwardingTable table, boolean ftov)
          This constructor with speification of directory name, fileName, ForwardingTable and the Storage Type.
 
Method Summary
static int getColumnId(java.lang.String name)
          To get the column subid from the names
 java.lang.String getColumnValue(ForwardingEntry entry, java.lang.String columnName)
          To get the value for each column from the Entry provided
 void initTableVector()
          Initializes a new Table Vector
protected  void readFromFile()
          Method to read from the persistent file in the fileSystem
 void refreshTrapTable(int refreshTime)
          Method to refresh the TrapForwardingTable with the refreshTime
 void run()
          This is the actual run method of the Thread used for refreshing the TrapForwardingTable
 void setForwardingTableRequestHandler(SimpleTrapForwardingTable handler)
          Sets the SimpleTrapForwardingTable with the values parsed from the file.
 void setFToVPersistence(boolean fToVPersistence)
          Setter for FToVPersistence.
 void writeIntoFile()
          This method writes the entry values from the TrapForwardingTable to the file in XML format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

forTable

protected ForwardingTable forTable
The forwarding Table associated with this XMLToVector


MANAGERHOSTTYPE

static final int MANAGERHOSTTYPE
See Also:
Constant Field Values

MANAGERHOST

static final int MANAGERHOST
Int value of the column managerHost

See Also:
Constant Field Values

MANAGERPORT

static final int MANAGERPORT
Int value of the column managerPort

See Also:
Constant Field Values

VERSION

static final int VERSION
Int value of the column rowStatus

See Also:
Constant Field Values

COMMUNITY

static final int COMMUNITY
See Also:
Constant Field Values

TIMEOUT

static final int TIMEOUT
See Also:
Constant Field Values

RETRIES

static final int RETRIES
See Also:
Constant Field Values

ROWSTATUS

static final int ROWSTATUS
See Also:
Constant Field Values

columnNames

static final java.lang.String[] columnNames
All the column names as present in the persistent file


tableVector

protected java.util.Vector tableVector
The Table Vector holding the entries.


refreshTime

int refreshTime

lastModified

long lastModified

name

protected java.lang.String name
The filename with the location


fieldSeparator

protected java.lang.String fieldSeparator
Separator between Table parameters in FToV format.


handler

protected SimpleTrapForwardingTable handler
The Handler associated with this


fToVPersistence

protected boolean fToVPersistence
FileToVector persistence flag

Constructor Detail

XMLToVector

public XMLToVector()
Primary constructor


XMLToVector

public XMLToVector(java.lang.String dirStr,
                   java.lang.String fileName,
                   ForwardingTable table,
                   boolean ftov)
This constructor with speification of directory name, fileName, ForwardingTable and the Storage Type.

Parameters:
dirStr - the directory location of the storage file.
fileName - the fileName.
table - the ForwardingTable whose entries are to be stored.
ftv - boolean to specify text or xml format true for text format.

XMLToVector

public XMLToVector(java.lang.String dirStr,
                   java.lang.String fileName)
This is the primary constructor with speification of directory name and fileName

Parameters:
dirStr - the directory location of the storage file.
fileName - the fileName.
Method Detail

getColumnId

public static int getColumnId(java.lang.String name)
To get the column subid from the names

Parameters:
name - The column name
Returns:
the column id int

getColumnValue

public java.lang.String getColumnValue(ForwardingEntry entry,
                                       java.lang.String columnName)
To get the value for each column from the Entry provided

Parameters:
entry - The row Entry
columnName - The column name
Returns:
The value of the column in the given Entry

readFromFile

protected void readFromFile()
                     throws java.lang.Exception
Method to read from the persistent file in the fileSystem

Throws:
java.lang.Exception - on error while parsing file

writeIntoFile

public void writeIntoFile()
This method writes the entry values from the TrapForwardingTable to the file in XML format

Specified by:
writeIntoFile in interface UpdateListener

initTableVector

public void initTableVector()
Initializes a new Table Vector


refreshTrapTable

public void refreshTrapTable(int refreshTime)
Method to refresh the TrapForwardingTable with the refreshTime

Parameters:
refreshTime - The refresh time in secs.

run

public void run()
This is the actual run method of the Thread used for refreshing the TrapForwardingTable

Specified by:
run in interface java.lang.Runnable

setForwardingTableRequestHandler

public void setForwardingTableRequestHandler(SimpleTrapForwardingTable handler)
Sets the SimpleTrapForwardingTable with the values parsed from the file.


setFToVPersistence

public void setFToVPersistence(boolean fToVPersistence)
Setter for FToVPersistence.

Parameters:
fToVPersistence - true to set Text file Storage.