jMobileCore toolkit

com.jmobilecore.ui
Class PhoneNumberField

java.lang.Object
  extended by com.jmobilecore.ui.core.Component
      extended by com.jmobilecore.ui.core.TextComponent
          extended by com.jmobilecore.ui.core.TextField
              extended by com.jmobilecore.ui.PhoneNumberField

public class PhoneNumberField
extends TextField

This class displays fields in a row for entering phone number information.

Author:
Igor Shevlyakov - initial implementation, Greg Gridin - redesign

Field Summary
static byte CCC_AAA_NNN_NN_NN
          The custom phone number format, example: 7(812)444-44-44/(812)444-44-44/444-44-44/44-44-44/4-44-44.
static byte CCC_AAA_NNN_NNNN
          The international phone number format, example: 7(812)444-4444/(812)444-4444/444-4444.
 byte STYLE
          The current PhoneNumberField formatting style.
 
Fields inherited from class com.jmobilecore.ui.core.TextField
adjustment, calculatedCaretPosition, calculatedCursorOffset, composer, currentLength, DEFAULT_SIZE, echoChar, HOFFSET, SCROLLABLE, VOFFSET
 
Fields inherited from class com.jmobilecore.ui.core.TextComponent
ALL_SPEC_CHARS, BORDER_GAP, BORDER_WIDTH, C_ALL_SPEC_CHARS, C_ALPHA, C_ALPHA_NUMERIC, C_ANY, C_EMAIL, C_EMAIL_SPEC_CHARS, C_LOWER_CASE, C_NO_CHARS, C_NUMERIC, C_SPACE, C_UPPER_CASE, cHandler, CHAR_OPTIONS, charOptionCounter, constraint, CURSOR_DELAY, CURSOR_TYPE_LINE, CURSOR_TYPE_SYMBOL, editable, EMAIL_SPEC_CHARS, insertMode, KEY_OPTIONS, lastKeyCode, LC_CHARS, NUMERIC_CHARS, SPACE_CHARS, UC_CHARS, validChars
 
Fields inherited from class com.jmobilecore.ui.core.Component
alignment, background, CENTER, focusable, focusedBackground, focusedForeground, font, foreground, height, isCompletelyVisible, isFocused, isVisible, LEFT, parentScreen, RIGHT, screenY, valid, width
 
Constructor Summary
PhoneNumberField()
          Constructs a new PhoneNumberField object.
PhoneNumberField(java.lang.String phoneNumber)
          Constructs a new PhoneNumberField object of specified format with the specified value.
 
Method Summary
 java.lang.String getFormattedText()
          Get formatted according to STYLE phone number or null if PhoneNumberField object value is set to null or incomplete
protected  char[] getFormattedText(boolean calcCursorOffset)
           
 boolean isValid()
          Tests phone number field value for correctness
 void setText(java.lang.String phoneNumber)
          Sets the PhoneNumberField field to specified value
 boolean validate(java.lang.String phoneNumber)
          Tests if the specified phone number valid
 
Methods inherited from class com.jmobilecore.ui.core.TextField
adjust, destructor, getComposer, getCursorOffset, getText, init, keyPressed, paint, paintCursor, setHeight
 
Methods inherited from class com.jmobilecore.ui.core.TextComponent
addValidChars, getCaretPosition, getKeyOption, initCursor, isCharValid, preProcessKeyCode, processKeyCode, resetCursor, resetCursorHandler, setCaretPosition
 
Methods inherited from class com.jmobilecore.ui.core.Component
getBackground, getFont, getForeground, getHeight, getWidth, invalidate, isFocusOwner, keyReleased, keyRepeated, paintBackground, pointerDragged, pointerPressed, pointerReleased, prepareForeground, releaseFocus, requestFocus, setFont
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CCC_AAA_NNN_NN_NN

public static final byte CCC_AAA_NNN_NN_NN
The custom phone number format, example: 7(812)444-44-44/(812)444-44-44/444-44-44/44-44-44/4-44-44.

See Also:
Constant Field Values

CCC_AAA_NNN_NNNN

public static final byte CCC_AAA_NNN_NNNN
The international phone number format, example: 7(812)444-4444/(812)444-4444/444-4444.

See Also:
Constant Field Values

STYLE

public final byte STYLE
The current PhoneNumberField formatting style.

See Also:
Constant Field Values
Constructor Detail

PhoneNumberField

public PhoneNumberField()
Constructs a new PhoneNumberField object.


PhoneNumberField

public PhoneNumberField(java.lang.String phoneNumber)
Constructs a new PhoneNumberField object of specified format with the specified value.

Parameters:
phoneNumber - the phone number, digits only no spaces or dashes
Method Detail

getFormattedText

public java.lang.String getFormattedText()
Get formatted according to STYLE phone number or null if PhoneNumberField object value is set to null or incomplete

Returns:
the String representing phone number

getFormattedText

protected char[] getFormattedText(boolean calcCursorOffset)
Overrides:
getFormattedText in class TextField

isValid

public boolean isValid()
Tests phone number field value for correctness

Returns:
true if the phone number field is valid false otherwise

setText

public void setText(java.lang.String phoneNumber)
Sets the PhoneNumberField field to specified value

Overrides:
setText in class TextField
Parameters:
phoneNumber - the phone number, digits only no spaces or dashes

validate

public boolean validate(java.lang.String phoneNumber)
Tests if the specified phone number valid

Parameters:
phoneNumber - phone number number without formatting (spaces, dashes etc.)
Returns:
true if the phone number field is valid false otherwise

jMobileCore toolkit