Package org.apache.wicket.util.convert
Class MaskConverter<C>
- java.lang.Object
-
- org.apache.wicket.util.convert.MaskConverter<C>
-
- Type Parameters:
C-
- All Implemented Interfaces:
Serializable,IConverter<C>,IClusterable
public class MaskConverter<C> extends Object implements IConverter<C>
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 fromComponent#getConverter(Class). It uses an instance ofMaskFormatterto 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.isLetterorCharacter.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.
- Author:
- Eelco Hillenius
- See Also:
MaskFormatter, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MaskConverter(String mask)Construct; converts to Strings.MaskConverter(String mask, Class<?> type)Construct.MaskConverter(MaskFormatter maskFormatter)Construct.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CconvertToObject(String value, Locale locale)Converts a string to an object usingMaskFormatter.stringToValue(String).StringconvertToString(C value, Locale locale)Converts the value to a string usingMaskFormatter.valueToString(Object).
-
-
-
Constructor Detail
-
MaskConverter
public MaskConverter(MaskFormatter maskFormatter)
Construct.- Parameters:
maskFormatter- The mask formatter to use for masking and unmasking values
-
MaskConverter
public MaskConverter(String mask)
Construct; converts to Strings.- Parameters:
mask- The mask to use for this converter instance- See Also:
MaskFormatter
-
MaskConverter
public MaskConverter(String mask, Class<?> type)
Construct.- Parameters:
mask- The mask to use for this converter instancetype- The type to convert string values to.- See Also:
MaskFormatter
-
-
Method Detail
-
convertToObject
public C convertToObject(String value, Locale locale)
Converts a string to an object usingMaskFormatter.stringToValue(String).- Specified by:
convertToObjectin interfaceIConverter<C>- Parameters:
value- The string value to convertlocale- The locale used to convert the value- Returns:
- The converted value
-
convertToString
public String convertToString(C value, Locale locale)
Converts the value to a string usingMaskFormatter.valueToString(Object).- Specified by:
convertToStringin interfaceIConverter<C>- Parameters:
value- The value to convertlocale- The locale used to convert the value- Returns:
- The converted string value
-
-