Package org.zkoss.zul
Class SimpleNumberInputConstraint<T extends Number & Comparable<T>>
java.lang.Object
org.zkoss.zul.SimpleConstraint
org.zkoss.zul.SimpleNumberInputConstraint<T>
- All Implemented Interfaces:
Serializable,ClientConstraint,Constraint
- Direct Known Subclasses:
SimpleDoubleSpinnerConstraint,SimpleSpinnerConstraint
public abstract class SimpleNumberInputConstraint<T extends Number & Comparable<T>>
extends SimpleConstraint
A simple NumberInput constraint.
- Since:
- 10.2.0
- Author:
- Jamson Chan
- See Also:
-
Field Summary
Fields inherited from class org.zkoss.zul.SimpleConstraint
_finishParseCst, _flags, AFTER_END, AFTER_POINTER, AFTER_START, AT_POINTER, BEFORE_END, BEFORE_START, END_AFTER, END_BEFORE, NO_EMPTY, NO_FUTURE, NO_NEGATIVE, NO_PAST, NO_POSITIVE, NO_TODAY, NO_ZERO, OVERLAP, OVERLAP_AFTER, OVERLAP_BEFORE, OVERLAP_END, SERVER, START_AFTER, START_BEFORE, STRICT -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a constraint.SimpleNumberInputConstraint(int flags) Constructs a constraint.SimpleNumberInputConstraint(String constraint) Constructs a constraint with a list of constraints separated by comma. -
Method Summary
Modifier and TypeMethodDescriptiongetMax()Returns the maximum value.getMin()Returns the minimum value.protected org.zkoss.zk.ui.WrongValueExceptionoutOfRangeValue(org.zkoss.zk.ui.Component comp) protected intparseConstraint(String constraint) Parses a constraint into an integer value.protected abstract TparseValue(String value) Parse the string value to the specified number type T.voidSets the maximum value.voidSets the minimum value.voidVerifies whether the value is acceptable.Methods inherited from class org.zkoss.zul.SimpleConstraint
getClientConstraint, getClientPackages, getErrorMessage, getFlags, getInstance, getRawValue
-
Constructor Details
-
SimpleNumberInputConstraint
public SimpleNumberInputConstraint()Constructs a constraint. -
SimpleNumberInputConstraint
public SimpleNumberInputConstraint(int flags) Constructs a constraint.- Parameters:
flags- a combination ofSimpleConstraint.NO_POSITIVE,SimpleConstraint.NO_NEGATIVE,SimpleConstraint.NO_ZERO, and so on.
-
SimpleNumberInputConstraint
Constructs a constraint with a list of constraints separated by comma.- Parameters:
constraint- a list of constraints separated by comma. Example: no positive, no zero
-
-
Method Details
-
getMin
Returns the minimum value. -
setMin
Sets the minimum value. -
getMax
Returns the maximum value. -
setMax
Sets the maximum value. -
parseValue
Parse the string value to the specified number type T. This method should be implemented by subclasses to convert a string representation of a number to the appropriate numeric type for this constraint.- Parameters:
value- the string representation of a number- Returns:
- the parsed number of type T
-
parseConstraint
Description copied from class:SimpleConstraintParses a constraint into an integer value. For example, "no positive" is parsed toSimpleConstraint.NO_POSITIVE.Deriving classes might override this to provide more constraints.
- Overrides:
parseConstraintin classSimpleConstraint- Throws:
org.zkoss.zk.ui.UiException
-
validate
public void validate(org.zkoss.zk.ui.Component comp, Object value) throws org.zkoss.zk.ui.WrongValueException Description copied from interface:ConstraintVerifies whether the value is acceptable.- Specified by:
validatein interfaceConstraint- Overrides:
validatein classSimpleConstraint- Parameters:
comp- the component being validated- Throws:
org.zkoss.zk.ui.WrongValueException
-
outOfRangeValue
protected org.zkoss.zk.ui.WrongValueException outOfRangeValue(org.zkoss.zk.ui.Component comp)
-