|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.i18n.phonenumbers.AsYouTypeFormatter
public class AsYouTypeFormatter
A formatter which formats phone numbers as they are entered.
An AsYouTypeFormatter can be created by invoking
PhoneNumberUtil.getAsYouTypeFormatter(java.lang.String)
. After that, digits can be added by invoking
inputDigit(char)
on the formatter instance, and the partially formatted phone number will be
returned each time a digit is added. clear()
can be invoked before formatting a new
number.
See the unittests for more details on how the formatter is to be used.
Method Summary | |
---|---|
void |
clear()
Clears the internal state of the formatter, so it can be reused. |
int |
getRememberedPosition()
Returns the current position in the partially formatted phone number of the character which was previously passed in as the parameter of inputDigitAndRememberPosition(char) . |
java.lang.String |
inputDigit(char nextChar)
Formats a phone number on-the-fly as each digit is entered. |
java.lang.String |
inputDigitAndRememberPosition(char nextChar)
Same as inputDigit(char) , but remembers the position where nextChar is inserted, so
that it can be retrieved later by using getRememberedPosition() . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public void clear()
public java.lang.String inputDigit(char nextChar)
nextChar
- the most recently entered digit of a phone number. Formatting characters are
allowed, but as soon as they are encountered this method formats the number as entered and
not "as you type" anymore. Full width digits and Arabic-indic digits are allowed, and will
be shown as they are.
public java.lang.String inputDigitAndRememberPosition(char nextChar)
inputDigit(char)
, but remembers the position where nextChar
is inserted, so
that it can be retrieved later by using getRememberedPosition()
. The remembered
position will be automatically adjusted if additional formatting characters are later
inserted/removed in front of nextChar
.
public int getRememberedPosition()
inputDigitAndRememberPosition(char)
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |