Package org.zkoss.zul
Class SimpleNumberInputConstraint<T extends java.lang.Number & java.lang.Comparable<T>>
- java.lang.Object
-
- org.zkoss.zul.SimpleConstraint
-
- org.zkoss.zul.SimpleNumberInputConstraint<T>
-
- All Implemented Interfaces:
java.io.Serializable,ClientConstraint,Constraint
- Direct Known Subclasses:
SimpleDoubleSpinnerConstraint,SimpleSpinnerConstraint
public abstract class SimpleNumberInputConstraint<T extends java.lang.Number & java.lang.Comparable<T>> extends SimpleConstraint
A simple NumberInput constraint.- Since:
- 10.2.0
- Author:
- Jamson Chan
- See Also:
- Serialized Form
-
-
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
Constructors Constructor Description SimpleNumberInputConstraint()Constructs a constraint.SimpleNumberInputConstraint(int flags)Constructs a constraint.SimpleNumberInputConstraint(java.lang.String constraint)Constructs a constraint with a list of constraints separated by comma.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description TgetMax()Returns the maximum value.TgetMin()Returns the minimum value.protected org.zkoss.zk.ui.WrongValueExceptionoutOfRangeValue(org.zkoss.zk.ui.Component comp)protected intparseConstraint(java.lang.String constraint)Parses a constraint into an integer value.protected abstract TparseValue(java.lang.String value)Parse the string value to the specified number type T.voidsetMax(T max)Sets the maximum value.voidsetMin(T min)Sets the minimum value.voidvalidate(org.zkoss.zk.ui.Component comp, java.lang.Object value)Verifies whether the value is acceptable.-
Methods inherited from class org.zkoss.zul.SimpleConstraint
getClientConstraint, getClientPackages, getErrorMessage, getFlags, getInstance, getRawValue
-
-
-
-
Constructor Detail
-
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
public SimpleNumberInputConstraint(java.lang.String constraint)
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 Detail
-
getMin
public T getMin()
Returns the minimum value.
-
setMin
public void setMin(T min)
Sets the minimum value.
-
getMax
public T getMax()
Returns the maximum value.
-
setMax
public void setMax(T max)
Sets the maximum value.
-
parseValue
protected abstract T parseValue(java.lang.String value)
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
protected int parseConstraint(java.lang.String constraint) throws org.zkoss.zk.ui.UiExceptionDescription 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, java.lang.Object value) throws org.zkoss.zk.ui.WrongValueExceptionDescription 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)
-
-