public class MaskFormatter extends AbstractFormatter
String
values in a
FormattedText
.
Symbol | Meaning |
---|---|
# |
Digit |
A |
Alphanumeric |
U |
Alphanumeric converted in uppercase |
L |
Alphanumeric converted in lowercase |
newFormatter("(###) UUU-AAAA");
setValue("123aBcDeF");
-> will display as "(123) ABC-DeF".Modifier and Type | Field and Description |
---|---|
protected int |
count
Current number of characters in the buffer (except mask characters)
|
protected java.lang.String |
editPattern
Edit mask
|
protected java.lang.StringBuffer |
editValue
Buffer for the edit value
|
protected int |
positions
Number of editable positions in the mask
|
EMPTY, ignore, SPACE, text
Constructor and Description |
---|
MaskFormatter(java.lang.String editPattern)
Constructs a new instance with the given edit mask.
|
Modifier and Type | Method and Description |
---|---|
protected void |
clearText(int start,
int len)
Clear a part of the edition cache.
|
java.lang.String |
getDisplayString()
Returns the current value formatted for display.
|
java.lang.String |
getEditString()
Returns the current value formatted for editing.
|
java.lang.Object |
getValue()
Returns the current value.
|
java.lang.Class<java.lang.String> |
getValueType()
Returns the type of value this
ITextFormatter handles, i.e. |
protected int |
insertText(java.lang.String txt,
int start)
Inserts a sequence of characters in the edit buffer.
|
boolean |
isEmpty()
Returns
true if current edited value is empty, else returns
false .A value is considered as empty in a MaskFormatter if the edit buffer contains no characters except the mask characters. |
protected boolean |
isHexDigit(char ch) |
boolean |
isValid()
Returns
true if current edited value is valid, else returns
false . |
void |
setValue(java.lang.Object value)
Sets the value to edit.
|
void |
verifyText(org.eclipse.swt.events.VerifyEvent e)
Handles a
VerifyEvent sent when the text is about to be
modified. |
beep, detach, setIgnore, setText, updateText, updateText
protected java.lang.String editPattern
protected java.lang.StringBuffer editValue
protected int positions
protected int count
public MaskFormatter(java.lang.String editPattern)
editPattern
- edit maskprotected void clearText(int start, int len)
start
- beginning indexlen
- length of portion to clearpublic java.lang.String getDisplayString()
There is no difference in this formatter between edit and display values. So this method returns the edit string.
ITextFormatter.getDisplayString()
public java.lang.String getEditString()
FormattedText
when the Text
widget gains focus.
The value returned is the content of the StringBuilder
editValue
used as cache.ITextFormatter.getEditString()
public java.lang.Object getValue()
ITextFormatter.getValue()
public java.lang.Class<java.lang.String> getValueType()
ITextFormatter
handles, i.e.
returns in getValue()
.protected int insertText(java.lang.String txt, int start)
txt
- String of characters to insertstart
- Starting position of insertionpublic boolean isEmpty()
true
if current edited value is empty, else returns
false
.public boolean isValid()
true
if current edited value is valid, else returns
false
. An empty value is considered as valid.ITextFormatter.isValid()
public void setValue(java.lang.Object value)
String
.value
- string valuejava.lang.IllegalArgumentException
- if not a stringITextFormatter.setValue(java.lang.Object)
public void verifyText(org.eclipse.swt.events.VerifyEvent e)
VerifyEvent
sent when the text is about to be
modified. This method is the entry point of all operations of formatting.VerifyListener.verifyText(org.eclipse.swt.events.VerifyEvent)
protected boolean isHexDigit(char ch)