jMobileCore toolkit

com.jmobilecore.ui
Class CurrencyField

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

public class CurrencyField
extends TextField

This class displays two fields, one for currency major and one for currency minor (like dollars and cents) separated by a decimal point. If alignment is Component.LEFT or Component.CENTER the currency major field is preceded by a currency symbol. If alignment is Component.RIGHT then the currency symbol follows the currency minor field

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

Field Summary
protected  int decimals
          The number of decimal digits in CurrencyField
 java.lang.String symbol
          The currency symbol Examples: "$", "USD", "RUR" etc.
 
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
CurrencyField()
          Constructs a new CurrencyField field.
CurrencyField(int major, int minor)
          Constructs a new CurrencyField object with the specified value.
 
Method Summary
 void destructor()
          Default destructor.
 java.lang.String getFormattedText()
          Get formatted representation of CurrencyField value or null if CurrencyField object value is set to null or incomplete
protected  char[] getFormattedText(boolean calcCursorOffset)
           
 long getMajor()
          Get the major part of CurrencyField value or -1 if CurrencyField object value is set to null or incomplete
 int getMinor()
          Get the minor part of CurrencyField value or -1 if CurrencyField object value is set to null or incomplete
protected  CustomFieldComposer initComposer()
          Initialize currency field composer
 boolean isValid()
          Tests currency field value for correctness
 void setCurrency(long major, long minor)
          Sets CurrencyField object to the specified value.
 
Methods inherited from class com.jmobilecore.ui.core.TextField
adjust, getComposer, getCursorOffset, getText, init, keyPressed, paint, paintCursor, setHeight, setText
 
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

decimals

protected int decimals
The number of decimal digits in CurrencyField


symbol

public java.lang.String symbol
The currency symbol Examples: "$", "USD", "RUR" etc.

Constructor Detail

CurrencyField

public CurrencyField()
Constructs a new CurrencyField field.


CurrencyField

public CurrencyField(int major,
                     int minor)
Constructs a new CurrencyField object with the specified value.

Parameters:
major - the major part of CurrencyField value
minor - the minor part of CurrencyField value
See Also:
setCurrency(long, long)
Method Detail

destructor

public void destructor()
Description copied from class: TextComponent
Default destructor. Helps VM to perform garbage collection

Overrides:
destructor in class TextField

getFormattedText

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

Returns:
the String representing bank card number

getFormattedText

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

getMajor

public long getMajor()
Get the major part of CurrencyField value or -1 if CurrencyField object value is set to null or incomplete

Returns:
the int value representing the specified currency major

getMinor

public int getMinor()
Get the minor part of CurrencyField value or -1 if CurrencyField object value is set to null or incomplete

Returns:
the int value representing the specified currency minor

initComposer

protected CustomFieldComposer initComposer()
Initialize currency field composer

Returns:
CustomFieldComposer for IPv4 field

isValid

public boolean isValid()
Tests currency field value for correctness

Returns:
true if the currency field is valid false otherwise

setCurrency

public void setCurrency(long major,
                        long minor)
Sets CurrencyField object to the specified value. The CurrencyField major/minor values should be calcuated according to formulae: CurrencyField.minor = minor % (10**digits); CurrencyField.major = major + minor / (10**digits);

Parameters:
major - the major part of CurrencyField value
minor - the minor part of CurrencyField value

jMobileCore toolkit