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:
  • Constructor Details

    • SimpleNumberInputConstraint

      public SimpleNumberInputConstraint()
      Constructs a constraint.
    • SimpleNumberInputConstraint

      public SimpleNumberInputConstraint(int flags)
      Constructs a constraint.
      Parameters:
      flags - a combination of SimpleConstraint.NO_POSITIVE, SimpleConstraint.NO_NEGATIVE, SimpleConstraint.NO_ZERO, and so on.
    • SimpleNumberInputConstraint

      public SimpleNumberInputConstraint(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 Details

    • 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(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(String constraint) throws org.zkoss.zk.ui.UiException
      Description copied from class: SimpleConstraint
      Parses a constraint into an integer value. For example, "no positive" is parsed to SimpleConstraint.NO_POSITIVE.

      Deriving classes might override this to provide more constraints.

      Overrides:
      parseConstraint in class SimpleConstraint
      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: Constraint
      Verifies whether the value is acceptable.
      Specified by:
      validate in interface Constraint
      Overrides:
      validate in class SimpleConstraint
      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)