## com.google.i18n.phonenumbers
Class AsYouTypeFormatter

    java.lang.Object
      com.google.i18n.phonenumbers.AsYouTypeFormatter

    public class AsYouTypeFormatter

extends java.lang.Object

A formatter which formats phone numbers as they are entered.

An AsYouTypeFormatter can be created by invoking `PhoneNumberUtil#getAsYouTypeFormatter`. 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

### clear

    public void clear()

  Clears the internal state of the formatter, so it can be reused.

### inputDigit

    public java.lang.String inputDigit(char nextChar)

  Formats a phone number on-the-fly as each digit is entered.

  Parameters:
    `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.
  Returns:
    the partially formatted phone number.

### inputDigitAndRememberPosition

    public 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()`. The remembered position will be automatically adjusted if additional formatting characters are later inserted/removed in front of `nextChar`.

### getRememberedPosition

    public 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)`.