org.snmp4j.agent
Class DefaultMOQuery

java.lang.Object
  extended by org.snmp4j.agent.DefaultMOQuery
All Implemented Interfaces:
MOContextScope, MOQuery, MOScope
Direct Known Subclasses:
MOQueryWithSource

public class DefaultMOQuery
extends java.lang.Object
implements MOQuery

The DefaultMOQuery class is the default implementation of a managed object query. It is used to lookup managed objects, for example in a MOServer repository. The constructor with source object reference has been pushed down into the new subclass MOQueryWithSource (since version 2.0).

Version:
2.0
Author:
Frank Fock

Constructor Summary
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.
 
Method Summary
 boolean covers(org.snmp4j.smi.OID oid)
          Checks if this scope covers the supplied OID.
 org.snmp4j.smi.OctetString getContext()
          Returns the context name of this scope.
 org.snmp4j.smi.OID getLowerBound()
          Gets the lower bound OID of the scope.
 MOContextScope getScope()
          Gets the search range of this query.
 org.snmp4j.smi.OID getUpperBound()
          Gets the upper bound OID of the scope.
 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 isWriteAccessQuery()
          Indicates whether this query is issued on behalf of an intended write access on the ManagedObjects matched by this query.
 boolean matchesQuery(ManagedObject managedObject)
          Checks whether a managed object matches the internal query criteria defined by this query.
 void substractScope(MOScope scope)
          Changes the query to no longer match (cover) the specified scope.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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 on ManagedObjects or not.
Since:
1.1
Method Detail

getScope

public MOContextScope getScope()
Gets the search range of this query.

Specified by:
getScope in interface MOQuery
Returns:
a MORange instance denoting upper and lower bound of this queries scope.

matchesQuery

public boolean matchesQuery(ManagedObject managedObject)
Checks whether a managed object matches the internal query criteria defined by this query.

Specified by:
matchesQuery in interface MOQuery
Parameters:
managedObject - the ManagedObject instance to check.
Returns:
true if the managedObject matches the query.

substractScope

public void substractScope(MOScope scope)
Description copied from interface: MOQuery
Changes the query to no longer match (cover) the specified scope. If the query's scope is immutable (does not implement the MutableMOScope interface, then this method will throw an UnsupportedOperationException.

Specified by:
substractScope in interface MOQuery
Parameters:
scope - a MOScope instance that defines the range of OIDs that should be no longer in the scope of this query.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isWriteAccessQuery

public boolean isWriteAccessQuery()
Description copied from interface: MOQuery
Indicates 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:
isWriteAccessQuery in interface MOQuery
Returns:
true if this query is performed to change or create a managed object matching this query and false if the query is for read-only access on the matched managed objects.

getLowerBound

public org.snmp4j.smi.OID getLowerBound()
Description copied from interface: MOScope
Gets the lower bound OID of the scope. Whether the lower bound is included or excluded from the scope's region is determined by MOScope.isLowerIncluded().

Specified by:
getLowerBound in interface MOScope
Returns:
an OID.

getUpperBound

public org.snmp4j.smi.OID getUpperBound()
Description copied from interface: MOScope
Gets the upper bound OID of the scope. Whether the upper bound is included or excluded from the scope's region is determined by MOScope.isUpperIncluded().

Specified by:
getUpperBound in interface MOScope
Returns:
OID

isLowerIncluded

public boolean isLowerIncluded()
Description copied from interface: MOScope
Indicates whether the lower bound OID is included in the scope or not.

Specified by:
isLowerIncluded in interface MOScope
Returns:
true if the lower bound is included.

isUpperIncluded

public boolean isUpperIncluded()
Description copied from interface: MOScope
Indicates whether the upper bound OID is included in the scope or not.

Specified by:
isUpperIncluded in interface MOScope
Returns:
true if the upper bound is included.

isCovered

public boolean isCovered(MOScope other)
Description copied from interface: MOScope
Checks whether the supplied scope is covered by this scope.

Specified by:
isCovered in interface MOScope
Parameters:
other - the MOScope to check
Returns:
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.

isOverlapping

public boolean isOverlapping(MOScope other)
Description copied from interface: MOScope
Checks whether the supplied scope overlap with this one, thus sharing at least one OID with the supplied one.

Specified by:
isOverlapping in interface MOScope
Parameters:
other - a MOScope.
Returns:
true if 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: MOScope
Checks if this scope covers the supplied OID.

Specified by:
covers in interface MOScope
Parameters:
oid - an OID.
Returns:
true if oid is greater or equal the scope's lower bound and if it is less or equal its upper bound.

getContext

public org.snmp4j.smi.OctetString getContext()
Description copied from interface: MOContextScope
Returns the context name of this scope.

Specified by:
getContext in interface MOContextScope
Returns:
the context name of this scope.

Copyright 2005-2010 Frank Fock (SNMP4J.org)

Copyright © 2011 SNMP4J.org. All Rights Reserved.