jMobileCore toolkit

com.jmobilecore.ui
Class BankCardField

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.BankCardField
Direct Known Subclasses:
AmexCardField, VisaCardField

public abstract class BankCardField
extends TextField

This abstract class displays formatted textfield for entering bank card information (like VISA/MasterCard/AMEX). Blocks of digits are separated by space.

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

Field Summary
 
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
BankCardField()
          Constructs a new BankCardField field.
BankCardField(java.lang.String cardNumber)
          Constructs a new BankCardField object of type style with the specified value.
 
Method Summary
 java.lang.String getFormattedText()
          Get formatted representation of BankCardField value or null if BankCardField object value is set to null or incomplete
protected abstract  CustomFieldComposer initComposer()
          Abstract method for initiating bank card field composer.
 boolean isValid()
          Tests bank card field value for correctness
 void setText(java.lang.String cardNumber)
          Sets the BankCardField field to specified value
 boolean validate(java.lang.String cardNumber)
          Tests if the specified card valid
 
Methods inherited from class com.jmobilecore.ui.core.TextField
adjust, destructor, getComposer, getCursorOffset, getFormattedText, 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
 

Constructor Detail

BankCardField

public BankCardField()
Constructs a new BankCardField field.


BankCardField

public BankCardField(java.lang.String cardNumber)
Constructs a new BankCardField object of type style with the specified value.

Parameters:
cardNumber - the card number, unformatted, no spaces or dashes
Method Detail

getFormattedText

public java.lang.String getFormattedText()
Get formatted representation of BankCardField value or null if BankCardField object value is set to null or incomplete

Returns:
the String representing bank card number

initComposer

protected abstract CustomFieldComposer initComposer()
Abstract method for initiating bank card field composer. This methods should be defined in inherited classes


isValid

public boolean isValid()
Tests bank card field value for correctness

Returns:
true if the bank card field is valid false otherwise

setText

public void setText(java.lang.String cardNumber)
Sets the BankCardField field to specified value

Overrides:
setText in class TextField
Parameters:
cardNumber - the card number, unformatted, no spaces or dashes

validate

public boolean validate(java.lang.String cardNumber)
Tests if the specified card valid

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

jMobileCore toolkit