jMobileCore toolkit

com.jmobilecore.ui
Class DigitalBlockComposer

java.lang.Object
  extended by com.jmobilecore.ui.core.TextFieldComposer
      extended by com.jmobilecore.ui.TextBlockComposer
          extended by com.jmobilecore.ui.DigitalBlockComposer
All Implemented Interfaces:
AbstractComposer

public class DigitalBlockComposer
extends TextBlockComposer

The DigitalBlockComposer is extension of class TextBlockComposer, supports digits-only text field editing

Author:
Greg Gridin

Field Summary
 long maxValue
          Maximal value for the field
 long minValue
          Minimal value for the field
 
Fields inherited from class com.jmobilecore.ui.TextBlockComposer
fillChar, FIXED_SIZE, STATIC_FOCUSABLE, STYLE, VARIABLE_SIZE
 
Fields inherited from class com.jmobilecore.ui.core.TextFieldComposer
caretPosition, curLen, text
 
Constructor Summary
DigitalBlockComposer(byte style, int length)
          Constructs new instance of DigitalBlockComposer with specified style and length
DigitalBlockComposer(byte style, int length, char fillChar)
          Constructs new instance of DigitalBlockComposer with specified style, length and filling characted
DigitalBlockComposer(byte style, int length, char fillChar, long minValue, long maxValue)
          Constructs new instance of DigitalBlockComposer with specified style, length filling characted, minimal and maximal value
DigitalBlockComposer(java.lang.String staticContent)
          Constructs new instance of DigitalBlockComposer with static style.
 
Method Summary
 boolean addChar(char ch, boolean insertMode)
          Adds new symbol or replaces the current one
 long getValue()
          Returns value of the field
 boolean isComplete()
          Tests if editing of the field is complete
 boolean setValue(long newValue)
          Sets new value to the field
 
Methods inherited from class com.jmobilecore.ui.TextBlockComposer
backspace, caretLeft, caretRight, clear, deleteChar, getCaretPosition, setCaretPosition, setText
 
Methods inherited from class com.jmobilecore.ui.core.TextFieldComposer
destructor, getChars, getCurrentLength, getCursorOffset, getMaxSize, getText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maxValue

public long maxValue
Maximal value for the field


minValue

public long minValue
Minimal value for the field

Constructor Detail

DigitalBlockComposer

public DigitalBlockComposer(byte style,
                            int length)
Constructs new instance of DigitalBlockComposer with specified style and length

Parameters:
style - DigitalBlockComposer style, cannot be STATIC
length - the length for fixed size style, the max length for variable size style
Throws:
java.lang.RuntimeException - if style is STATIC

DigitalBlockComposer

public DigitalBlockComposer(byte style,
                            int length,
                            char fillChar)
Constructs new instance of DigitalBlockComposer with specified style, length and filling characted

Parameters:
style - DigitalBlockComposer style, cannot be STATIC
length - the length for fixed size style, the max length for variable size style
fillChar - the characted for filling out "empty" symbols
Throws:
java.lang.RuntimeException - if style is STATIC

DigitalBlockComposer

public DigitalBlockComposer(byte style,
                            int length,
                            char fillChar,
                            long minValue,
                            long maxValue)
Constructs new instance of DigitalBlockComposer with specified style, length filling characted, minimal and maximal value

Parameters:
style - TextBlockComposer style, cannot be STATIC
length - the length for fixed size style, the max length for variable size style
fillChar - the characted for filling out "empty" symbols
minValue - the minimal value for the field
maxValue - the maximal value for the field
Throws:
java.lang.RuntimeException - if style is STATIC

DigitalBlockComposer

public DigitalBlockComposer(java.lang.String staticContent)
Constructs new instance of DigitalBlockComposer with static style.

Parameters:
staticContent - the static (non-editable) content
Method Detail

addChar

public boolean addChar(char ch,
                       boolean insertMode)
Adds new symbol or replaces the current one

Specified by:
addChar in interface AbstractComposer
Overrides:
addChar in class TextBlockComposer
Parameters:
ch - new symbol
insertMode - if true then new symbol will be added, otherwise the current symbol will be replaced
Returns:
true if the add/replace is possible, false otherwise

getValue

public long getValue()
Returns value of the field

Returns:
the field value
Throws:
java.lang.NumberFormatException - if field contants not-a-number value

isComplete

public boolean isComplete()
Tests if editing of the field is complete

Overrides:
isComplete in class TextBlockComposer
Returns:
true if field is valid (complete and has correct value), false otherwise

setValue

public boolean setValue(long newValue)
Sets new value to the field

Parameters:
newValue - the new value for the field
Returns:
true if the field was set to new value, false otherwise

jMobileCore toolkit