FileDocCategorySizeDatePackage
IntConstraint.javaAPI DocExample2138Sun Dec 14 22:47:38 GMT 2003oreilly.hcj.datamodeling.constraints

IntConstraint

public class IntConstraint extends Constraint
A constraint for properties of type int.
author
Robert Simmons jr.
version
$Revision: 1.1 $

Fields Summary
private int
maxValue
The maximum legal value.
private int
minValue
The minimum legal value.
Constructors Summary
public IntConstraint(String name, int minValue, int maxValue)
Creates a new IntConstraint object.

param
name Contains the name of the constraint
param
minValue The minimum legal value.
param
maxValue The maximum legal value.
see
mirror.datamodel.constraints.Constraint

		super(name);
		this.minValue = minValue;
		this.maxValue = maxValue;
	
Methods Summary
public intgetMaxValue()
Get the maximum legal value for the property beign constrained.

return
The maximum legal value.

		return this.maxValue;
	
public intgetMinValue()
Get the minimum legal value for the property beign constrained.

return
The minimum legal value.

		return this.minValue;
	
public voidvalidate(int value)
Validate the given object against the constraint.

param
value The value to validate.
throws
ConstraintException If the constraint is violated.

		if (minValue > value) {
			throw new ConstraintException(ConstraintExceptionType.VALUE_BELOW_MINIMUM);
		}
		if (maxValue < value) {
			throw new ConstraintException(ConstraintExceptionType.VALUE_ABOVE_MAXIMUM);
		}