|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.snmp4j.agent.mo.DefaultMOTable<R,C,M>
public class DefaultMOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>>
The DefaultMOTable class is the default implementation of the
MOTable class. For most use cases, it is not necessary to customize
this class through deriving your own sub-class. Instead, using a different
MOTableModel as table data provider is sufficient.
The default table model can be used to hold the data of a SNMP conceptual
table as real tabular data. If you want to implement a virtual table, you
will have to directly implement the interfaces MOTableModel or
MOMutableTableModel to access the data based on the actual view.
| Nested Class Summary | |
|---|---|
static class |
DefaultMOTable.ChangeSet
|
| Field Summary | |
|---|---|
protected java.util.Vector<MOChangeListener> |
moChangeListeners
|
protected M |
model
|
protected java.util.Vector<MOTableRowListener> |
moTableRowListeners
|
protected java.util.WeakHashMap<Request,java.util.Map<org.snmp4j.smi.OID,R>> |
newRows
|
protected java.util.WeakHashMap<Request,java.util.Map<org.snmp4j.smi.OID,DefaultMOTable.ChangeSet>> |
pendingChanges
|
| Constructor Summary | |
|---|---|
DefaultMOTable(org.snmp4j.smi.OID oid,
MOTableIndex indexDef,
C[] columns)
|
|
DefaultMOTable(org.snmp4j.smi.OID oid,
MOTableIndex indexDef,
C[] columns,
M model)
Creates a new SNMP table with the specified "Entry" OID, INDEX, columns, and MOTableModel. |
|
| Method Summary | |
|---|---|
void |
addMOChangeListener(MOChangeListener l)
Adds a MOChangeListener that needs to be informed about
state changes of this table. |
void |
addMOTableRowListener(MOTableRowListener l)
Adds a MOTableRowListener listener that needs to be informed
about row changes (creation, addition, removal). |
protected DefaultMOTable.ChangeSet |
addPendingChanges(SubRequest subRequest,
MOTableRow row,
boolean newRow)
|
boolean |
addRow(R row)
Adds the supplied row to the underlying table model and fires the appropriate MOTableRowEvent. |
void |
cleanup(SubRequest request)
Cleansup a (sub)request and frees all resources locked during the preparation phase. |
void |
commit(SubRequest request)
Commits a previously prepared SET (sub)request. |
boolean |
covers(org.snmp4j.smi.OID oid)
Checks if this scope covers the supplied OID. |
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. |
protected MOTableCellInfo |
findCell(MOScope range,
SubRequest request)
|
protected void |
fireAfterMOChange(MOChangeEvent changeEvent)
|
protected void |
fireAfterPrepareMOChange(MOChangeEvent changeEvent)
|
protected void |
fireBeforeMOChange(MOChangeEvent changeEvent)
|
protected void |
fireBeforePrepareMOChange(MOChangeEvent changeEvent)
|
protected void |
fireRowChanged(MOTableRowEvent event)
|
void |
get(SubRequest request)
Processes a GET request and return the result in the supplied sub-request. |
MOTableCellInfo |
getCellInfo(org.snmp4j.smi.OID oid)
Returns a MOTableCellInfo instance for the supplied
cell OID. |
org.snmp4j.smi.OID |
getCellOID(org.snmp4j.smi.OID index,
int col)
|
protected int |
getChangesFromRequest(org.snmp4j.smi.OID index,
MOTableRow row,
SubRequest request,
org.snmp4j.smi.Variable[] values,
boolean setDefaultValues,
boolean newRow)
|
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. |
org.snmp4j.smi.OID |
getID()
Gets the unique object ID of the managed object. |
MOTableIndex |
getIndexDef()
Gets the index definition of this table. |
org.snmp4j.smi.OID |
getIndexPart(org.snmp4j.smi.OID anyOID)
Returns the index part of a column instance identifier of this table. |
org.snmp4j.smi.OID |
getLowerBound()
Gets the lower bound OID of the scope. |
M |
getModel()
Gets the table model of this table. |
protected java.util.Map<org.snmp4j.smi.OID,R> |
getNewRows(Request key)
|
org.snmp4j.smi.OID |
getOID()
Returns the OID of the table entry. |
protected DefaultMOTable.ChangeSet |
getPendingChangeSet(SubRequest subRequest,
org.snmp4j.smi.OID index)
|
protected org.snmp4j.smi.Variable[] |
getPersistentValues(MOTableRow row)
Gets the values of a row that need to be made persistent on behalf of a save(MOOutput output) call. |
MOScope |
getScope()
Returns the scope of object identifiers this managed object is managing. |
org.snmp4j.smi.OID |
getUpperBound()
Gets the upper bound OID of the scope. |
protected org.snmp4j.smi.Variable |
getValue(MOTableRow row,
int col)
|
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. |
protected boolean |
hasNewRows(Request key)
|
protected boolean |
isChangeSetComplete(SubRequest subRequest,
org.snmp4j.smi.OID index,
int column)
|
boolean |
isCovered(MOScope other)
Checks whether the supplied scope is covered by this scope. |
boolean |
isLowerIncluded()
Indicates whether the lower bound OID is included in the scope or not. |
boolean |
isOverlapping(MOScope other)
Checks whether the supplied scope overlap with this one, thus sharing at least one OID with the supplied one. |
boolean |
isUpperIncluded()
Indicates whether the upper bound OID is included in the scope or not. |
boolean |
isVolatile()
Tests if this instance of a SerializableManagedObject should be serialized or deserialized through persistent storage load or save operation. |
void |
load(MOInput input)
Loads the content of the managed object from the specified input (stream). |
boolean |
next(SubRequest request)
Finds the successor instance for the object instance ID (OID) given by the supplied sub-request and returns it within the supplied sub-request object. |
void |
prepare(SubRequest request)
Prepares a SET (sub)request. |
int |
removeAll()
Removes all rows from this table. |
void |
removeMOChangeListener(MOChangeListener l)
Removes a MOChangeListener |
void |
removeMOTableRowListener(MOTableRowListener l)
Removes MOTableRowListener instance. |
R |
removeRow(org.snmp4j.smi.OID index)
Removes the row with the specified index and returns it if the operation was successful. |
void |
save(MOOutput output)
Saves the (non-volatile) content of this managed object to the specified output (stream). |
void |
setModel(M model)
|
boolean |
setValue(org.snmp4j.smi.VariableBinding newValueAndInstancceOID)
Sets the value of a particular MIB object instance managed by this ManagedObject. |
void |
setVolatile(boolean isVolatile)
|
java.lang.String |
toString()
|
void |
undo(SubRequest request)
Compensates (undo) a (sub)request when a commit of another subrequest failed with an error. |
void |
update(MOScope updateScope)
Update the content of this table that is covered by the supplied scope. |
protected void |
update(MOScope range,
SubRequest request)
Update this table for the supplied search range and sub-request if it has not yet been updated for that request. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected M extends MOTableModel<R> model
protected java.util.WeakHashMap<Request,java.util.Map<org.snmp4j.smi.OID,R extends MOTableRow>> newRows
protected java.util.WeakHashMap<Request,java.util.Map<org.snmp4j.smi.OID,DefaultMOTable.ChangeSet>> pendingChanges
protected transient java.util.Vector<MOChangeListener> moChangeListeners
protected transient java.util.Vector<MOTableRowListener> moTableRowListeners
| Constructor Detail |
|---|
public DefaultMOTable(org.snmp4j.smi.OID oid,
MOTableIndex indexDef,
C[] columns)
public DefaultMOTable(org.snmp4j.smi.OID oid,
MOTableIndex indexDef,
C[] columns,
M model)
MOTableModel.
oid - the OID of the SNMP table's Entry object. If the table is ifTable
(1.3.6.1.2.1.2.2) then the OID to provide is 1.3.6.1.2.1.2.2.1
which is the ifEntry OID. By SMI rule, you can simply append ".1" to
the table OID.indexDef - the index definition of the table based on the INDEX clause of the
table MIB definition.columns - the column definitions which may also include non-accessible columns.model - the table model holding the table data.| Method Detail |
|---|
public MOTableCellInfo getCellInfo(org.snmp4j.smi.OID oid)
MOTableMOTableCellInfo instance for the supplied
cell OID. The returned object contains the index, column index, and
column ID of the specified cell, if available.
getCellInfo in interface MOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>>oid - cell instance OID.
MOTableCellInfo instance with the index, column index
and column ID of the specified cell if available.public int getColumnIndex(int id)
MOTable
getColumnIndex in interface MOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>>id - a column sub-identifier (normally one based) as defined in the MIB
specification.
id. The column index
points into the column array returned by MOTable.getColumns().
A value less than zero indicates that such a column does not exists
currently but could be inserted at the (-n)-1 position
if n is the returned value.public C getColumn(int index)
MOTable
getColumn in interface MOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>>index - the (zero-based) column index.
MOColumn instance describing the attributes of requested
column.public int getColumnCount()
MOTable
getColumnCount in interface MOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>>
public R createRow(org.snmp4j.smi.OID index,
org.snmp4j.smi.Variable[] initialValues)
MOMutableTableModel
instance or if one of the MOTableRowListener deny the row creation
attempt then null will be returned.
createRow in interface MOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>>index - the index OID of the new row.initialValues - the initial values that should be assigned to the new row. If the array
contains less values than this table has columns, default values will
be created for the missing columns.
MOTableRow instance or null if
the row cannot be created.public R createRow(org.snmp4j.smi.OID index)
MOTableMOTableRowListener
deny the row creation attempt then null will be returned.
createRow in interface MOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>>index - the index OID of the new row.
MOTableRow instance or null if
the row cannot be created.public boolean addRow(R row)
MOTableRowEvent. 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 prepare(org.snmp4j.agent.request.SubRequest) method.
addRow in interface MOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>>row - the MOTableRow to add.
true if the row has been added or false
if it could not be added.public R removeRow(org.snmp4j.smi.OID index)
MOTable
removeRow in interface MOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>>index - the index OID of the row to remove.
null if the row cannot be found or
cannot be removed.public int removeAll()
public void commit(SubRequest request)
ManagedObject
commit in interface ManagedObjectrequest - the SubRequest to process.public final org.snmp4j.smi.OID getIndexPart(org.snmp4j.smi.OID anyOID)
MOTable
getIndexPart in interface MOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>>anyOID - the OID of a column instance. The returned result is undefined, when
this OID is not a column instance OID.
instanceIdentifier column instance OID.
public org.snmp4j.smi.OID getCellOID(org.snmp4j.smi.OID index,
int col)
public org.snmp4j.smi.OID find(MOScope range)
MOTable
find in interface ManagedObjectfind in interface MOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>>range - a MOScope specifying the search range.
null if no such instance exists.
protected MOTableCellInfo findCell(MOScope range,
SubRequest request)
public MOScope getScope()
ManagedObject
getScope in interface ManagedObjectMOScope that defines a range (possibly also a single
or none instance OID) of object IDs managed by this managed object.public org.snmp4j.smi.Variable getValue(org.snmp4j.smi.OID cellOID)
MOTable
getValue in interface ManagedObjectValueAccessgetValue in interface MOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>>cellOID - the instance OID of the requested cell.
null if such a cell does not
exist.
public org.snmp4j.smi.Variable getValue(org.snmp4j.smi.OID index,
int col)
MOTable
getValue in interface MOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>>index - the row index of the cell.col - the column index of the cell.
null if such a cell does not
exist.
protected org.snmp4j.smi.Variable getValue(MOTableRow row,
int col)
public void update(MOScope updateScope)
This method is part of the UpdatableManagedObject interface.
Although the DefaultMOTable does not implement that interface,
subclasses of this class may do so easily by overriding this hook-up
method.
updateScope - the scope to update. If null the whole managed object is
updated.update(MOScope range, SubRequest request)
protected void update(MOScope range,
SubRequest request)
By default, the
update(MOScope updateScope) is being called on behalf of this
method call (which itself does not nothing by default). You may choose
either to implement the UpdatableManagedObject interface and
implement its interface in a subclass. Then it is recommended to overwrite
this method by an empty method. Otherwise, do not implement the
UpdatableManagedObject interface.
range - the search range.request - the sub-request triggered the update or null if that
request cannot be determined.public void get(SubRequest request)
ManagedObject
get in interface ManagedObjectrequest - the SubRequest to process.public boolean next(SubRequest request)
ManagedObject
next in interface ManagedObjectrequest - the SubRequest to process.
true if the search request found an appropriate instance,
false otherwise.public void prepare(SubRequest request)
ManagedObject
prepare in interface ManagedObjectrequest - the SubRequest to process.
protected int getChangesFromRequest(org.snmp4j.smi.OID index,
MOTableRow row,
SubRequest request,
org.snmp4j.smi.Variable[] values,
boolean setDefaultValues,
boolean newRow)
protected boolean hasNewRows(Request key)
protected java.util.Map<org.snmp4j.smi.OID,R> getNewRows(Request key)
protected boolean isChangeSetComplete(SubRequest subRequest,
org.snmp4j.smi.OID index,
int column)
protected DefaultMOTable.ChangeSet addPendingChanges(SubRequest subRequest,
MOTableRow row,
boolean newRow)
protected DefaultMOTable.ChangeSet getPendingChangeSet(SubRequest subRequest,
org.snmp4j.smi.OID index)
public void cleanup(SubRequest request)
ManagedObject
cleanup in interface ManagedObjectrequest - the SubRequest to process.public void undo(SubRequest request)
ManagedObject
undo in interface ManagedObjectrequest - the SubRequest to process.public org.snmp4j.smi.OID getOID()
MOTable
getOID in interface MOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>>public void setModel(M model)
public void setVolatile(boolean isVolatile)
public M getModel()
MOTable
getModel in interface MOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>>public C[] getColumns()
MOTable
getColumns in interface MOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>>public MOTableIndex getIndexDef()
MOTable
getIndexDef in interface MOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>>public boolean isVolatile()
SerializableManagedObject
isVolatile in interface SerializableManagedObjecttrue if SerializableManagedObject.load(org.snmp4j.agent.io.MOInput) and SerializableManagedObject.save(org.snmp4j.agent.io.MOOutput) should not be
called through a persistent storage operation and false
if these method should be called.public org.snmp4j.smi.OID getLowerBound()
MOScopeMOScope.isLowerIncluded().
getLowerBound in interface MOScopepublic org.snmp4j.smi.OID getUpperBound()
MOScopeMOScope.isUpperIncluded().
getUpperBound in interface MOScopepublic boolean isLowerIncluded()
MOScope
isLowerIncluded in interface MOScopetrue if the lower bound is included.public boolean isUpperIncluded()
MOScope
isUpperIncluded in interface MOScopetrue if the upper bound is included.public boolean isCovered(MOScope other)
MOScope
isCovered in interface MOScopeother - the MOScope to check
true if the lower bound of other is greater
or equal than the lower bound of this scope and if the upper bound of
other is lower or equal than the upper bound of this scope.public boolean isOverlapping(MOScope other)
MOScope
isOverlapping in interface MOScopeother - a MOScope.
true if there exists at least one OID that is included in
both scopes.public void addMOChangeListener(MOChangeListener l)
MOTableMOChangeListener that needs to be informed about
state changes of this table.
addMOChangeListener in interface MOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>>l - a MOChangeListener instance.public void removeMOChangeListener(MOChangeListener l)
MOTableMOChangeListener
removeMOChangeListener in interface MOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>>l - a MOChangeListener instance.protected void fireBeforePrepareMOChange(MOChangeEvent changeEvent)
protected void fireAfterPrepareMOChange(MOChangeEvent changeEvent)
protected void fireBeforeMOChange(MOChangeEvent changeEvent)
protected void fireAfterMOChange(MOChangeEvent changeEvent)
public void addMOTableRowListener(MOTableRowListener l)
MOTableMOTableRowListener listener that needs to be informed
about row changes (creation, addition, removal).
addMOTableRowListener in interface MOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>>l - a MOTableRowListener instance.public void removeMOTableRowListener(MOTableRowListener l)
MOTableMOTableRowListener instance.
removeMOTableRowListener in interface MOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>>l - a MOTableRowListener instance.protected void fireRowChanged(MOTableRowEvent event)
public org.snmp4j.smi.OID getID()
RegisteredManagedObject
getID in interface RegisteredManagedObject
public void load(MOInput input)
throws java.io.IOException
SerializableManagedObject
load in interface SerializableManagedObjectinput - a MOInput instance.
java.io.IOException - if an MOInput operation fails.
public void save(MOOutput output)
throws java.io.IOException
SerializableManagedObject
save in interface SerializableManagedObjectoutput - a MOOutput instance.
java.io.IOException - if an MOOutput operation fails.protected org.snmp4j.smi.Variable[] getPersistentValues(MOTableRow row)
save(MOOutput output) call.
row - a MOTableRow that is being saved into a MOOutput stream.
Variable instances that need to be saved.
Typically, these are all columns of the row - including hidden
extension columns/values.public org.snmp4j.smi.Variable[] getDefaultValues()
MOTablenull and contains that default value.
getDefaultValues in interface MOTable<R extends MOTableRow,C extends MOColumn,M extends MOTableModel<R>>Variable instances.public java.lang.String toString()
toString in class java.lang.Objectpublic boolean covers(org.snmp4j.smi.OID oid)
MOScope
covers in interface MOScopeoid - an OID.
true if oid is greater or equal the scope's
lower bound and if it is less or equal its upper bound.public boolean setValue(org.snmp4j.smi.VariableBinding newValueAndInstancceOID)
ManagedObjectValueAccessManagedObject. This is a low level operation, thus
no change events will be fired.
setValue in interface ManagedObjectValueAccessnewValueAndInstancceOID - a VariableBinding identifying the object instance to modify
by its OID and the new value by its variable part.
true if the object instance exists and has been modified
successfully, false otherwise.
|
Copyright 2005-2010 Frank Fock (SNMP4J.org) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||