devices
Class Device

java.lang.Object
  extended bydevices.Device

public class Device
extends java.lang.Object

A network device (e.g., router or switch) of interest to GLTMon. A Device holds information gathered via SNMP and specific to its storage in a database (e.g., record ID).

Version:
0.1
Author:
ryan/gswalters

Constructor Summary
Device(java.sql.Connection dbConn, long deviceID)
          Query the database and create a Device from the query results.
Device(java.sql.ResultSet sqlResults)
          Create a Device from a database query result set.
Device(java.lang.String ipAddress, java.lang.String community, java.lang.String sysName, java.lang.String sysDescr, int ifNumber, long sysUpTime)
          Create a bare Device as first discovered via SNMP.
 
Method Summary
 boolean dbInsertDevice(java.sql.Connection dbConn)
          Insert a new Device into the database.
 boolean dbUpdateDevice(java.sql.Connection dbConn)
          Update all the fields in a Device to the database.
 boolean dbUpdateMonitored(java.sql.Connection dbConn)
          Update a Device's monitored status.
 boolean dbUpdateSysUpTime(java.sql.Connection dbConn)
           
 java.lang.String getCommunity()
          Gets the community string of the Device.
 java.sql.Timestamp getDateCreated()
          Gets the creation date of the Device.
 long getDeviceID()
          Gets the ID of the Device.
 int getIfNumber()
          Gets the number of Device Interfaces.
 java.lang.String getIpAddress()
          Gets the IP address of the Device.
 java.lang.String getSysDescr()
          Gets the description of the Device.
 java.lang.String getSysName()
          Gets the name of the Device.
 long getSysUpTime()
          Gets Device's up time.
 boolean isMonitored()
          Gets the monitoring status of the Device.
 boolean isRemoved()
          Gets the removed or present status of the Device.
 void remove()
          Utility method to set removed to true.
 void setCommunity(java.lang.String community)
          Sets the community string for the Device.
 void setDateCreated(java.sql.Timestamp dateCreated)
          Sets the Device's database creation time.
 void setDeviceID(long deviceID)
          Sets the ID of the Device.
 void setIfNumber(int ifNumber)
          Sets the Device's number of Interfaces.
 void setIpAddress(java.lang.String ipAddress)
          Sets the IP address of the Device.
 void setMonitored(boolean monitored)
          Sets the monitoring status of the Device.
 void setRemoved(boolean removed)
          Sets the removed status of the Device.
 void setSysDescr(java.lang.String sysDescr)
          Sets the description of the Device.
 void setSysName(java.lang.String sysName)
          Sets the name of the Device.
 void setSysUpTime(long sysUpTime)
          Sets the Device's current up time.
 java.lang.String toString()
          Convert the Device object into a printable String.
 void unremove()
          Utility method to set removed to false.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Device

public Device(java.lang.String ipAddress,
              java.lang.String community,
              java.lang.String sysName,
              java.lang.String sysDescr,
              int ifNumber,
              long sysUpTime)
Create a bare Device as first discovered via SNMP.

Parameters:
ipAddress - IP address of the Device
community - password for the Device
sysName - SNMP name of the Device
sysDescr - SNMP description of the Device
ifNumber - amount of interfaces on the Device
sysUpTime - amount of time elapsed since the Device was started

Device

public Device(java.sql.Connection dbConn,
              long deviceID)
       throws java.sql.SQLException
Query the database and create a Device from the query results.

Parameters:
dbConn - Connection to the database
deviceID - record ID of the Device in the database

Device

public Device(java.sql.ResultSet sqlResults)
       throws java.sql.SQLException
Create a Device from a database query result set.

Parameters:
sqlResults - single result set from a database query of the Device table
Method Detail

dbInsertDevice

public boolean dbInsertDevice(java.sql.Connection dbConn)
Insert a new Device into the database.

Parameters:
dbConn - Connection to a database
Returns:
Boolean indicating if the Device was inserted

dbUpdateMonitored

public boolean dbUpdateMonitored(java.sql.Connection dbConn)
Update a Device's monitored status.

Parameters:
dbConn - Connection to a database

dbUpdateSysUpTime

public boolean dbUpdateSysUpTime(java.sql.Connection dbConn)

dbUpdateDevice

public boolean dbUpdateDevice(java.sql.Connection dbConn)
Update all the fields in a Device to the database.

Returns:
Boolean indicating if the record update succeeded

toString

public java.lang.String toString()
Convert the Device object into a printable String.

Returns:
String containing the Device information nicely formatted

setDeviceID

public void setDeviceID(long deviceID)
Sets the ID of the Device.

Parameters:
deviceID - long value of the Device database record ID

setIpAddress

public void setIpAddress(java.lang.String ipAddress)
Sets the IP address of the Device.

Parameters:
ipAddress - string containing the IP address of the Device

setCommunity

public void setCommunity(java.lang.String community)
Sets the community string for the Device.

Parameters:
community - string containing the community password

setSysDescr

public void setSysDescr(java.lang.String sysDescr)
Sets the description of the Device.

Parameters:
sysDescr - string containing the description of the Device

setSysName

public void setSysName(java.lang.String sysName)
Sets the name of the Device.

Parameters:
sysName - string containing the name of the Device

setIfNumber

public void setIfNumber(int ifNumber)
Sets the Device's number of Interfaces.

Parameters:
ifNumber - int count of the Device's number of interfaces

setSysUpTime

public void setSysUpTime(long sysUpTime)
Sets the Device's current up time.

Parameters:
sysUpTime - long ticks of the Device's up time

setDateCreated

public void setDateCreated(java.sql.Timestamp dateCreated)
Sets the Device's database creation time.

Parameters:
dateCreated - java.sql.Timestamp of the Device's addition to the database

setMonitored

public void setMonitored(boolean monitored)
Sets the monitoring status of the Device.

Parameters:
monitored - boolean indicating the desired monitoring status of the Device

setRemoved

public void setRemoved(boolean removed)
Sets the removed status of the Device.

Parameters:
removed - boolean indicating the device's availability status

unremove

public void unremove()
Utility method to set removed to false.


remove

public void remove()
Utility method to set removed to true.


getDeviceID

public long getDeviceID()
Gets the ID of the Device.

Returns:
the deviceID.

getIpAddress

public java.lang.String getIpAddress()
Gets the IP address of the Device.

Returns:
the ipAddress.

getCommunity

public java.lang.String getCommunity()
Gets the community string of the Device.

Returns:
the community string.

getSysName

public java.lang.String getSysName()
Gets the name of the Device.

Returns:
the name.

getSysDescr

public java.lang.String getSysDescr()
Gets the description of the Device.

Returns:
the sysDescr.

getIfNumber

public int getIfNumber()
Gets the number of Device Interfaces.

Returns:
the ifNumber.

getSysUpTime

public long getSysUpTime()
Gets Device's up time.

Returns:
the sysUpTime.

getDateCreated

public java.sql.Timestamp getDateCreated()
Gets the creation date of the Device.

Returns:
the dateCreated.

isMonitored

public boolean isMonitored()
Gets the monitoring status of the Device.

Returns:
true if and only if the Device is monitored.

isRemoved

public boolean isRemoved()
Gets the removed or present status of the Device.

Returns:
true if and only if the Device is removed.