Class DefaultMOContextScope

java.lang.Object
org.snmp4j.agent.DefaultMOScope
org.snmp4j.agent.DefaultMOContextScope
All Implemented Interfaces:
MOContextScope, MOScope, MutableMOScope

public class DefaultMOContextScope extends DefaultMOScope implements MOContextScope
The DefaultMOContextScope is the default implementation of a MOContextScope representing an OID scope that distinguishes between different contexts.
Version:
1.1
Author:
Frank Fock
  • Constructor Details

    • DefaultMOContextScope

      public DefaultMOContextScope(org.snmp4j.smi.OctetString context, org.snmp4j.smi.OID lowerBound, boolean lowerIncluded, org.snmp4j.smi.OID upperBound, boolean upperIncluded)
      Creates a context scope from a context, upper, and lower bound OID.
      Parameters:
      context - the context for which this scope is valid.
      lowerBound - the lower bound of the OID scope (must not be null).
      lowerIncluded - specifies whether the lower bound is included or not.
      upperBound - the upper bound of the OID scope (null for no upper limit).
      upperIncluded - specifies whether the upper bound is included or not.
    • DefaultMOContextScope

      public DefaultMOContextScope(MOContextScope scope)
      Creates a context scope from another context scope.
      Parameters:
      scope - a MOContextScope instance whose context and bounds are copied by reference.
    • DefaultMOContextScope

      public DefaultMOContextScope(org.snmp4j.smi.OctetString context, MOScope extendedScope)
      Creates a context scope from a plain OID scope.
      Parameters:
      context - the context name for the new context scope.
      extendedScope - the OID scope that defines the OID range of the new scope (boundaries are copied by reference).
  • Method Details

    • getContext

      public org.snmp4j.smi.OctetString getContext()
      Gets the context of the scope.
      Specified by:
      getContext in interface MOContextScope
      Returns:
      the context name this scope applies to.
    • setContext

      public void setContext(org.snmp4j.smi.OctetString context)
      Sets the context name for this scope.
      Parameters:
      context - a context name.
    • equals

      public boolean equals(Object obj)
      Indicates whether an object is equal to this one.
      Overrides:
      equals in class DefaultMOScope
      Parameters:
      obj - some object.
      Returns:
      true only if obj is a MOContextScope and if context and scope equals this one's.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class DefaultMOScope
    • isContextMatching

      public static boolean isContextMatching(MOScope a, MOScope b)
      Indicates whether the given scopes have a matching context. The context does not match if both are MOContextScope instances and both contexts are not null and different.
      Parameters:
      a - a MOScope instance.
      b - another MOScope instance.
      Returns:
      true if both scopes have matching contexts (or at least one has no context defined).
      Since:
      1.1
    • 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
      Overrides:
      isCovered in class DefaultMOScope
      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.
    • toString

      public String toString()
      Overrides:
      toString in class DefaultMOScope
    • 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
      Overrides:
      isOverlapping in class DefaultMOScope
      Parameters:
      other - a MOScope.
      Returns:
      true if there exists at least one OID that is included in both scopes.