OpenNMS API 1.2.9

## org.opennms.netmgt.capsd
Class DbSnmpInterfaceEntry

    java.lang.Object
      org.opennms.netmgt.capsd.DbSnmpInterfaceEntry

final class DbSnmpInterfaceEntry
extends java.lang.Object

Once loaded or create, the class tracks any changes and will write those changes to the database whenever the `store` method is invoked. If a database conneciton is not passed to the store method, then a temporary one is allocated to write the results.

NOTE: if the connection is passed in and is not in auto commit mode, then the caller must call `commit` to inform the database that the transaction is complete.

Author:
  Weave , OpenNMS

Field Summary
`private static int` `CHANGED_DESCRIPTION`
`private static int` `CHANGED_IFADDRESS`
`private static int` `CHANGED_IFADMINSTATUS`
`private static int` `CHANGED_IFALIAS`
`private static int` `CHANGED_IFNAME`
`private static int` `CHANGED_IFOPERSTATUS`
`private static int` `CHANGED_IFSPEED`
`private static int` `CHANGED_IFTYPE`
`private static int` `CHANGED_NETMASK`
`private static int` `CHANGED_PHYSADDR`
`private int` `m_changed` The bit map used to determine which elements have changed since the record was created.
`private boolean` `m_fromDb` True if this recored was loaded from the database.
`private int` `m_ifAdminStatus`
`private java.lang.String` `m_ifAlias`
`private java.lang.String` `m_ifDescription`
`private int` `m_ifIndex` The SNMP ifIndex
`private java.lang.String` `m_ifName`
`private int` `m_ifOperStatus`
`private int` `m_ifSpeed`
`private int` `m_ifType`
`private java.net.InetAddress` `m_ipAddr` The IP address.
`private java.net.InetAddress` `m_netmask`
`private int` `m_nodeId` The node identifier
`private java.lang.String` `m_physAddr`
`private static java.lang.String` `SQL_LOAD_REC` The SQL statement used to read a node from the database.

Constructor Summary
`private` `DbSnmpInterfaceEntry()` Default constructor.
`private` `DbSnmpInterfaceEntry(int nid, int ifIndex)` Constructs a new interface.
`private` `DbSnmpInterfaceEntry(int nid, int ifIndex, boolean exists)` Constructs a new interface.

