- java.lang.Object
-
- org.snmp4j.agent.DefaultMOQuery
-
- All Implemented Interfaces:
MOContextScope,MOQuery,MOScope
- Direct Known Subclasses:
MOQueryWithSource
public class DefaultMOQuery extends Object implements MOQuery
TheDefaultMOQueryclass is the default implementation of a managed object query. It is used to lookup managed objects, for example in aMOServerrepository. The constructor with source object reference has been pushed down into the new subclassMOQueryWithSource(since version 2.0).- Version:
- 2.0
- Author:
- Frank Fock
-
-
Constructor Summary
Constructors Constructor Description DefaultMOQuery(MOContextScope scope)Creates a context aware query from a context aware OID scope.DefaultMOQuery(MOContextScope scope, boolean isWriteAccessIntended)Creates a context aware query from a context aware OID scope.DefaultMOQuery(MOContextScope scope, boolean isWriteAccessIntended, Object source)Creates a context aware query from a context aware OID scope.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancovers(org.snmp4j.smi.OID oid)Checks if this scope covers the supplied OID.org.snmp4j.smi.OctetStringgetContext()Returns the context name of this scope.org.snmp4j.smi.OIDgetLowerBound()Gets the lower bound OID of the scope.MOContextScopegetScope()Gets the search range of this query.ObjectgetSource()Gets the source (Request) object on whose behalf this query is executed.org.snmp4j.smi.OIDgetUpperBound()Gets the upper bound OID of the scope.booleanisCovered(MOScope other)Checks whether the supplied scope is covered by this scope.booleanisLowerIncluded()Indicates whether the lower bound OID is included in the scope or not.booleanisOverlapping(MOScope other)Checks whether the supplied scope overlap with this one, thus sharing at least one OID with the supplied one.booleanisUpperIncluded()Indicates whether the upper bound OID is included in the scope or not.booleanisWriteAccessQuery()Indicates whether this query is issued on behalf of an intended write access on the ManagedObjects matched by this query.booleanmatchesQuery(ManagedObject<?> managedObject)Checks whether a managed object matches the internal query criteria defined by this query.voidsubstractScope(MOScope scope)Changes the query to no longer match (cover) the specified scope.StringtoString()
-
-
-
Constructor Detail
-
DefaultMOQuery
public DefaultMOQuery(MOContextScope scope)
Creates a context aware query from a context aware OID scope.- Parameters:
scope- a scope that defines the possible result set of OIDs from a specific context for this query.
-
DefaultMOQuery
public DefaultMOQuery(MOContextScope scope, boolean isWriteAccessIntended)
Creates a context aware query from a context aware OID scope.- Parameters:
scope- a scope that defines the possible result set of OIDs from a specific context for this query.isWriteAccessIntended- indicates whether this query serves a write access onManagedObjects or not.- Since:
- 1.1
-
DefaultMOQuery
public DefaultMOQuery(MOContextScope scope, boolean isWriteAccessIntended, Object source)
Creates a context aware query from a context aware OID scope.- Parameters:
scope- a scope that defines the possible result set of OIDs from a specific context for this query.isWriteAccessIntended- indicates whether this query serves a write access onManagedObjects or not.source- the request object that triggered the creation of this query. SeegetSource().- Since:
- 1.1
-
-
Method Detail
-
getScope
public MOContextScope getScope()
Gets the search range of this query.
-
getSource
public Object getSource()
Gets the source (Request) object on whose behalf this query is executed. This object reference can be used to determine whether a query needs to updateManagedObjectcontent or not. When the reference is the same as those from the last query then an update is not necessary.- Returns:
- an Object on whose behalf this query is executed which will be in most
cases a
Requestinstance, but code should not rely on that. Ifnullis returned, the query source cannot be determined. - Since:
- 1.1
-
matchesQuery
public boolean matchesQuery(ManagedObject<?> managedObject)
Checks whether a managed object matches the internal query criteria defined by this query.- Specified by:
matchesQueryin interfaceMOQuery- Parameters:
managedObject- theManagedObjectinstance to check.- Returns:
trueif themanagedObjectmatches the query.
-
substractScope
public void substractScope(MOScope scope)
Description copied from interface:MOQueryChanges the query to no longer match (cover) the specified scope. If the query's scope is immutable (does not implement theMutableMOScopeinterface, then this method will throw anUnsupportedOperationException.- Specified by:
substractScopein interfaceMOQuery- Parameters:
scope- aMOScopeinstance that defines the range of OIDs that should be no longer in the scope of this query.
-
isWriteAccessQuery
public boolean isWriteAccessQuery()
Description copied from interface:MOQueryIndicates whether this query is issued on behalf of an intended write access on the ManagedObjects matched by this query. This information can be used to optimize query evaluation or to control resource allocation.- Specified by:
isWriteAccessQueryin interfaceMOQuery- Returns:
trueif this query is performed to change or create a managed object matching this query andfalseif the query is for read-only access on the matched managed objects.
-
getLowerBound
public org.snmp4j.smi.OID getLowerBound()
Description copied from interface:MOScopeGets the lower bound OID of the scope. Whether the lower bound is included or excluded from the scope's region is determined byMOScope.isLowerIncluded().- Specified by:
getLowerBoundin interfaceMOScope- Returns:
- an OID.
-
getUpperBound
public org.snmp4j.smi.OID getUpperBound()
Description copied from interface:MOScopeGets the upper bound OID of the scope. Whether the upper bound is included or excluded from the scope's region is determined byMOScope.isUpperIncluded().- Specified by:
getUpperBoundin interfaceMOScope- Returns:
- OID
-
isLowerIncluded
public boolean isLowerIncluded()
Description copied from interface:MOScopeIndicates whether the lower bound OID is included in the scope or not.- Specified by:
isLowerIncludedin interfaceMOScope- Returns:
trueif the lower bound is included.
-
isUpperIncluded
public boolean isUpperIncluded()
Description copied from interface:MOScopeIndicates whether the upper bound OID is included in the scope or not.- Specified by:
isUpperIncludedin interfaceMOScope- Returns:
trueif the upper bound is included.
-
isCovered
public boolean isCovered(MOScope other)
Description copied from interface:MOScopeChecks whether the supplied scope is covered by this scope.
-
isOverlapping
public boolean isOverlapping(MOScope other)
Description copied from interface:MOScopeChecks whether the supplied scope overlap with this one, thus sharing at least one OID with the supplied one.- Specified by:
isOverlappingin interfaceMOScope- Parameters:
other- aMOScope.- Returns:
trueif there exists at least one OID that is included in both scopes.
-
covers
public boolean covers(org.snmp4j.smi.OID oid)
Description copied from interface:MOScopeChecks if this scope covers the supplied OID.
-
getContext
public org.snmp4j.smi.OctetString getContext()
Description copied from interface:MOContextScopeReturns the context name of this scope.- Specified by:
getContextin interfaceMOContextScope- Returns:
- the context name of this scope.
-
-