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 TypeMethodDescriptionvoidadd(Constraint sizeConstraint) Adds a range constraint to the constraints collection.Gets an array with the constraints in this collection ordered by insertion time.booleanisValidSize(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.voidremove(Constraint sizeContraint) Removes a constraint.intvalidate(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:ConstraintsAdds a range constraint to the constraints collection.- Specified by:
addin interfaceConstraints- Parameters:
sizeConstraint- a SNMP integer/long value range constraint.
-
remove
Description copied from interface:ConstraintsRemoves a constraint.- Specified by:
removein interfaceConstraints- Parameters:
sizeContraint- a SNMP integer/long value range constraint.
-
getConstraints
Description copied from interface:ConstraintsGets an array with the constraints in this collection ordered by insertion time.- Specified by:
getConstraintsin interfaceConstraints- Returns:
- an array of
Constraintinstances.
-
isValidSize
public boolean isValidSize(long size) Description copied from interface:ConstraintsInterpretes 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:
isValidSizein interfaceConstraints- Parameters:
size- a long value representing an OCTET STRING size.- Returns:
trueif the size is valid.
-
validate
public int validate(org.snmp4j.smi.Variable variable) Description copied from interface:ValueConstraintIndicates whether a SNMP value matches this value constraint.- Specified by:
validatein interfaceValueConstraint- Parameters:
variable- a SNMP value that has to match the type of SNMP value thisValueConstraintsupports. 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.
-