Method Summary
`(package private) static DbSnmpInterfaceEntry` `create(int nid, int ifIndex)` Creates a new entry.
`(package private) static DbSnmpInterfaceEntry` `get(java.sql.Connection db, int nid, int ifIndex)` Retreives a current record from the database based upon the key fields of nodeID and ifIndex.
`(package private) static DbSnmpInterfaceEntry` `get(int nid, int ifIndex)` Retreives a current record from the database based upon the key fields of nodeID and ifindex.
`(package private) int` `getAdminStatus()`
`(package private) java.lang.String` `getAlias()`
`(package private) java.lang.String` `getDescription()`
`(package private) java.net.InetAddress` `getIfAddress()` Returns the IP address for the entry.
`(package private) int` `getIfIndex()` Returns the current ifIndex
`(package private) java.lang.String` `getName()`
`(package private) java.net.InetAddress` `getNetmask()`
`(package private) int` `getNodeId()` Returns the node entry's unique identifier.
`(package private) int` `getOperationalStatus()`
`(package private) java.lang.String` `getPhysicalAddress()`
`(package private) int` `getSpeed()`
`(package private) int` `getType()`
`(package private) boolean` `hasAdminStatusChanged()`
`(package private) boolean` `hasAliasChanged()`
`(package private) boolean` `hasDescriptionChanged()`
`(package private) boolean` `hasIfAddressChanged()`
`(package private) boolean` `hasIfIndex()` Returns true if the ifIndex is defined.
`(package private) boolean` `hasNameChanged()`
`(package private) boolean` `hasNetmaskChanged()`
`(package private) boolean` `hasOperationalStatusChanged()`
`(package private) boolean` `hasPhysicalAddressChanged()`
`(package private) boolean` `hasSpeedChanged()`
`(package private) boolean` `hasTypeChanged()`
`private void` `insert(java.sql.Connection c)` Inserts the new interface into the ipInterface table of the OpenNMS databasee.
`private boolean` `load(java.sql.Connection c)` Load the current interface from the database.
`static void` `main(java.lang.String[] args)` For debugging only
`(package private) void` `setAdminStatus(int status)`
`(package private) void` `setAlias(java.lang.String alias)`
`(package private) void` `setDescription(java.lang.String descr)`
`(package private) void` `setIfAddress(java.net.InetAddress addr)`
`(package private) void` `setName(java.lang.String name)`
`(package private) void` `setNetmask(java.net.InetAddress mask)`
`(package private) void` `setOperationalStatus(int status)`
`(package private) void` `setPhysicalAddress(java.lang.String addr)`
`(package private) void` `setSpeed(int speed)`
`(package private) void` `setType(int type)`
`(package private) void` `store()` Updates the interface information in the configured database.
`(package private) void` `store(java.sql.Connection db)` Updates the interface information in the configured database.
`java.lang.String` `toString()` Creates a string that displays the internal contents of the record.
`private void` `update(java.sql.Connection c)` Updates an existing record in the OpenNMS ipInterface table.
`(package private) boolean` `updateAdminStatus(int newIfAdminStatus)`
`(package private) boolean` `updateAlias(java.lang.String newIfAlias)`
`(package private) boolean` `updateDescription(java.lang.String newIfDescription)`
`(package private) boolean` `updateIfAddress(java.net.InetAddress addr)`
`(package private) boolean` `updateName(java.lang.String newIfName)`
`(package private) boolean` `updateNetmask(java.net.InetAddress newNetmask)`
`(package private) boolean` `updateOperationalStatus(int newIfOperStatus)`
`(package private) boolean` `updatePhysicalAddress(java.lang.String newPhysAddr)`
`(package private) boolean` `updateSpeed(int newIfSpeed)`
`(package private) boolean` `updateType(int newIfType)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### SQL_LOAD_REC

    private static final java.lang.String SQL_LOAD_REC

  The SQL statement used to read a node from the database. This record is keyed by the node identifier and the ifIndex.

  See Also:
    Constant Field Values

### m_fromDb

    private boolean m_fromDb

  True if this recored was loaded from the database. False if it's new.

### m_nodeId

    private int m_nodeId

  The node identifier

### m_ipAddr

    private java.net.InetAddress m_ipAddr

  The IP address.

### m_ifIndex

    private int m_ifIndex

  The SNMP ifIndex

### m_netmask

    private java.net.InetAddress m_netmask

### m_physAddr

    private java.lang.String m_physAddr

### m_ifDescription

    private java.lang.String m_ifDescription

### m_ifType

    private int m_ifType

### m_ifName

    private java.lang.String m_ifName

### m_ifAlias

    private java.lang.String m_ifAlias

### m_ifSpeed

    private int m_ifSpeed

### m_ifAdminStatus

    private int m_ifAdminStatus

### m_ifOperStatus

    private int m_ifOperStatus

### m_changed

    private int m_changed

  The bit map used to determine which elements have changed since the record was created.

### CHANGED_IFADDRESS

    private static final int CHANGED_IFADDRESS

See Also:
  Constant Field Values

### CHANGED_NETMASK

    private static final int CHANGED_NETMASK

See Also:
  Constant Field Values

### CHANGED_PHYSADDR

    private static final int CHANGED_PHYSADDR

See Also:
  Constant Field Values

### CHANGED_DESCRIPTION

    private static final int CHANGED_DESCRIPTION

See Also:
  Constant Field Values

### CHANGED_IFTYPE

    private static final int CHANGED_IFTYPE

See Also:
  Constant Field Values

### CHANGED_IFNAME

    private static final int CHANGED_IFNAME

See Also:
  Constant Field Values

### CHANGED_IFSPEED

    private static final int CHANGED_IFSPEED

See Also:
  Constant Field Values

### CHANGED_IFADMINSTATUS

    private static final int CHANGED_IFADMINSTATUS

See Also:
  Constant Field Values

### CHANGED_IFOPERSTATUS

    private static final int CHANGED_IFOPERSTATUS

See Also:
  Constant Field Values

### CHANGED_IFALIAS

    private static final int CHANGED_IFALIAS

See Also:
  Constant Field Values

Constructor Detail

### DbSnmpInterfaceEntry

    private DbSnmpInterfaceEntry()

  Default constructor.

### DbSnmpInterfaceEntry

    private DbSnmpInterfaceEntry(int nid,
                                 int ifIndex)

  Constructs a new interface.

Parameters:
  `nid` - The node identifier.
  `ifIndex` - The interface index to load

### DbSnmpInterfaceEntry

    private DbSnmpInterfaceEntry(int nid,
                                 int ifIndex,
                                 boolean exists)

  Constructs a new interface.

Parameters:
  `nid` - The node identifier.
  `ifIndex` - The interface index to load
  `exists` - True if the interface already exists.

Method Detail

### insert

    private void insert(java.sql.Connection c)
                 throws java.sql.SQLException

  Inserts the new interface into the ipInterface table of the OpenNMS databasee.

  Parameters:
    `c` - The connection to the database.
  Throws:
    `java.sql.SQLException` - Thrown if an error occurs with the connection

### update

    private void update(java.sql.Connection c)
                 throws java.sql.SQLException

  Updates an existing record in the OpenNMS ipInterface table.

  Parameters:
    `c` - The connection used for the update.
  Throws:
    `java.sql.SQLException` - Thrown if an error occurs with the connection

### load

    private boolean load(java.sql.Connection c)
                  throws java.sql.SQLException

  Load the current interface from the database. If the interface was modified, the modifications are lost. The nodeid and ip address must be set prior to this call.

  Parameters:
    `c` - The connection used to load the data.
  Throws:
    `java.sql.SQLException` - Thrown if an error occurs with the connection

### getNodeId

    int getNodeId()

  Returns the node entry's unique identifier. This is a non-mutable element. If the record does not yet exist in the database then a -1 is returned.

### getIfAddress

    java.net.InetAddress getIfAddress()

  Returns the IP address for the entry.

### setIfAddress

    void setIfAddress(java.net.InetAddress addr)

### hasIfAddressChanged

    boolean hasIfAddressChanged()

### updateIfAddress

    boolean updateIfAddress(java.net.InetAddress addr)

### hasIfIndex

    boolean hasIfIndex()

  Returns true if the ifIndex is defined.

### getIfIndex

    int getIfIndex()

  Returns the current ifIndex

### getNetmask

    java.net.InetAddress getNetmask()

### setNetmask

    void setNetmask(java.net.InetAddress mask)

### hasNetmaskChanged

    boolean hasNetmaskChanged()

### updateNetmask

    boolean updateNetmask(java.net.InetAddress newNetmask)

### getPhysicalAddress

    java.lang.String getPhysicalAddress()

### setPhysicalAddress

    void setPhysicalAddress(java.lang.String addr)

### hasPhysicalAddressChanged

    boolean hasPhysicalAddressChanged()

### updatePhysicalAddress

    boolean updatePhysicalAddress(java.lang.String newPhysAddr)

### getDescription

    java.lang.String getDescription()

### setDescription

    void setDescription(java.lang.String descr)

### hasDescriptionChanged

    boolean hasDescriptionChanged()

### updateDescription

    boolean updateDescription(java.lang.String newIfDescription)

### getName

    java.lang.String getName()

### setName

    void setName(java.lang.String name)

### hasNameChanged

    boolean hasNameChanged()

### updateName

    boolean updateName(java.lang.String newIfName)

### getType

    int getType()

### setType

    void setType(int type)

### hasTypeChanged

    boolean hasTypeChanged()

### updateType

    boolean updateType(int newIfType)

### getSpeed

    int getSpeed()

### setSpeed

    void setSpeed(int speed)

### hasSpeedChanged

    boolean hasSpeedChanged()

### updateSpeed

    boolean updateSpeed(int newIfSpeed)

### getAdminStatus

    int getAdminStatus()

### setAdminStatus

    void setAdminStatus(int status)

### hasAdminStatusChanged

    boolean hasAdminStatusChanged()

### updateAdminStatus

    boolean updateAdminStatus(int newIfAdminStatus)

### getOperationalStatus

    int getOperationalStatus()

### setOperationalStatus

    void setOperationalStatus(int status)

### hasOperationalStatusChanged

    boolean hasOperationalStatusChanged()

### updateOperationalStatus

    boolean updateOperationalStatus(int newIfOperStatus)

### getAlias

    java.lang.String getAlias()

### setAlias

    void setAlias(java.lang.String alias)

### hasAliasChanged

    boolean hasAliasChanged()

### updateAlias

    boolean updateAlias(java.lang.String newIfAlias)

### store

    void store()
         throws java.sql.SQLException

  Updates the interface information in the configured database. If the interface does not exist the a new row in the table is created. If the element already exists then it's current row is updated as needed based upon the current changes to the node.

  Throws:
    `java.sql.SQLException`

### store

    void store(java.sql.Connection db)
         throws java.sql.SQLException

  Updates the interface information in the configured database. If the interfaca does not exist the a new row in the table is created. If the element already exists then it's current row is updated as needed based upon the current changes to the node.

  Parameters:
    `db` - The database connection used to write the record.
  Throws:
    `java.sql.SQLException`

### create

    static DbSnmpInterfaceEntry create(int nid,
                                       int ifIndex)

  Creates a new entry. The entry is created in memory, but is not written to the database until the first call to `store`.

  Parameters:
    `nid` - The node id of the interface.
    `ifIndex` - The ifIndex of the interface
  Returns:
    A new interface record.

### get

    static DbSnmpInterfaceEntry get(int nid,
                                    int ifIndex)
                             throws java.sql.SQLException

  Retreives a current record from the database based upon the key fields of nodeID and ifindex. If the record cannot be found then a null reference is returned.

  Parameters:
    `nid` - The node id key
    `ifIndex` - the interface index.
  Returns:
    The loaded entry or null if one could not be found.
  Throws:
    `java.sql.SQLException`

### get

    static DbSnmpInterfaceEntry get(java.sql.Connection db,
                                    int nid,
                                    int ifIndex)
                             throws java.sql.SQLException

  Retreives a current record from the database based upon the key fields of nodeID and ifIndex. If the record cannot be found then a null reference is returned.

  Parameters:
    `db` - The databse connection used to load the entry.
    `nid` - The node id key
    `ifIndex` - The interface index.
  Returns:
    The loaded entry or null if one could not be found.
  Throws:
    `java.sql.SQLException`

### toString

    public java.lang.String toString()

  Creates a string that displays the internal contents of the record. This is mainly just used for debug output since the format is ad-hoc.

### main

    public static void main(java.lang.String[] args)

  For debugging only

OpenNMS API 1.2.9

Generated by ranger on May 19 2007 2335.