Package org.snmp4j.agent.mo.snmp.smi
Class ConstraintsImpl
java.lang.Object
org.snmp4j.agent.mo.snmp.smi.ConstraintsImpl
- All Implemented Interfaces:
Constraints
,ValueConstraint
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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(Constraint sizeConstraint) Adds a range constraint to the constraints collection.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.
-
Constructor Details
-
ConstraintsImpl
public ConstraintsImpl()Creates a new constraints collection.
-
-
Method Details
-
add
Description copied from interface:Constraints
Adds a range constraint to the constraints collection.- Specified by:
add
in interfaceConstraints
- Parameters:
sizeConstraint
- a SNMP integer/long value range constraint.
-
remove
Description copied from interface:Constraints
Removes a constraint.- Specified by:
remove
in interfaceConstraints
- Parameters:
sizeContraint
- a SNMP integer/long value range constraint.
-
getConstraints
Description copied from interface:Constraints
Gets an array with the constraints in this collection ordered by insertion time.- Specified by:
getConstraints
in interfaceConstraints
- 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 interfaceConstraints
- 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 interfaceValueConstraint
- Parameters:
variable
- a SNMP value that has to match the type of SNMP value thisValueConstraint
supports. Otherwise a wrongType error should be returned instead of throwing aClassCastException
.- Returns:
- a SNMP error status (e.g. wrongValue) if the value does not match the constraint, or zero if it matches.
-