jMobileCore toolkit

com.jmobilecore.ui
Class PostalCodeField

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.PostalCodeField

public class PostalCodeField
extends TextField

This class displays formatted textfield for entering postal code information Format of the postal code is specified by user.

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

Field Summary
 byte STYLE
          The current PostalCodeField formatting style.
static byte XXXXX
          The 5 digits postal code, example 12345
static byte XXXXX_XXXX
          The 5 digits postal code with extension, example 12345-6789
static byte XXXXXX
          The 6 digits postal code, example 123456
 
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
PostalCodeField()
          Constructs a new PostalCodeField object.
PostalCodeField(byte style)
          Constructs a new PostalCodeField object of specified style.
PostalCodeField(byte style, java.lang.String postalCode)
          Constructs a new PostalCodeField object of the specified style and 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)
           
protected  CustomFieldComposer initComposer(int style)
          Initialize postal code field composer
 boolean isValid()
          Tests postal code field value for correctness
 void setText(java.lang.String postalCode)
          Sets the PostalCodeField object to specified value
 boolean validate(java.lang.String postalCode)
          Tests if the specified postal code 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

STYLE

public final byte STYLE
The current PostalCodeField formatting style.


XXXXX

public static final byte XXXXX
The 5 digits postal code, example 12345

See Also:
Constant Field Values

XXXXX_XXXX

public static final byte XXXXX_XXXX
The 5 digits postal code with extension, example 12345-6789

See Also:
Constant Field Values

XXXXXX

public static final byte XXXXXX
The 6 digits postal code, example 123456

See Also:
Constant Field Values
Constructor Detail

PostalCodeField

public PostalCodeField()
Constructs a new PostalCodeField object.


PostalCodeField

public PostalCodeField(byte style)
Constructs a new PostalCodeField object of specified style.

Parameters:
style - the postal code style

PostalCodeField

public PostalCodeField(byte style,
                       java.lang.String postalCode)
Constructs a new PostalCodeField object of the specified style and the specified value.

Parameters:
style - the postal code style
postalCode - the postal code, 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

initComposer

protected CustomFieldComposer initComposer(int style)
Initialize postal code field composer

Returns:
CustomFieldComposer for postal code field

isValid

public boolean isValid()
Tests postal code field value for correctness

Returns:
true if the postal code field is valid false otherwise

setText

public void setText(java.lang.String postalCode)
Sets the PostalCodeField object to specified value

Overrides:
setText in class TextField
Parameters:
postalCode - the postal code, digits only no spaces or dashes

validate

public boolean validate(java.lang.String postalCode)
Tests if the specified postal code valid

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

jMobileCore toolkit