|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectwicket.util.convert.LocalizableAdapter
wicket.util.convert.SimpleConverterAdapter
wicket.util.convert.MaskConverter
public class MaskConverter
A converter that takes a mask into account. It is specifically meant for
overrides on individual components, that provide their own converter by
returning it from Component.getConverter(). It uses an instance of
MaskFormatter to delegate the masking and unmasking to.
The following characters can be specified (adopted from the MaskFormatter documentation):
| Character |
Description |
|---|---|
| # | Any valid number, uses Character.isDigit. |
| ' | Escape character, used to escape any of the special formatting characters. |
| U | Any character (Character.isLetter). All lowercase
letters are mapped to upper case. |
| L | Any character (Character.isLetter). All upper case
letters are mapped to lower case. |
| A | Any character or number (Character.isLetter or
Character.isDigit) |
| ? | Any character (Character.isLetter). |
| * | Anything. |
| H | Any hex character (0-9, a-f or A-F). |
Typically characters correspond to one char, but in certain languages this is not the case. The mask is on a per character basis, and will thus adjust to fit as many chars as are needed.
MaskFormatter,
Serialized Form| Constructor Summary | |
|---|---|
MaskConverter(javax.swing.text.MaskFormatter maskFormatter)
Construct. |
|
MaskConverter(java.lang.String mask,
java.lang.Class type)
Construct. |
|
| Method Summary | |
|---|---|
java.lang.Object |
toObject(java.lang.String value)
Converts a string to an object using MaskFormatter.stringToValue(String). |
java.lang.String |
toString(java.lang.Object value)
Converts the value to a string using MaskFormatter.valueToString(Object). |
| Methods inherited from class wicket.util.convert.SimpleConverterAdapter |
|---|
convert |
| Methods inherited from class wicket.util.convert.LocalizableAdapter |
|---|
getLocale, setLocale |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface wicket.util.convert.ILocalizable |
|---|
getLocale, setLocale |
| Constructor Detail |
|---|
public MaskConverter(java.lang.String mask,
java.lang.Class type)
mask - The mask to use for this converter instancetype - The type to convert string values to. WARNING: adding anything
that implements charsequence here will probably not have the
desired effect as then only toString(Object) will be
called. Consider wrapping your string value in a custom class
so that conversion will be triggered properly. That class
should have a public constructor with a single string
argument. That constructor will be used by
MaskFormatter to construct instances.MaskFormatterpublic MaskConverter(javax.swing.text.MaskFormatter maskFormatter)
DefaultFormatter.setValueClass(Class) to
anything that implements charsequence, or not setting that class at all,
which has the effect that String will be used will probably not have the
desired effect as then only toString(Object) will be called.
Consider wrapping your string value in a custom class so that conversion
will be triggered properly. That class should have a public constructor
with a single string argument. That constructor will be used by
MaskFormatter to construct instances.
maskFormatter - The mask formatter to use for masking and unmasking values| Method Detail |
|---|
public java.lang.String toString(java.lang.Object value)
MaskFormatter.valueToString(Object).
toString in class SimpleConverterAdaptervalue - The value to convert, may be null
SimpleConverterAdapter.toString(java.lang.Object)public java.lang.Object toObject(java.lang.String value)
MaskFormatter.stringToValue(String).
toObject in class SimpleConverterAdaptervalue - The string to convert, may be null
SimpleConverterAdapter.toObject(java.lang.String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||