public class MOScalar<V extends org.snmp4j.smi.Variable> extends Object implements ManagedObject, MOScope, SerializableManagedObject, ManagedObjectValueAccess
MOScalar class represents scalar SNMP managed objects.
Subclasses might support Java serialization for this class. SNMP4J
serialization is provided in any case by the SerializableManagedObject
interface.| Modifier and Type | Field and Description |
|---|---|
protected MOAccess |
access |
protected org.snmp4j.smi.OID |
oid |
| Modifier | Constructor and Description |
|---|---|
protected |
MOScalar()
Construct a MOScalar for deserialization.
|
|
MOScalar(org.snmp4j.smi.OID id,
MOAccess access,
V value)
Creates a scalar MO instance with OID, maximum access level and initial
value.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addMOChangeListener(MOChangeListener l)
Adds a
MOChangeListener that needs to be informed about
state changes of this scalar. |
void |
addMOValueValidationListener(MOValueValidationListener l)
Adds a value validation listener to check new values.
|
protected int |
changeValue(V value)
Changes the value of this scalar on behalf of a commit or undo operation.
|
protected boolean |
checkRequestScope(SubRequest request)
Checks whether the request is within the scope of this scalar or not.
|
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.
|
org.snmp4j.smi.OID |
find(MOScope range)
Finds the first object ID (OID) in the specified search range.
|
protected void |
fireAfterMOChange(MOChangeEvent changeEvent) |
protected void |
fireAfterPrepareMOChange(MOChangeEvent changeEvent) |
protected void |
fireBeforeMOChange(MOChangeEvent changeEvent) |
protected void |
fireBeforePrepareMOChange(MOChangeEvent changeEvent) |
protected void |
fireValidate(MOValueValidationEvent validationEvent) |
void |
get(SubRequest request)
Processes a GET request and return the result in the supplied sub-request.
|
MOAccess |
getAccess()
Gets the access object for this scalar.
|
org.snmp4j.smi.OID |
getID()
Gets the unique object ID of the managed object.
|
org.snmp4j.smi.OID |
getLowerBound()
Gets the lower bound OID of the scope.
|
org.snmp4j.smi.OID |
getOid()
Gets the instance OID of this scalar managed object.
|
MOScope |
getScope()
Returns the scope of OIDs that are covered by this scalar's object
registration.
|
MOScope |
getSingleInstanceScope()
Returns a scope that covers only the scalar instance itself without any
possible OIDs down in the tree or at the same level.
|
org.snmp4j.smi.OID |
getUpperBound()
Gets the upper bound OID of the scope.
|
V |
getValue()
Returns the actual value of this scalar managed object.
|
org.snmp4j.smi.Variable |
getValue(org.snmp4j.smi.OID instanceOID)
Returns the variable (a copy thereof) with the specified instance OID
managed by this
ManagedObject. |
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.
|
int |
isValueOK(SubRequest request)
Checks whether the new value contained in the supplied sub-request is a
valid value for this object.
|
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.
|
void |
removeMOChangeListener(MOChangeListener l)
Removes a
MOChangeListener. |
void |
removeMOValueValidationListener(MOValueValidationListener l)
Removes a value validation listener
|
void |
save(MOOutput output)
Saves the (non-volatile) content of this managed object to the specified
output (stream).
|
int |
setValue(V value)
Sets the value of this scalar managed object without checking it for
the correct syntax.
|
boolean |
setValue(org.snmp4j.smi.VariableBinding newValueAndInstancceOID)
Sets the value of a particular MIB object instance managed by
this
ManagedObject. |
void |
setVolatile(boolean isVolatile)
Sets the volatile flag for this instance.
|
String |
toString() |
protected String |
toStringDetails() |
void |
undo(SubRequest request)
Compensates (undo) a (sub)request when a commit of another subrequest
failed with an error.
|
protected org.snmp4j.smi.OID oid
protected MOAccess access
protected MOScalar()
oid and access members are set before the scalar is
registered with a MOServer instance. The oid must not be
changed or modified afterwards!public MOScalar(org.snmp4j.smi.OID id,
MOAccess access,
V value)
id - the instance OID of the scalar instance (last sub-identifier should be
zero).access - the maximum access level supported by this instance.value - the initial value of the scalar instance. If the initial value is
null or a Counter syntax, the scalar is created as a
volatile (non-persistent) instance by default.public MOScope getScope()
1.3.6...n <= x < 1.3.6...n+1 where n is the
last subidentifier of the OID registered by the corresponding OBJECT-TYPE
definition. Prior to version 1.1.2, this method returned a scope equal
to the scope now returned by getSingleInstanceScope().getScope in interface ManagedObjectpublic MOScope getSingleInstanceScope()
public org.snmp4j.smi.OID find(MOScope range)
ManagedObjectfind in interface ManagedObjectrange - the MOScope for the search.OID that is included in the search range
and null if no such instances could be found.public void get(SubRequest request)
ManagedObjectget in interface ManagedObjectrequest - the SubRequest to process.public MOAccess getAccess()
protected boolean checkRequestScope(SubRequest request)
request - a SubRequest.true if the request is within scope and false
otherwise. In the latter case, the variable of the request is set
to Null.noSuchInstance and the request is marked completed.public boolean next(SubRequest request)
ManagedObjectnext in interface ManagedObjectrequest - the SubRequest to process.true if the search request found an appropriate instance,
false otherwise.public int isValueOK(SubRequest request)
MOValueValidationEvent the registered listeners.request - the SubRequest with the new value.SnmpConstants.SNMP_ERROR_SUCCESS if the new value is OK,
any other appropriate SNMPv2/v3 error status if not.public void prepare(SubRequest request)
ManagedObjectprepare in interface ManagedObjectrequest - the SubRequest to process.public void commit(SubRequest request)
ManagedObjectcommit in interface ManagedObjectrequest - the SubRequest to process.protected int changeValue(V value)
setValue(Variable value) is called.value - the new value.public void undo(SubRequest request)
ManagedObjectundo in interface ManagedObjectrequest - the SubRequest to process.public void cleanup(SubRequest request)
ManagedObjectcleanup in interface ManagedObjectrequest - the SubRequest to process.public org.snmp4j.smi.OID getOid()
public org.snmp4j.smi.OID getLowerBound()
MOScopeMOScope.isLowerIncluded().getLowerBound in interface MOScopepublic org.snmp4j.smi.OID getUpperBound()
MOScopeMOScope.isUpperIncluded().getUpperBound in interface MOScopepublic boolean isCovered(MOScope other)
MOScopepublic boolean isLowerIncluded()
MOScopeisLowerIncluded in interface MOScopetrue if the lower bound is included.public boolean isUpperIncluded()
MOScopeisUpperIncluded in interface MOScopetrue if the upper bound is included.public V getValue()
value member and
then call super.getValue() in the derived class.null Variable with the same syntax defined for
this scalar object.public boolean isVolatile()
SerializableManagedObjectisVolatile 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 int setValue(V value)
value - a Variable with the with the same syntax defined for
this scalar object (not checked).public void setVolatile(boolean isVolatile)
isVolatile - if true the state of this object will not be persistently
stored, otherwise the agent may save the state of this object
persistently.public boolean isOverlapping(MOScope other)
MOScopeisOverlapping in interface MOScopeother - a MOScope.true if there exists at least one OID that is included in
both scopes.public void addMOValueValidationListener(MOValueValidationListener l)
l - a MOValueValidationListener instance.public void removeMOValueValidationListener(MOValueValidationListener l)
l - a MOValueValidationListener instance.protected void fireValidate(MOValueValidationEvent validationEvent)
public org.snmp4j.smi.OID getID()
RegisteredManagedObjectgetID in interface RegisteredManagedObjectpublic void load(MOInput input) throws IOException
SerializableManagedObjectload in interface SerializableManagedObjectinput - a MOInput instance.IOException - if an MOInput operation fails.public void save(MOOutput output) throws IOException
SerializableManagedObjectsave in interface SerializableManagedObjectoutput - a MOOutput instance.IOException - if an MOOutput operation fails.public boolean covers(org.snmp4j.smi.OID oid)
MOScopeprotected String toStringDetails()
public void addMOChangeListener(MOChangeListener l)
MOChangeListener that needs to be informed about
state changes of this scalar.l - a MOChangeListener instance.public void removeMOChangeListener(MOChangeListener l)
MOChangeListener.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 org.snmp4j.smi.Variable getValue(org.snmp4j.smi.OID instanceOID)
ManagedObjectValueAccessManagedObject.getValue in interface ManagedObjectValueAccessinstanceOID - the instance OID of the value. Thus, for scalar values with .0 suffix
and for tabular objects with table index suffix.Variable or null if
such a variable does not exist.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 © 2020 SNMP4J.org. All rights reserved.