org.snmp4j.agent
Class DefaultMOQuery

java.lang.Object
  extended by org.snmp4j.agent.DefaultMOQuery
All Implemented Interfaces:
MOQuery

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.

Version:
1.1
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.
DefaultMOQuery(MOContextScope scope, boolean isWriteAccessIntended, java.lang.Object source)
          Creates a context aware query from a context aware OID scope.
 
Method Summary
 MOContextScope getScope()
          Gets the search range of this query.
 java.lang.Object getSource()
          Gets the source (Request) object on whose behalf this query is executed.
static boolean isSameSource(MOQuery query, java.lang.Object source)
          This method checks whether the supplied query and the given source reference refer to the same source (request).
 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

DefaultMOQuery

public DefaultMOQuery(MOContextScope scope,
                      boolean isWriteAccessIntended,
                      java.lang.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 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.

getSource

public java.lang.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 update ManagedObject content 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 Request instance, but code should not rely on that. If null is returned, the query source cannot be determined.
Since:
1.1

isSameSource

public static boolean isSameSource(MOQuery query,
                                   java.lang.Object source)
This method checks whether the supplied query and the given source reference refer to the same source (request).

Parameters:
query - a MOQuery instance.
source - any source object reference.
Returns:
true only if query is a DefaultMOQuery instance and getSource() == source and source is not null.
Since:
1.1

Copyright 2005-2008 Frank Fock (SNMP4J.org)