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<?>>
The
MOTable 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
Modifier and TypeMethodDescriptionvoidAdds aMOTableRowListenerlistener that needs to be informed about row changes (creation, addition, removal).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).booleanAdds the supplied row to the underlying table model and fires the appropriateMOTableRowEvent.createRow(org.snmp4j.smi.OID index) Creates a new row for this table with the supplied index and default values.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.OIDFinds the object identifier of the first object instance in the specified range.getCellInfo(org.snmp4j.smi.OID oid) Returns aMOTableCellInfoinstance for the supplied cell OID.getColumn(int index) Gets the column definition for the specified column.intReturns the number of columns in this table.intgetColumnIndex(int id) Returns the zero based column index for the specified column sub-identifier.C[]Gets the column definitions for this table.org.snmp4j.smi.Variable[]Returns an array of variables where each variable corresponds to the column with the same index.Gets the index definition of this table.org.snmp4j.smi.OIDgetIndexPart(org.snmp4j.smi.OID instanceIdentifier) Returns the index part of a column instance identifier of this table.getModel()Gets the table model of this table.org.snmp4j.smi.OIDgetOID()Returns the OID of the table entry.org.snmp4j.smi.VariablegetValue(org.snmp4j.smi.OID cellOID) Gets the value of the cell instance with the specified instance OID.org.snmp4j.smi.VariablegetValue(org.snmp4j.smi.OID index, int col) Gets the value of the cell instance in the specified column and row.voidRemovesMOTableRowListenerinstance.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, removeMOChangeListenerMethods inherited from interface org.snmp4j.agent.ManagedObject
cleanup, commit, get, getScope, next, prepare, undoMethods inherited from interface org.snmp4j.agent.ManagedObjectValueAccess
setValue
-
Method Details
-
find
Finds the object identifier of the first object instance in the specified range.- Specified by:
findin interfaceManagedObject<R extends MOTableRow>- Parameters:
range- aMOScopespecifying the search range.- Returns:
- the OID of the lexicographic first instance in the search range or
nullif 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)-1position ifnis the returned value.
-
getColumns
C[] getColumns()Gets the column definitions for this table.- Returns:
- an array with the column definitions of this table.
-
getColumn
Gets the column definition for the specified column.- Parameters:
index- the (zero-based) column index.- Returns:
- a
MOColumninstance describing the attributes of requested column.
-
getCellInfo
Returns aMOTableCellInfoinstance 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
MOTableCellInfoinstance 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
instanceIdentifiercolumn 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 notnulland contains that default value.- Returns:
- the default variables for a newly created row as an array of
Variableinstances.
-
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:
getValuein interfaceManagedObjectValueAccess<R extends MOTableRow>- Parameters:
cellOID- the instance OID of the requested cell.- Returns:
- the value of the cell or
nullif 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
nullif such a cell does not exist.
-
addMOTableRowListener
Adds aMOTableRowListenerlistener that needs to be informed about row changes (creation, addition, removal).- Parameters:
l- aMOTableRowListenerinstance.
-
removeMOTableRowListener
RemovesMOTableRowListenerinstance.- Parameters:
l- aMOTableRowListenerinstance.
-
createRow
Creates a new row for this table with the supplied index and initial values. If one of theMOTableRowListenerdeny the row creation attempt thennullwill 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
MOTableRowinstance ornullif the row cannot be created.
-
addNewRow
Creates a new row for this table with the supplied index and initial values and then immediately callsaddRow(MOTableRow). If one of theMOTableRowListenerdeny the row creation attempt thennullwill 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
MOTableRowinstance ornullif the row cannot be created. - Since:
- 2.2
-
createRow
Creates a new row for this table with the supplied index and default values. If one of theMOTableRowListenerdeny the row creation attempt thennullwill be returned.- Parameters:
index- the index OID of the new row.- Returns:
- the created
MOTableRowinstance ornullif the row cannot be created.
-
addRow
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- theMOTableRowto add.- Returns:
trueif the row has been added orfalseif it could not be added.
-
removeRow
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
nullif the row cannot be found or cannot be removed.
-