public class

MaskFormat

extends Format
implements FormatProvider
java.lang.Object
   ↳ java.text.Format
     ↳ humanize.text.MaskFormat

Class Overview

MaskFormat is used to format and parse strings by the mean of a mask. Underscore '_' is used as default place holder for the next message character. The other characters within the mask are inserted between the message symbols. The backslash '\' is escape symbol. Combination of '\?' will include '?' in the human-readable message, where '?' can be any character including underscore '_' and backslash '\'. Hash '#' can be used to skip (delete) a character from the original message.

Examples:
Input Mask Output
313378444416 _ _____ _____ _ 3 13378 44441 6
A58818501 _-__-_____/_ A-58-81850/1
A/5881850 1 _# __ _____#-_ A 58 81850-1

Summary

Public Constructors
MaskFormat()
MaskFormat(String mask)
MaskFormat(String mask, char placeholder)
Public Methods
static FormatFactory factory()
static String format(String mask, String str, char placeholder)
String format(String str)
static String format(String mask, String str)
StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)
FormatFactory getFactory()
Gets the format factory.
String getFormatName()
Gets the format name that will be registered.
String getMask()
char getPlaceholder()
String parse(String source)
static String parse(String mask, String source)
static String parse(String mask, String source, char placeholder)
String parse(String source, ParsePosition pos)
Object parseObject(String source)
Object parseObject(String source, ParsePosition pos)
void setMask(String mask)
void setPlaceholder(char placeholder)
[Expand]
Inherited Methods
From class java.text.Format
From class java.lang.Object
From interface humanize.spi.FormatProvider

Public Constructors

public MaskFormat ()

public MaskFormat (String mask)

public MaskFormat (String mask, char placeholder)

Public Methods

public static FormatFactory factory ()

public static String format (String mask, String str, char placeholder)

public String format (String str)

public static String format (String mask, String str)

public StringBuffer format (Object obj, StringBuffer toAppendTo, FieldPosition pos)

public FormatFactory getFactory ()

Gets the format factory.

Returns

public String getFormatName ()

Gets the format name that will be registered. If you want to register multiple names for a format then return a String with the names concatenated by a vertical bar character '|'.

Returns
  • the format name

public String getMask ()

public char getPlaceholder ()

public String parse (String source)

public static String parse (String mask, String source)

public static String parse (String mask, String source, char placeholder)

public String parse (String source, ParsePosition pos)

public Object parseObject (String source)

public Object parseObject (String source, ParsePosition pos)

public void setMask (String mask)

public void setPlaceholder (char placeholder)