Package org.snmp4j.model.snmp.proxy.impl
Class SnmpTableImplRO<C extends SnmpProxyColumn,IC extends SnmpProxyIndexColumn,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>
- All Implemented Interfaces:
Serializable
,Iterable<R>
,Collection<R>
,TableModel
,SnmpProxyObject
,SnmpTableRO<IC,
,C, IT, T, R> SnmpTableUpdateListener<R>
- Direct Known Subclasses:
SnmpTableImpl
public class SnmpTableImplRO<C extends SnmpProxyColumn,IC extends SnmpProxyIndexColumn,IT,T,R extends SnmpProxyRow<IT,T>>
extends AbstractTableModel
implements SnmpTableRO<IC,C,IT,T,R>, Collection<R>
The
SnmpTableImplRO
class implements a proxy for a read-only SNMP table. Although it can be used
on a read-writable SNMP table too, modifications of the proxy table model cannot be committed to the
backing agent.- Author:
- Frank Fock
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
protected class
protected class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.snmp4j.smi.OctetString
protected int
protected Object[]
protected int
protected ConcurrentHashMap<org.snmp4j.smi.OID,
SnmpTableImplRO<C, IC, IT, T, R>.RowUpdateError> protected SnmpProxyRowFactory<R,
IT, T> protected SnmpProxyRowFilter
protected org.snmp4j.smi.OID
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
-
Constructor Summary
ConstructorsConstructorDescriptionSnmpTableImplRO
(org.snmp4j.smi.OID tableEntryOID, org.snmp4j.smi.OctetString context, SnmpProxyRowFactory<R, IT, T> rowFactory, List<C> columns, List<IC> indexColumns, 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 TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends R> c) void
addError
(List<SnmpValuesChangeSet> valuesChangeSets, SnmpErrorStatus errorStatus, int errorIndex) void
beginUpdate
(Object userObject) This method is called when a table update begins.void
clear()
void
clearError
(org.snmp4j.smi.OID rowIndex) boolean
boolean
containsAll
(Collection<?> c) int
findColumn
(String columnName) void
finishUpdate
(Object userObject) This method is called when the update with the given update ID has been finished.getCell
(org.snmp4j.smi.OID instanceOID) Class<?>
getColumnClass
(int columnIndex) int
getColumnName
(int column) int
getColumnNumber
(org.snmp4j.smi.OID columnOID) Gets the list of columnar proxy objects of this table.org.snmp4j.smi.OctetString
Get the context of the proxy object.int
getError
(org.snmp4j.smi.OID rowIndex, int column) Gets the list of index columnar proxy objects of this table.List<org.snmp4j.smi.OID>
getIndexOIDs
(org.snmp4j.smi.OID index, List<? extends SnmpProxyIndexColumn> indexColumns) Split a table index into an array of object IDs each representing the value of its corresponding index object.static org.snmp4j.smi.VariableBinding
getIndexVariable
(SnmpProxyIndexColumn indexColumn, org.snmp4j.smi.OID subIndex) List<org.snmp4j.smi.VariableBinding>
getIndexVariableBindings
(org.snmp4j.smi.OID index) static List<org.snmp4j.smi.VariableBinding>
getIndexVariables
(List<? extends SnmpProxyIndexColumn> indexes, List<? extends org.snmp4j.smi.OID> indexValues) static List<org.snmp4j.smi.VariableBinding>
getIndexVariableTemplates
(List<? extends SnmpProxyIndexColumn> indexes) Object[]
protected int
getNonPagedRowIndex
(int pageRowIndex) org.snmp4j.smi.OID
getOID()
Gets the table entry OID (thus including the.1
suffix) for the associated SNMP table.int
Gets the page size.int
org.snmp4j.smi.OID
getRowIndex
(int rowNumber) List<org.snmp4j.smi.OID>
int
getRowNumber
(org.snmp4j.smi.OID index) getTableColumnModel
(int maxCharacterPixelWidth, int maxColumnCharacters) getValueAt
(int rowIndex, int columnIndex) boolean
isEmpty()
iterator()
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.boolean
boolean
removeAll
(Collection<?> c) boolean
retainAll
(Collection<?> c) void
setCurrentIndex
(int startPos) void
setMinIndex
(Object[] minIndex) void
setPageSize
(int numRows) Sets the page size for this table.void
setRowFactory
(SnmpProxyRowFactory<R, IT, T> rowFactory) void
setRowFilter
(SnmpProxyRowFilter rowFilter) int
size()
Object[]
toArray()
<T> T[]
toArray
(T[] a) toString()
void
This method is called when the provided row has been updated.boolean
waitForTask
(TaskId taskId, long timeout) Wait until the specified background task terminates.Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
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 javax.swing.table.TableModel
addTableModelListener, isCellEditable, removeTableModelListener, setValueAt
-
Field Details
-
columns
-
indexColumns
-
rows
-
updatingRows
-
tableEntryOID
protected org.snmp4j.smi.OID tableEntryOID -
pageSize
protected int pageSize -
currentIndex
protected int currentIndex -
minIndex
-
rowFilter
-
rowFactory
-
rowErrors
protected ConcurrentHashMap<org.snmp4j.smi.OID,SnmpTableImplRO<C extends SnmpProxyColumn, rowErrorsIC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>>.RowUpdateError> -
context
protected org.snmp4j.smi.OctetString context
-
-
Constructor Details
-
SnmpTableImplRO
public SnmpTableImplRO(org.snmp4j.smi.OID tableEntryOID, org.snmp4j.smi.OctetString context, SnmpProxyRowFactory<R, IT, T> rowFactory, List<C> columns, List<IC> indexColumns, 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.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
-
getContext
public org.snmp4j.smi.OctetString getContext()Description copied from interface:SnmpProxyObject
Get the context of the proxy object.- Specified by:
getContext
in interfaceSnmpProxyObject
- Returns:
- the context associated with this proxy object.
-
getColumnName
- Specified by:
getColumnName
in interfaceTableModel
- Overrides:
getColumnName
in classAbstractTableModel
-
findColumn
- Overrides:
findColumn
in classAbstractTableModel
-
getColumnClass
- Specified by:
getColumnClass
in interfaceTableModel
- Overrides:
getColumnClass
in classAbstractTableModel
-
getOID
public org.snmp4j.smi.OID getOID()Description copied from interface:SnmpTableRO
Gets the table entry OID (thus including the.1
suffix) for the associated SNMP table.- Specified by:
getOID
in interfaceSnmpProxyObject
- Specified by:
getOID
in interfaceSnmpTableRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>> - Returns:
- the table entry OID.
-
getCell
- Specified by:
getCell
in interfaceSnmpTableRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>>
-
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
- 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.
-
waitForTask
Description copied from interface:SnmpProxyObject
Wait until the specified background task terminates.- Specified by:
waitForTask
in interfaceSnmpProxyObject
- Parameters:
taskId
- the task ID of the task to wait for.timeout
- the maximum time to wait in millis.- Returns:
true
if the task has terminated,false
otherwise.
-
getColumns
Description copied from interface:SnmpTableRO
Gets the list of columnar proxy objects of this table.- Specified by:
getColumns
in interfaceSnmpTableRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>> - Returns:
- the list of column proxy objects.
-
getIndexColumns
Description copied from interface:SnmpTableRO
Gets the list of index columnar proxy objects of this table.- Specified by:
getIndexColumns
in interfaceSnmpTableRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>> - Returns:
- the list of index column proxy objects.
-
setPageSize
public void setPageSize(int numRows) Description copied from interface:SnmpTableRO
Sets the page size for this table. For any value greater than zero, theTableModel
will view only a single page of rows of this proxy table.- Specified by:
setPageSize
in interfaceSnmpTableRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>> - Parameters:
numRows
- the number of rows in the table.
-
getPageSize
public int getPageSize()Description copied from interface:SnmpTableRO
Gets the page size.- Specified by:
getPageSize
in interfaceSnmpTableRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>> - Returns:
- the maximum number of rows in a page. If zero or less is returned, then there is no limit.
-
setCurrentIndex
public void setCurrentIndex(int startPos) - Specified by:
setCurrentIndex
in interfaceSnmpTableRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>>
-
getCurrentIndex
public int getCurrentIndex()- Specified by:
getCurrentIndex
in interfaceSnmpTableRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>>
-
setRowFilter
- Specified by:
setRowFilter
in interfaceSnmpTableRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>>
-
getRowFilter
- Specified by:
getRowFilter
in interfaceSnmpTableRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>>
-
getMinIndex
- Specified by:
getMinIndex
in interfaceSnmpTableRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>>
-
getIndexVariableBindings
- Specified by:
getIndexVariableBindings
in interfaceSnmpTableRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>>
-
setMinIndex
- Specified by:
setMinIndex
in interfaceSnmpTableRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>>
-
getRowFactory
- Specified by:
getRowFactory
in interfaceSnmpTableRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>>
-
setRowFactory
-
beginUpdate
Description copied from interface:SnmpTableUpdateListener
This method is called when a table update begins.- Specified by:
beginUpdate
in interfaceSnmpTableUpdateListener<C extends SnmpProxyColumn>
- Parameters:
userObject
- the ID of the update procedure.
-
updateRow
Description copied from interface:SnmpTableUpdateListener
This method is called when the provided row has been updated.- Specified by:
updateRow
in interfaceSnmpTableUpdateListener<C extends SnmpProxyColumn>
- Parameters:
userObject
- the ID of the update procedure.updateRow
- the updated row.
-
finishUpdate
Description copied from interface:SnmpTableUpdateListener
This method is called when the update with the given update ID has been finished.- Specified by:
finishUpdate
in interfaceSnmpTableUpdateListener<C extends SnmpProxyColumn>
- Parameters:
userObject
- the ID of the update procedure.
-
getRowCount
public int getRowCount()- Specified by:
getRowCount
in interfaceTableModel
-
getColumnCount
public int getColumnCount()- Specified by:
getColumnCount
in interfaceTableModel
-
getValueAt
- Specified by:
getValueAt
in interfaceTableModel
-
getNonPagedRowIndex
protected int getNonPagedRowIndex(int pageRowIndex) -
getIndexVariable
public static org.snmp4j.smi.VariableBinding getIndexVariable(SnmpProxyIndexColumn indexColumn, org.snmp4j.smi.OID subIndex) -
getIndexVariables
public static List<org.snmp4j.smi.VariableBinding> getIndexVariables(List<? extends SnmpProxyIndexColumn> indexes, List<? extends org.snmp4j.smi.OID> indexValues) -
getIndexVariableTemplates
public static List<org.snmp4j.smi.VariableBinding> getIndexVariableTemplates(List<? extends SnmpProxyIndexColumn> indexes) -
getIndexOIDs
public List<org.snmp4j.smi.OID> getIndexOIDs(org.snmp4j.smi.OID index, List<? extends SnmpProxyIndexColumn> indexColumns) Split a table index into an array of object IDs each representing the value of its corresponding index object. For example if a table's index would be defined as INDEX { ifIndex, ipAddress } and the index given would be "1.127.0.0.1" the resulting array would be { "1", "127.0.0.1" }- Parameters:
index
- an OID denoting a table's index value.indexColumns
- an array of index object descriptions.- Returns:
- a list of OID instances with the same size as indexColumns. If the given index is not a valid object ID null is returned.
-
getTableColumnModel
- Specified by:
getTableColumnModel
in interfaceSnmpTableRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>>
-
addError
public void addError(List<SnmpValuesChangeSet> valuesChangeSets, SnmpErrorStatus errorStatus, int errorIndex) - Specified by:
addError
in interfaceSnmpTableRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>>
-
getError
- Specified by:
getError
in interfaceSnmpTableRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>>
-
clearAllErrors
public void clearAllErrors()- Specified by:
clearAllErrors
in interfaceSnmpTableRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>>
-
clearError
- Specified by:
clearError
in interfaceSnmpTableRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>>
-
size
public int size()- Specified by:
size
in interfaceCollection<C extends SnmpProxyColumn>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<C extends SnmpProxyColumn>
-
contains
- Specified by:
contains
in interfaceCollection<C extends SnmpProxyColumn>
-
iterator
- Specified by:
iterator
in interfaceCollection<C extends SnmpProxyColumn>
- Specified by:
iterator
in interfaceIterable<C extends SnmpProxyColumn>
-
toArray
- Specified by:
toArray
in interfaceCollection<C extends SnmpProxyColumn>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArray
in interfaceCollection<C extends SnmpProxyColumn>
-
add
- Specified by:
add
in interfaceCollection<C extends SnmpProxyColumn>
-
remove
- Specified by:
remove
in interfaceCollection<C extends SnmpProxyColumn>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<C extends SnmpProxyColumn>
-
addAll
- Specified by:
addAll
in interfaceCollection<C extends SnmpProxyColumn>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<C extends SnmpProxyColumn>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<C extends SnmpProxyColumn>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<C extends SnmpProxyColumn>
-
getRowNumber
public int getRowNumber(org.snmp4j.smi.OID index) - Specified by:
getRowNumber
in interfaceSnmpTableRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>>
-
getColumnNumber
public int getColumnNumber(org.snmp4j.smi.OID columnOID) - Specified by:
getColumnNumber
in interfaceSnmpTableRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>>
-
getRowIndexes
- Specified by:
getRowIndexes
in interfaceSnmpTableRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>>
-
getRowIndex
public org.snmp4j.smi.OID getRowIndex(int rowNumber) - Specified by:
getRowIndex
in interfaceSnmpTableRO<C extends SnmpProxyColumn,
IC extends SnmpProxyIndexColumn, IT, T, R extends SnmpProxyRow<IT, T>>
-
toString
-