Package org.snmp4j.model.snmp.proxy.impl
Class SnmpTableImpl<IC extends SnmpProxyIndexColumn,C extends SnmpProxyColumn,IT,T,R extends SnmpProxyRow<IT,T>>
java.lang.Object
javax.swing.table.AbstractTableModel
org.snmp4j.model.snmp.proxy.impl.SnmpTableImplRO<C,IC,IT,T,R>
org.snmp4j.model.snmp.proxy.impl.SnmpTableImpl<IC,C,IT,T,R>
- Type Parameters:
C
- the proxy column type fo the table proxy.IC
- the index proxy column type for the table proxy.IT
- the model value type for index columns.T
- the model value type for the columnar model values.R
- the proxy row type for the rows of the table.
- All Implemented Interfaces:
Serializable
,Iterable<R>
,Collection<R>
,TableModel
,MutableSnmpProxy
,SnmpCommitListener
,SnmpProxyObject
,SnmpTable<C,
,IC, IT, T, R> SnmpTableRO<IC,
,C, IT, T, R> SnmpTableUpdateListener<R>
public class SnmpTableImpl<IC extends SnmpProxyIndexColumn,C extends SnmpProxyColumn,IT,T,R extends SnmpProxyRow<IT,T>>
extends SnmpTableImplRO<C,IC,IT,T,R>
implements SnmpTable<C,IC,IT,T,R>
The SnmpTableImpl class implements a writable SNMP table that implements the Java
TableModel
.- Author:
- Frank Fock
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.snmp4j.model.snmp.proxy.impl.SnmpTableImplRO
SnmpTableImplRO.RowUpdateError, SnmpTableImplRO.SnmpColumnOidComparator, SnmpTableImplRO.SnmpProxyRowOidComparator
-
Field Summary
Fields inherited from class org.snmp4j.model.snmp.proxy.impl.SnmpTableImplRO
columns, context, currentIndex, indexColumns, minIndex, pageSize, rowErrors, rowFactory, rowFilter, rows, tableEntryOID, updatingRows
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
-
Constructor Summary
ConstructorsConstructorDescriptionSnmpTableImpl
(org.snmp4j.smi.OID tableEntryOID, org.snmp4j.smi.OctetString context, SnmpProxyCommitter snmpProxyCommitter, SnmpProxyRowFactory<R, IT, T> rowFactory, List<IC> indexColumns, List<C> columns, int pageSize) Creates a proxy table implementation based on the SNMP table entry object identifier and lists with the index and regular column proxy objects as well as a page size to support paged table models. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
cellUpdated
(int row, int column, SnmpValueChange change) protected void
cellUpdateValidationFailure
(int row, int column, SnmpValueChange change) void
clear()
Remove all rows of the proxy table without changing the target SNMP table at all.void
commitFailure
(List<SnmpValuesChangeSet> failedChanges, SnmpErrorStatus errorStatus, int errorIndex) Indicates a failed commit operation.void
commitSuccess
(List<SnmpValuesChangeSet> committedChanges) Indication of a successful commit.boolean
doChange
(SnmpValuesChangeSet changeSet) Perform a change by adding it to the committer queue.boolean
doChange
(SnmpValuesChangeSet changeSet, boolean addToCommitter) Performs a change by validating it using theSnmpProxyCommitter
.org.snmp4j.smi.OID
getCellOID
(int column, org.snmp4j.smi.OID index) Gets the cell update listener associated with this table.int
getRowNumber
(org.snmp4j.smi.OID rowIndex) Gets the row number for the specified SNMP row index value.void
Insert a new row into the table.boolean
isCellEditable
(int rowIndex, int columnIndex) reload
(SnmpService snmpService, org.snmp4j.Target target, VariableBindingMapper variableBindingMapper, SnmpProxyReloadListener reloadListener) Reload the model content of the proxy object from the target SNMP entity asynchronously in the background.removeRow
(int rowIndex) Removes a row from the model without changing the associated SNMP table.removeRow
(org.snmp4j.smi.OID rowIndex) Removes a row from the model without changing the associated SNMP table.void
setCellUpdateListener
(SnmpCellUpdateListener cellUpdateListener) Sets the cell update listener associated with this table.void
setValueAt
(Object aValue, int rowIndex, int columnIndex) boolean
undoChange
(SnmpValuesChangeSet changeSet) Undo a change by adding the compensation change to the committer queue.Methods inherited from class org.snmp4j.model.snmp.proxy.impl.SnmpTableImplRO
add, addAll, addError, beginUpdate, clearAllErrors, clearError, contains, containsAll, findColumn, finishUpdate, getCell, getColumnClass, getColumnCount, getColumnName, getColumnNumber, getColumns, getContext, getCurrentIndex, getError, getIndexColumns, getIndexOIDs, getIndexVariable, getIndexVariableBindings, getIndexVariables, getIndexVariableTemplates, getMinIndex, getNonPagedRowIndex, getOID, getPageSize, getRowCount, getRowFactory, getRowFilter, getRowIndex, getRowIndexes, getTableColumnModel, getValueAt, isEmpty, iterator, remove, removeAll, retainAll, setCurrentIndex, setMinIndex, setPageSize, setRowFactory, setRowFilter, size, toArray, toArray, toString, updateRow, waitForTask
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
Methods inherited from interface org.snmp4j.model.snmp.proxy.SnmpCommitListener
getContext
Methods inherited from interface org.snmp4j.model.snmp.proxy.SnmpProxyObject
getContext, waitForTask
Methods inherited from interface org.snmp4j.model.snmp.proxy.SnmpTable
fireTableCellUpdated
Methods inherited from interface org.snmp4j.model.snmp.proxy.SnmpTableRO
addError, clearAllErrors, clearError, getCell, getColumnNumber, getColumns, getCurrentIndex, getError, getIndexColumns, getIndexVariableBindings, getMinIndex, getOID, getPageSize, getRowFactory, getRowFilter, getRowIndex, getRowIndexes, getTableColumnModel, setCurrentIndex, setMinIndex, setPageSize, setRowFilter
Methods inherited from interface org.snmp4j.model.snmp.proxy.SnmpTableUpdateListener
beginUpdate, finishUpdate, updateRow
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, getColumnClass, getColumnCount, getColumnName, getRowCount, getValueAt, removeTableModelListener
-
Constructor Details
-
SnmpTableImpl
public SnmpTableImpl(org.snmp4j.smi.OID tableEntryOID, org.snmp4j.smi.OctetString context, SnmpProxyCommitter snmpProxyCommitter, SnmpProxyRowFactory<R, IT, T> rowFactory, List<IC> indexColumns, List<C> columns, int pageSize) Creates a proxy table implementation based on the SNMP table entry object identifier and lists with the index and regular column proxy objects as well as a page size to support paged table models.- Parameters:
tableEntryOID
- the OID of the SNMP table Entry object (thus the table OID inclusive the entry suffix.1
).context
- the SNMP context associated with this proxy object.snmpProxyCommitter
- the proxy committer used to commit changes to model values to the associated target SNMP entity.rowFactory
- the factory for new model rows.indexColumns
- the index proxy column objects.columns
- the proxy column objects.pageSize
- the page size for paged table models. A zero (or less) size disables paging.
-
-
Method Details
-
getCommitter
- Specified by:
getCommitter
in interfaceMutableSnmpProxy
-
setValueAt
- Specified by:
setValueAt
in interfaceTableModel
- Overrides:
setValueAt
in classAbstractTableModel
-
getCellUpdateListener
Description copied from interface:SnmpTable
Gets the cell update listener associated with this table.- Specified by:
getCellUpdateListener
in interfaceSnmpTable<IC extends SnmpProxyIndexColumn,
C extends SnmpProxyColumn, IT, T, R extends SnmpProxyRow<IT, T>> - Returns:
- the cell update listener of this table.
-
setCellUpdateListener
Description copied from interface:SnmpTable
Sets the cell update listener associated with this table.- Specified by:
setCellUpdateListener
in interfaceSnmpTable<IC extends SnmpProxyIndexColumn,
C extends SnmpProxyColumn, IT, T, R extends SnmpProxyRow<IT, T>> - Parameters:
cellUpdateListener
- the new cell update listener for this table.
-
cellUpdateValidationFailure
-
cellUpdated
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex) - Specified by:
isCellEditable
in interfaceTableModel
- Overrides:
isCellEditable
in classAbstractTableModel
-
getCellOID
public org.snmp4j.smi.OID getCellOID(int column, org.snmp4j.smi.OID index) -
insertRow
Description copied from interface:SnmpTable
Insert a new row into the table. This adds a new change set to theSnmpCommitListener
.- Specified by:
insertRow
in interfaceSnmpTable<IC extends SnmpProxyIndexColumn,
C extends SnmpProxyColumn, IT, T, R extends SnmpProxyRow<IT, T>> - Parameters:
newRow
- the new proxy row.
-
removeRow
Removes a row from the model without changing the associated SNMP table.- Parameters:
rowIndex
- the zero based row index.- Returns:
- the removed row.
-
removeRow
Removes a row from the model without changing the associated SNMP table.- Parameters:
rowIndex
- the SNMP row index (i.e., the OID suffix that identifies the row in the table).- Returns:
- the removed row or
null
if such a row could not be found.
-
clear
public void clear()Description copied from interface:SnmpTable
Remove all rows of the proxy table without changing the target SNMP table at all.- Specified by:
clear
in interfaceCollection<IC extends SnmpProxyIndexColumn>
- Specified by:
clear
in interfaceSnmpTable<IC extends SnmpProxyIndexColumn,
C extends SnmpProxyColumn, IT, T, R extends SnmpProxyRow<IT, T>> - Overrides:
clear
in classSnmpTableImplRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>>
-
commitSuccess
Description copied from interface:SnmpCommitListener
Indication of a successful commit.- Specified by:
commitSuccess
in interfaceSnmpCommitListener
- Parameters:
committedChanges
- the list of successfully committed change sets (each change set was committed atomically for itself).
-
commitFailure
public void commitFailure(List<SnmpValuesChangeSet> failedChanges, SnmpErrorStatus errorStatus, int errorIndex) Description copied from interface:SnmpCommitListener
Indicates a failed commit operation.- Specified by:
commitFailure
in interfaceSnmpCommitListener
- Parameters:
failedChanges
- the changes that failed to commit (none of the changes within a single change set must have been committed, if the change set was small enough to be committed atomically).errorStatus
- the SNMP error status of the first failed change set.errorIndex
- the index in the original list of changes committed that failed (zero based).
-
reload
public TaskId reload(SnmpService snmpService, org.snmp4j.Target target, VariableBindingMapper variableBindingMapper, SnmpProxyReloadListener reloadListener) Description copied from interface:SnmpProxyObject
Reload the model content of the proxy object from the target SNMP entity asynchronously in the background.- Specified by:
reload
in interfaceSnmpProxyObject
- Overrides:
reload
in classSnmpTableImplRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>> - Parameters:
snmpService
- the SNMP service to use.target
- the SNMP target (i.e., address, timeouts, etc.) to use.variableBindingMapper
- the variable binding mapper that maps the retrieved SNMP values to model values (based on SNMP types or specific OID based mappings).reloadListener
- a callback listener that is informed about the reloading status.- Returns:
- the task ID for the background task.
-
getRowNumber
public int getRowNumber(org.snmp4j.smi.OID rowIndex) Gets the row number for the specified SNMP row index value.- Specified by:
getRowNumber
in interfaceSnmpTableRO<IC extends SnmpProxyIndexColumn,
C extends SnmpProxyColumn, IT, T, R extends SnmpProxyRow<IT, T>> - Overrides:
getRowNumber
in classSnmpTableImplRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>> - Parameters:
rowIndex
- a SNMP row index (i.e., the OID suffix that identifies a row in the target table).- Returns:
- the row number the is associated with the given SNMP row index or a negative number whose abstract value identifies where such a row could be inserted in the row model.
-
doChange
Description copied from interface:MutableSnmpProxy
Perform a change by adding it to the committer queue.- Specified by:
doChange
in interfaceMutableSnmpProxy
- Parameters:
changeSet
- the change to perform atomically.- Returns:
true
if the change passed validation and thus was successfully added to the queue.
-
doChange
Performs a change by validating it using theSnmpProxyCommitter
. Optionally the change is then also added the the proxy committer queue.- Parameters:
changeSet
- aSnmpValuesChangeSet
that contains changes to model objects that refer to cells of this proxy table.addToCommitter
- iftrue
, the changes will also be added to the proxy committer change queue for committing the changes to the target SNMP table.- Returns:
true
if the change set was valid. If not, no changes to the model and the target SNMP table are performed.
-
undoChange
Description copied from interface:MutableSnmpProxy
Undo a change by adding the compensation change to the committer queue.- Specified by:
undoChange
in interfaceMutableSnmpProxy
- Parameters:
changeSet
- the change to undo atomically.- Returns:
true
if the undo change passed validation and thus was successfully added to the queue.
-