Package org.zkoss.zul
Class AbstractSimpleDateTimeConstraint<T extends java.lang.Comparable<? super T>>
- java.lang.Object
-
- org.zkoss.zul.SimpleConstraint
-
- org.zkoss.zul.AbstractSimpleDateTimeConstraint<T>
-
- All Implemented Interfaces:
java.io.Serializable
,ClientConstraint
,Constraint
- Direct Known Subclasses:
SimpleDateConstraint
,SimpleLocalDateConstraint
,SimpleLocalTimeConstraint
public abstract class AbstractSimpleDateTimeConstraint<T extends java.lang.Comparable<? super T>> extends SimpleConstraint
A skeleton of simple date/time constraint.- Since:
- 9.0.0
- Author:
- rudyhuang
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected T
_beg
protected T
_end
protected java.util.TimeZone
_tzone
-
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 AbstractSimpleDateTimeConstraint(int flags)
Constraints a constraint.AbstractSimpleDateTimeConstraint(int flags, java.lang.String errmsg)
Constraints a constraint.AbstractSimpleDateTimeConstraint(int flags, java.util.regex.Pattern regex, java.lang.String errmsg)
Constructs a constraint combining regular expression.AbstractSimpleDateTimeConstraint(java.lang.String constraint)
Constructs a constraint with a list of constraints separated by comma.AbstractSimpleDateTimeConstraint(java.util.regex.Pattern regex, java.lang.String errmsg)
Constructs a regular-expression constraint.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
fixConstraint()
T
getBeginDate()
Returns the beginning date, or null if there is no constraint of the beginning date.T
getEndDate()
Returns the ending date, or null if there is no constraint of the ending date.protected int
parseConstraint(java.lang.String constraint)
Parses a constraint into an integer value.protected abstract T
parseFrom(java.lang.String val)
void
setTimeZone(java.util.TimeZone tzone)
Sets time zone that this date constraint belongs tovoid
validate(Component comp, java.lang.Object value)
Verifies whether the value is acceptable.protected void
validate0(Component comp, T value)
protected abstract java.lang.String
valueToString(Component comp, T value)
-
Methods inherited from class org.zkoss.zul.SimpleConstraint
getClientConstraint, getClientPackages, getErrorMessage, getFlags, getInstance, getRawValue
-
-
-
-
Constructor Detail
-
AbstractSimpleDateTimeConstraint
public AbstractSimpleDateTimeConstraint(int flags)
Constraints a constraint.- Parameters:
flags
- a combination ofSimpleConstraint.NO_POSITIVE
,SimpleConstraint.NO_NEGATIVE
,SimpleConstraint.NO_ZERO
, and so on.
-
AbstractSimpleDateTimeConstraint
public AbstractSimpleDateTimeConstraint(int flags, java.lang.String errmsg)
Constraints a constraint.- Parameters:
flags
- a combination ofSimpleConstraint.NO_POSITIVE
,SimpleConstraint.NO_NEGATIVE
,SimpleConstraint.NO_ZERO
, and so on.errmsg
- the error message to display. Ignored if null or empty.
-
AbstractSimpleDateTimeConstraint
public AbstractSimpleDateTimeConstraint(java.util.regex.Pattern regex, java.lang.String errmsg)
Constructs a regular-expression constraint.- Parameters:
regex
- ignored if null or emptyerrmsg
- the error message to display. Ignored if null or empty.
-
AbstractSimpleDateTimeConstraint
public AbstractSimpleDateTimeConstraint(int flags, java.util.regex.Pattern regex, java.lang.String errmsg)
Constructs a constraint combining regular expression.- Parameters:
flags
- a combination ofSimpleConstraint.NO_POSITIVE
,SimpleConstraint.NO_NEGATIVE
,SimpleConstraint.NO_ZERO
, and so on.regex
- ignored if null or emptyerrmsg
- the error message to display. Ignored if null or empty.
-
AbstractSimpleDateTimeConstraint
public AbstractSimpleDateTimeConstraint(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: "between 20071012 and 20071223", "before 20080103"
-
-
Method Detail
-
fixConstraint
protected abstract void fixConstraint()
-
getBeginDate
public T getBeginDate()
Returns the beginning date, or null if there is no constraint of the beginning date.
-
getEndDate
public T getEndDate()
Returns the ending date, or null if there is no constraint of the ending date.
-
setTimeZone
public void setTimeZone(java.util.TimeZone tzone)
Sets time zone that this date constraint belongs to
-
parseConstraint
protected int parseConstraint(java.lang.String constraint) throws UiException
Description copied from class:SimpleConstraint
Parses 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:
parseConstraint
in classSimpleConstraint
- Throws:
UiException
-
parseFrom
protected abstract T parseFrom(java.lang.String val) throws UiException
- Throws:
UiException
-
validate
public void validate(Component comp, java.lang.Object value) throws WrongValueException
Description copied from interface:Constraint
Verifies whether the value is acceptable.- Specified by:
validate
in interfaceConstraint
- Overrides:
validate
in classSimpleConstraint
- Parameters:
comp
- the component being validated- Throws:
WrongValueException
-
validate0
protected void validate0(Component comp, T value) throws WrongValueException
- Throws:
WrongValueException
-
-