|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tapestry.valid.BaseValidator org.apache.tapestry.valid.NumberValidator
public class NumberValidator
Simple validation for standard number classes. This is probably insufficient for anything tricky and application specific, such as parsing currency.
Nested Class Summary | |
---|---|
static class |
NumberValidator.NumberAdaptor
This class is not meant for use outside of NumberValidator; it is public only to fascilitate some unit testing. |
Field Summary | |
---|---|
static int |
NUMBER_TYPE_INTEGER
|
static int |
NUMBER_TYPE_REAL
|
Fields inherited from class org.apache.tapestry.valid.BaseValidator |
---|
FIELD_SYMBOL, FORM_SYMBOL, FUNCTION_SYMBOL, VALIDATOR_SYMBOL |
Constructor Summary | |
---|---|
NumberValidator()
|
Method Summary | |
---|---|
protected String |
buildInvalidIntegerFormatMessage(IFormComponent field)
|
protected String |
buildInvalidNumericFormatMessage(IFormComponent field)
|
protected String |
buildNumberRangeMessage(IFormComponent field)
|
protected String |
buildNumberTooLargeMessage(IFormComponent field)
|
protected String |
buildNumberTooSmallMessage(IFormComponent field)
|
static NumberValidator.NumberAdaptor |
getAdaptor(Class type)
Returns an adaptor for the given type. |
boolean |
getHasMaximum()
|
boolean |
getHasMinimum()
|
String |
getInvalidIntegerFormatMessage()
|
String |
getInvalidNumericFormatMessage()
|
Number |
getMaximum()
|
Number |
getMinimum()
|
String |
getNumberRangeMessage()
|
String |
getNumberTooLargeMessage()
|
String |
getNumberTooSmallMessage()
|
String |
getScriptPath()
|
Class |
getValueTypeClass()
Returns the value type to convert strings back into. |
boolean |
getZeroIsNull()
If true, then when rendering, a zero is treated as a non-value, and null is returned. |
boolean |
isIntegerNumber()
|
void |
renderValidatorContribution(IFormComponent field,
IMarkupWriter writer,
IRequestCycle cycle)
This implementation does nothing. |
void |
setInvalidIntegerFormatMessage(String string)
Overrides the invalid-int-format bundle key. |
void |
setInvalidNumericFormatMessage(String string)
Overrides the invalid-numeric-format bundle key. |
void |
setMaximum(Number maximum)
|
void |
setMinimum(Number minimum)
|
void |
setNumberRangeMessage(String string)
Overrides the number-range bundle key. |
void |
setNumberTooLargeMessage(String string)
Overrides the number-too-large bundle key. |
void |
setNumberTooSmallMessage(String string)
Overrides the number-too-small bundle key. |
void |
setScriptPath(String scriptPath)
Allows a developer to use the existing validation logic with a different client-side script. |
void |
setValueType(String typeName)
Sets the value type from a string type name. |
void |
setValueTypeClass(Class valueTypeClass)
|
void |
setZeroIsNull(boolean zeroIsNull)
|
Object |
toObject(IFormComponent field,
String value)
Converts input, submitted by the client, into an object value. |
String |
toString(IFormComponent field,
Object value)
Invoked during rendering to convert an object value (which may be null) to a String. |
Methods inherited from class org.apache.tapestry.valid.BaseValidator |
---|
buildRequiredMessage, checkRequired, formatString, formatString, formatString, getPattern, getRequiredMessage, isClientScriptingEnabled, isRequired, processValidatorScript, setClientScriptingEnabled, setRequired, setRequiredMessage |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int NUMBER_TYPE_INTEGER
public static final int NUMBER_TYPE_REAL
Constructor Detail |
---|
public NumberValidator()
Method Detail |
---|
public String toString(IFormComponent field, Object value)
IValidator
public static NumberValidator.NumberAdaptor getAdaptor(Class type)
Note: this method exists only for testing purposes. It is not meant to be invoked by user code and is subject to change at any time.
type
- the type (a Number subclass) for which to return an adaptor
public Object toObject(IFormComponent field, String value) throws ValidatorException
IValidator
The input string will already have been trimmed. It may be null.
ValidatorException
- if the string cannot be converted into
an object, or the object is
not valid (due to other constraints).public Number getMaximum()
public boolean getHasMaximum()
public void setMaximum(Number maximum)
public Number getMinimum()
public boolean getHasMinimum()
public void setMinimum(Number minimum)
public boolean getZeroIsNull()
public void setZeroIsNull(boolean zeroIsNull)
public void renderValidatorContribution(IFormComponent field, IMarkupWriter writer, IRequestCycle cycle)
BaseValidator
renderValidatorContribution
in interface IValidator
renderValidatorContribution
in class BaseValidator
public String getScriptPath()
public void setScriptPath(String scriptPath)
window.alert()
).
public void setValueType(String typeName)
public void setValueTypeClass(Class valueTypeClass)
public Class getValueTypeClass()
public String getInvalidNumericFormatMessage()
public String getInvalidIntegerFormatMessage()
public String getNumberRangeMessage()
public String getNumberTooLargeMessage()
public String getNumberTooSmallMessage()
public void setInvalidNumericFormatMessage(String string)
invalid-numeric-format
bundle key.
Parameter {0} is the display name of the field.
public void setInvalidIntegerFormatMessage(String string)
invalid-int-format
bundle key.
Parameter {0} is the display name of the field.
protected String buildInvalidNumericFormatMessage(IFormComponent field)
protected String buildInvalidIntegerFormatMessage(IFormComponent field)
public void setNumberRangeMessage(String string)
number-range
bundle key.
Parameter [0} is the display name of the field.
Parameter {1} is the minimum value.
Parameter {2} is the maximum value.
protected String buildNumberRangeMessage(IFormComponent field)
public void setNumberTooLargeMessage(String string)
number-too-large
bundle key.
Parameter {0} is the display name of the field.
Parameter {1} is the maximum allowed value.
protected String buildNumberTooLargeMessage(IFormComponent field)
public void setNumberTooSmallMessage(String string)
number-too-small
bundle key.
Parameter {0} is the display name of the field.
Parameter {1} is the minimum allowed value.
protected String buildNumberTooSmallMessage(IFormComponent field)
public boolean isIntegerNumber()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |