Module org.snmp4j.agent
Package org.snmp4j.agent.mo
Interface MOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>>
-
- All Superinterfaces:
ChangeableManagedObject<SubRequest<?>>
,GenericManagedObject
,ManagedObject<SubRequest<?>>
,ManagedObjectValueAccess<SubRequest<?>>
- All Known Implementing Classes:
DefaultMOTable
,SNMPv2MIB.SysOREntry
public interface MOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>> extends GenericManagedObject, ManagedObjectValueAccess<SubRequest<?>>, ChangeableManagedObject<SubRequest<?>>
TheMOTable
interface describes SNMP conceptual tables. In general, a conceptual table can be implemented in two different ways:- For large tables, a virtual table model is best suited where rows are created on behalf of a request only. The instrumentation directly propagates data to the managed objects without holding the data in a table model.
- For small or medium size tables, holding the data in (non virtual) table model provides data caching and decoupling of the instrumentation.
- Version:
- 3.1.0
- Author:
- Frank Fock
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addMOTableRowListener(MOTableRowListener<R> l)
Adds aMOTableRowListener
listener that needs to be informed about row changes (creation, addition, removal).R
addNewRow(org.snmp4j.smi.OID index, org.snmp4j.smi.Variable[] initialValues)
Creates a new row for this table with the supplied index and initial values and then immediately callsaddRow(MOTableRow)
.boolean
addRow(R row)
Adds the supplied row to the underlying table model and fires the appropriateMOTableRowEvent
.R
createRow(org.snmp4j.smi.OID index)
Creates a new row for this table with the supplied index and default values.R
createRow(org.snmp4j.smi.OID index, org.snmp4j.smi.Variable[] initialValues)
Creates a new row for this table with the supplied index and initial values.org.snmp4j.smi.OID
find(MOScope range)
Finds the object identifier of the first object instance in the specified range.MOTableCellInfo
getCellInfo(org.snmp4j.smi.OID oid)
Returns aMOTableCellInfo
instance for the supplied cell OID.C
getColumn(int index)
Gets the column definition for the specified column.int
getColumnCount()
Returns the number of columns in this table.int
getColumnIndex(int id)
Returns the zero based column index for the specified column sub-identifier.C[]
getColumns()
Gets the column definitions for this table.org.snmp4j.smi.Variable[]
getDefaultValues()
Returns an array of variables where each variable corresponds to the column with the same index.MOTableIndex
getIndexDef()
Gets the index definition of this table.org.snmp4j.smi.OID
getIndexPart(org.snmp4j.smi.OID instanceIdentifier)
Returns the index part of a column instance identifier of this table.M
getModel()
Gets the table model of this table.org.snmp4j.smi.OID
getOID()
Returns the OID of the table entry.org.snmp4j.smi.Variable
getValue(org.snmp4j.smi.OID cellOID)
Gets the value of the cell instance with the specified instance OID.org.snmp4j.smi.Variable
getValue(org.snmp4j.smi.OID index, int col)
Gets the value of the cell instance in the specified column and row.void
removeMOTableRowListener(MOTableRowListener<R> l)
RemovesMOTableRowListener
instance.R
removeRow(org.snmp4j.smi.OID index)
Removes the row with the specified index and returns it if the operation was successful.-
Methods inherited from interface org.snmp4j.agent.mo.ChangeableManagedObject
addMOChangeListener, removeMOChangeListener
-
Methods inherited from interface org.snmp4j.agent.ManagedObject
cleanup, commit, get, getScope, next, prepare, undo
-
Methods inherited from interface org.snmp4j.agent.ManagedObjectValueAccess
setValue
-
-
-
-
Method Detail
-
find
org.snmp4j.smi.OID find(MOScope range)
Finds the object identifier of the first object instance in the specified range.- Specified by:
find
in interfaceManagedObject<R extends MOTableRow>
- Parameters:
range
- aMOScope
specifying the search range.- Returns:
- the OID of the lexicographic first instance in the search range or
null
if no such instance exists.
-
getColumnIndex
int getColumnIndex(int id)
Returns the zero based column index for the specified column sub-identifier.- Parameters:
id
- a column sub-identifier (normally one based) as defined in the MIB specification.- Returns:
- a value greater or equal to zero denoting the column index
of the column associated with
id
. The column index points into the column array returned bygetColumns()
. A value less than zero indicates that such a column does not exists currently but could be inserted at the(-n)-1
position ifn
is the returned value.
-
getColumns
C[] getColumns()
Gets the column definitions for this table.- Returns:
- an array with the column definitions of this table.
-
getColumn
C getColumn(int index)
Gets the column definition for the specified column.- Parameters:
index
- the (zero-based) column index.- Returns:
- a
MOColumn
instance describing the attributes of requested column.
-
getCellInfo
MOTableCellInfo getCellInfo(org.snmp4j.smi.OID oid)
Returns aMOTableCellInfo
instance for the supplied cell OID. The returned object contains the index, column index, and column ID of the specified cell, if available.- Parameters:
oid
- cell instance OID.- Returns:
- a
MOTableCellInfo
instance with the index, column index and column ID of the specified cell if available.
-
getColumnCount
int getColumnCount()
Returns the number of columns in this table.- Returns:
- the column count.
-
getIndexDef
MOTableIndex getIndexDef()
Gets the index definition of this table.- Returns:
- a MOTableIndex instance containing the sub-index definitions for this table.
-
getIndexPart
org.snmp4j.smi.OID getIndexPart(org.snmp4j.smi.OID instanceIdentifier)
Returns the index part of a column instance identifier of this table.- Parameters:
instanceIdentifier
- the OID of a column instance. The returned result is undefined, when this OID is not a column instance OID.- Returns:
- an OID representing the index OID of the row identified by the
instanceIdentifier
column instance OID.
-
getModel
M getModel()
Gets the table model of this table.- Returns:
- a MOTableModel instance.
-
getOID
org.snmp4j.smi.OID getOID()
Returns the OID of the table entry.- Returns:
- a table entry OID (including the .1 suffix).
-
getDefaultValues
org.snmp4j.smi.Variable[] getDefaultValues()
Returns an array of variables where each variable corresponds to the column with the same index. If a column has a default value, the returned variable is notnull
and contains that default value.- Returns:
- the default variables for a newly created row as an array of
Variable
instances.
-
getValue
org.snmp4j.smi.Variable getValue(org.snmp4j.smi.OID cellOID)
Gets the value of the cell instance with the specified instance OID.- Specified by:
getValue
in interfaceManagedObjectValueAccess<R extends MOTableRow>
- Parameters:
cellOID
- the instance OID of the requested cell.- Returns:
- the value of the cell or
null
if such a cell does not exist.
-
getValue
org.snmp4j.smi.Variable getValue(org.snmp4j.smi.OID index, int col)
Gets the value of the cell instance in the specified column and row.- Parameters:
index
- the row index of the cell.col
- the column index of the cell.- Returns:
- the value of the cell or
null
if such a cell does not exist.
-
addMOTableRowListener
void addMOTableRowListener(MOTableRowListener<R> l)
Adds aMOTableRowListener
listener that needs to be informed about row changes (creation, addition, removal).- Parameters:
l
- aMOTableRowListener
instance.
-
removeMOTableRowListener
void removeMOTableRowListener(MOTableRowListener<R> l)
RemovesMOTableRowListener
instance.- Parameters:
l
- aMOTableRowListener
instance.
-
createRow
R createRow(org.snmp4j.smi.OID index, org.snmp4j.smi.Variable[] initialValues)
Creates a new row for this table with the supplied index and initial values. If one of theMOTableRowListener
deny the row creation attempt thennull
will be returned.- Parameters:
index
- the index OID of the new row.initialValues
- the initial values that should be assigned to the new row.- Returns:
- the created
MOTableRow
instance ornull
if the row cannot be created.
-
addNewRow
R addNewRow(org.snmp4j.smi.OID index, org.snmp4j.smi.Variable[] initialValues)
Creates a new row for this table with the supplied index and initial values and then immediately callsaddRow(MOTableRow)
. If one of theMOTableRowListener
deny the row creation attempt thennull
will be returned andaddRow(MOTableRow)
will not be called.This method is the same as calling:
R newRow = createRow(index, initialValues); if (newRow != null) { addRow(newRow); } return newRow;
- Parameters:
index
- the index OID of the new row.initialValues
- the initial values that should be assigned to the new row.- Returns:
- the created
MOTableRow
instance ornull
if the row cannot be created. - Since:
- 2.2
-
createRow
R createRow(org.snmp4j.smi.OID index)
Creates a new row for this table with the supplied index and default values. If one of theMOTableRowListener
deny the row creation attempt thennull
will be returned.- Parameters:
index
- the index OID of the new row.- Returns:
- the created
MOTableRow
instance ornull
if the row cannot be created.
-
addRow
boolean addRow(R row)
Adds the supplied row to the underlying table model and fires the appropriateMOTableRowEvent
. Since this method is typically called during the commit phase of a SET request that creates a table, it should be avoided to return an error here. Instead error checking should be placed in the- Parameters:
row
- theMOTableRow
to add.- Returns:
true
if the row has been added orfalse
if it could not be added.
-
removeRow
R removeRow(org.snmp4j.smi.OID index)
Removes the row with the specified index and returns it if the operation was successful.- Parameters:
index
- the index OID of the row to remove.- Returns:
- the removed row or
null
if the row cannot be found or cannot be removed.
-
-