|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
javax.faces.validator Class DoubleRangeValidator
java.lang.Objectjavax.faces.validator.DoubleRangeValidator
- All Implemented Interfaces:
- EventListener, StateHolder, Validator
public class DoubleRangeValidator
- extends Object
- implements Validator, StateHolder
DoubleRangeValidator 是一个 Validator,它根据指定的最小值和最大值检查相应组件的值。实现以下算法:
- 如果传递的值为
null,则立即退出。 - 如果当前组件值不是浮点类型,或者是可以转换成 double 的 String,则抛出包含 TYPE_MESSAGE_ID 消息的
ValidatorException。 - 如果对此
Validator配置了maximum和minimum属性,则根据这两个限制检查组件值。如果组件值不在此指定范围内,则抛出包含#NOT_IN_RANGE_MESSAGE_ID消息的ValidatorException。 - 如果对此
Validator配置了maximum属性,则根据此限制检查组件值。如果组件值大于指定的最大值,则抛出包含 MAXIMUM_MESSAGE_ID 消息的ValidatorException。 - 如果对此
Validator配置了minimum属性,则根据此限制检查组件值。如果组件值小于指定的最小值,则抛出包含 MINIMUM_MESSAGE_ID 消息的ValidatorException。
对于所有导致抛出 ValidatorException 的上述原因,如果有些消息的参数匹配验证器参数,则这些参数的值必须使用转换器 ID javax.faces.Number 在应用程序中注册的 Converter 转换。这使值可以根据当前的 Locale 进行本地化。
DoubleRangeValidator is a Validator that checks
the value of the corresponding component against specified minimum and
maximum values. The following algorithm is implemented:
- If the passed value is
null, exit immediately. - If the current component value is not a floating point type, or
a String that is convertible to double, throw a
ValidatorExceptioncontaining a TYPE_MESSAGE_ID message. - If both a
maximumandminimumproperty has been configured on thisValidator, check the component value against both limits. If the component value is not within this specified range, throw aValidatorExceptioncontaining aNOT_IN_RANGE_MESSAGE_IDmessage. - If a
maximumproperty has been configured on thisValidator, check the component value against this limit. If the component value is greater than the specified maximum, throw aValidatorExceptioncontaining a MAXIMUM_MESSAGE_ID message. - If a
minimumproperty has been configured on thisValidator, check the component value against this limit. If the component value is less than the specified minimum, throw aValidatorExceptioncontaining a MINIMUM_MESSAGE_ID message.
For all of the above cases that cause a ValidatorException
to be thrown, if there are parameters to the message that match up
with validator parameters, the values of these parameters must be
converted using the Converter registered in the application
under the converter id javax.faces.Number. This allows
the values to be localized according to the current
Locale.
| Field Summary | |
|---|---|
static String |
MAXIMUM_MESSAGE_ID
The message identifier of the FacesMessage
to be created if the maximum value check fails. |
static String |
MINIMUM_MESSAGE_ID
The message identifier of the FacesMessage
to be created if the minimum value check fails. |
static String |
NOT_IN_RANGE_MESSAGE_ID
The message identifier of the FacesMessage to be created if
the maximum or minimum value check fails, and both the maximum
and minimum values for this validator have been set. |
static String |
TYPE_MESSAGE_ID
The message identifier of the FacesMessage
to be created if the current value of this component is not of the
correct type. |
static String |
VALIDATOR_ID
The standard converter id for this converter. |
| Constructor Summary | |
|---|---|
DoubleRangeValidator()
Construct a Validator with no preconfigured limits. |
|
DoubleRangeValidator(double maximum)
Construct a Validator with the specified preconfigured
limit. |
|
DoubleRangeValidator(double maximum,
double minimum)
Construct a Validator with the specified preconfigured
limits. |
|
| Method Summary | |
|---|---|
boolean |
equals(Object otherObj)
|
double |
getMaximum()
Return the maximum value to be enforced by this Validator or Double.MAX_VALUE if it has not been
set. |
double |
getMinimum()
Return the minimum value to be enforced by this Validator, or Double.MIN_VALUE if it has not been
set. |
int |
hashCode()
|
boolean |
isTransient()
If true, the Object implementing this interface must not participate in state saving or restoring. |
void |
restoreState(FacesContext context,
Object state)
Perform any processing required to restore the state from the entries in the state Object. |
Object |
saveState(FacesContext context)
Gets the state of the instance as a Serializable Object. |
void |
setMaximum(double maximum)
Set the maximum value to be enforced by this Validator. |
void |
setMinimum(double minimum)
Set the minimum value to be enforced by this Validator. |
void |
setTransient(boolean transientValue)
Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring. |
void |
validate(FacesContext context,
UIComponent component,
Object value)
Perform the correctness checks implemented by this Validator against the specified UIComponent. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
英文文档:
VALIDATOR_ID
public static final String VALIDATOR_ID
The standard converter id for this converter.
- See Also:
- Constant Field Values
英文文档:
MAXIMUM_MESSAGE_ID
public static final String MAXIMUM_MESSAGE_ID
The message identifier of the
FacesMessageto be created if the maximum value check fails. The message format string for this message may optionally include the following placeholders:{0}replaced by the configured maximum value.{1}replaced by aStringwhose value is the label of the input component that produced this message.
- See Also:
- Constant Field Values
英文文档:
MINIMUM_MESSAGE_ID
public static final String MINIMUM_MESSAGE_ID
The message identifier of the
FacesMessageto be created if the minimum value check fails. The message format string for this message may optionally include the following placeholders:{0}replaced by the configured minimum value.{1}replaced by aStringwhose value is the label of the input component that produced this message.
- See Also:
- Constant Field Values
英文文档:
NOT_IN_RANGE_MESSAGE_ID
public static final String NOT_IN_RANGE_MESSAGE_ID
The message identifier of the
FacesMessageto be created if the maximum or minimum value check fails, and both the maximum and minimum values for this validator have been set. The message format string for this message may optionally include the following placeholders:{0}replaced by the configured minimum value.{1}replaced by the configured maximum value.{2}replaced by aStringwhose value is the label of the input component that produced this message.
- See Also:
- Constant Field Values
英文文档:
TYPE_MESSAGE_ID
public static final String TYPE_MESSAGE_ID
The message identifier of the
FacesMessageto be created if the current value of this component is not of the correct type. The message format string for this message may optionally include a{0}placeholder that will be replaced by aStringwhose value is the label of the input component that produced this message.- See Also:
- Constant Field Values
| Constructor Detail |
|---|
public
DoubleRangeValidator()
构造没有预配置限制的 Validator。
DoubleRangeValidator
public DoubleRangeValidator()
Construct a
Validatorwith no preconfigured limits.
public
DoubleRangeValidator(double maximum)
构造具有指定预配置限制的 Validator。
| maximum | 允许的最大值 |
DoubleRangeValidator
public DoubleRangeValidator(double maximum)
Construct a
Validatorwith the specified preconfigured limit.- Parameters:
maximum- Maximum value to allow
public
DoubleRangeValidator(double maximum, double minimum)
构造具有指定预配置限制的 Validator。
| maximum | 允许的最大值 |
| minimum | 允许的最小值 |
DoubleRangeValidator
public DoubleRangeValidator(double maximum,
double minimum)
Construct a
Validatorwith the specified preconfigured limits.- Parameters:
maximum- Maximum value to allowminimum- Minimum value to allow
| Method Detail |
|---|
public double
getMaximum()
返回此 Validator 强制执行的最大值;如果没有设置,则返回 Double.MAX_VALUE。
getMaximum
public double getMaximum()
Return the maximum value to be enforced by this
ValidatororDouble.MAX_VALUEif it has not been set.
public void
setMaximum(double maximum)
设置此 Validator 强制执行的最大值。
| maximum | 新的最大值 |
setMaximum
public void setMaximum(double maximum)
Set the maximum value to be enforced by this
Validator.- Parameters:
maximum- The new maximum value
public double
getMinimum()
返回此 Validator 强制执行的最小值;如果没有设置,则返回 Double.MIN_VALUE。
getMinimum
public double getMinimum()
Return the minimum value to be enforced by this
Validator, orDouble.MIN_VALUEif it has not been set.
public void
setMinimum(double minimum)
设置此 Validator 强制执行的最小值。
| minimum | 新的最小值 |
setMinimum
public void setMinimum(double minimum)
Set the minimum value to be enforced by this
Validator.- Parameters:
minimum- The new minimum value
public void
validate(FacesContext context, UIComponent component, Object value) throws ValidatorException
| Throws | NullPointerException:
NullPointerException
如果 context 或 component 为 null |
| Throws | ValidatorException: NullPointerException 如果验证失败 |
validate
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException
- Description copied from interface:
Validator Perform the correctness checks implemented by this
Validatoragainst the specifiedUIComponent. If any violations are found, aValidatorExceptionwill be thrown containing theFacesMessagedescribing the failure.- Parameters:
context- FacesContext for the request we are processingcomponent- UIComponent we are checking for correctnessvalue- the value to validate- Throws:
NullPointerException- ifcontextorcomponentisnullValidatorException- if validation fails
public boolean
equals(Object otherObj)
英文文档:
equals
public boolean equals(Object otherObj)
public int
hashCode()
英文文档:
hashCode
public int hashCode()
public Object
saveState(FacesContext context)
英文文档:
saveState
public Object saveState(FacesContext context)
- Description copied from interface:
StateHolder Gets the state of the instance as a
SerializableObject.If the class that implements this interface has references to instances that implement StateHolder (such as a
UIComponentwith event handlers, validators, etc.) this method must call theStateHolder.saveState(javax.faces.context.FacesContext)method on all those instances as well. This method must not save the state of children and facets. That is done via theStateManagerThis method must not alter the state of the implementing object. In other words, after executing this code:
Object state = component.saveState(facesContext);
componentshould be the same as before executing it.The return from this method must be
Serializable- Specified by:
saveStatein interfaceStateHolder
public void
restoreState(FacesContext context, Object state)
英文文档:
restoreState
public void restoreState(FacesContext context, Object state)
- Description copied from interface:
StateHolder Perform any processing required to restore the state from the entries in the state Object.
If the class that implements this interface has references to instances that also implement StateHolder (such as a
UIComponentwith event handlers, validators, etc.) this method must call theStateHolder.restoreState(javax.faces.context.FacesContext, java.lang.Object)method on all those instances as well.- Specified by:
restoreStatein interfaceStateHolder
public boolean
isTransient()
英文文档:
isTransient
public boolean isTransient()
- Description copied from interface:
StateHolder If true, the Object implementing this interface must not participate in state saving or restoring.
- Specified by:
isTransientin interfaceStateHolder
public void
setTransient(boolean transientValue)
英文文档:
setTransient
public void setTransient(boolean transientValue)
- Description copied from interface:
StateHolder Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring.
- Specified by:
setTransientin interfaceStateHolder
- Parameters:
transientValue- boolean passtrueif this Object will participate in state saving or restoring, otherwise passfalse.
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!
javax.faces.validator.DoubleRangeValidator