C - public class MaskConverter<C> extends Object implements IConverter<C>
Component#getConverter(Class). 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 and Description |
|---|
MaskConverter(MaskFormatter maskFormatter)
Construct.
|
MaskConverter(String mask)
Construct; converts to Strings.
|
MaskConverter(String mask,
Class<?> type)
Construct.
|
| Modifier and Type | Method and Description |
|---|---|
C |
convertToObject(String value,
Locale locale)
Converts a string to an object using
MaskFormatter.stringToValue(String). |
String |
convertToString(C value,
Locale locale)
Converts the value to a string using
MaskFormatter.valueToString(Object). |
public MaskConverter(MaskFormatter maskFormatter)
maskFormatter - The mask formatter to use for masking and unmasking valuespublic MaskConverter(String mask)
mask - The mask to use for this converter instanceMaskFormatterpublic MaskConverter(String mask, Class<?> type)
mask - The mask to use for this converter instancetype - The type to convert string values to.MaskFormatterpublic C convertToObject(String value, Locale locale)
MaskFormatter.stringToValue(String).convertToObject in interface IConverter<C>value - The string value to convertlocale - The locale used to convert the valuepublic String convertToString(C value, Locale locale)
MaskFormatter.valueToString(Object).convertToString in interface IConverter<C>value - The value to convertlocale - The locale used to convert the valueCopyright © 2006–2015 Apache Software Foundation. All rights reserved.