Class ConstraintsImpl

  • All Implemented Interfaces:
    Constraints, ValueConstraint

    public class ConstraintsImpl
    extends java.lang.Object
    implements Constraints
    The ConstraintsImpl class represents a collection of constraints that are applied to a SNMP value in the order they have been added to this constraints collection.
    Version:
    1.0
    Author:
    Frank Fock
    • Constructor Summary

      Constructors 
      Constructor Description
      ConstraintsImpl()
      Creates a new constraints collection.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(Constraint sizeConstraint)
      Adds a range constraint to the constraints collection.
      Constraint[] getConstraints()
      Gets an array with the constraints in this collection ordered by insertion time.
      boolean isValidSize​(long size)
      Interpretes the value range constraints contained in this collection as size restrictions for OCTET STRING values and checks whether the given size matches these criteria.
      void remove​(Constraint sizeContraint)
      Removes a constraint.
      int validate​(org.snmp4j.smi.Variable variable)
      Indicates whether a SNMP value matches this value constraint.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ConstraintsImpl

        public ConstraintsImpl()
        Creates a new constraints collection.
    • Method Detail

      • add

        public void add​(Constraint sizeConstraint)
        Description copied from interface: Constraints
        Adds a range constraint to the constraints collection.
        Specified by:
        add in interface Constraints
        Parameters:
        sizeConstraint - a SNMP integer/long value range constraint.
      • remove

        public void remove​(Constraint sizeContraint)
        Description copied from interface: Constraints
        Removes a constraint.
        Specified by:
        remove in interface Constraints
        Parameters:
        sizeContraint - a SNMP integer/long value range constraint.
      • getConstraints

        public Constraint[] getConstraints()
        Description copied from interface: Constraints
        Gets an array with the constraints in this collection ordered by insertion time.
        Specified by:
        getConstraints in interface Constraints
        Returns:
        an array of Constraint instances.
      • isValidSize

        public boolean isValidSize​(long size)
        Description copied from interface: Constraints
        Interpretes the value range constraints contained in this collection as size restrictions for OCTET STRING values and checks whether the given size matches these criteria.
        Specified by:
        isValidSize in interface Constraints
        Parameters:
        size - a long value representing an OCTET STRING size.
        Returns:
        true if the size is valid.
      • validate

        public int validate​(org.snmp4j.smi.Variable variable)
        Description copied from interface: ValueConstraint
        Indicates whether a SNMP value matches this value constraint.
        Specified by:
        validate in interface ValueConstraint
        Parameters:
        variable - a SNMP value that has to match the type of SNMP value this ValueConstraint supports. Otherwise a wrongType error should be returned instead of throwing a ClassCastException.
        Returns:
        a SNMP error status (e.g. wrongValue) if the value does not match the constraint, or zero if it matches.