private class DateFormat.DateBuf extends DisplayFormat.Presentation
Modifier and Type | Field and Description |
---|---|
private char[][] |
compBufs
Buffers for date component digits.
|
private static char |
SPACE
Special value for an empty digit place.
|
presCursorPos, presInsertMode
Constructor and Description |
---|
DateBuf()
Constructs default presentation used for clear operation.
|
DateBuf(date varDate)
Constructs presentation initialized with given
date . |
Modifier and Type | Method and Description |
---|---|
private void |
assignComponent(char[] comp,
int value)
Fills the date component with the given value.
|
void |
checkFormat()
Checks format rules.
|
private void |
clearComponent(char[] comp)
Fills the date component with
SPACE . |
private void |
completeComponent(char[][] newCompBufs,
char[][] oldCompBufs,
int compIndex)
Completes date component.
|
boolean |
deleteBack()
Erases one symbol before the cursor position.
|
boolean |
deleteCurrent()
Erases one symbol in the cursor position.
|
private int |
extractDayOrMonthComponent(char[] comp)
Calculates numeric value of the date component.
|
private int |
extractYearComponent(char[][] comp)
Calculates numeric value of the year.
|
boolean |
finishEdit()
Indicates completion of an edit.
|
private char[][] |
initBuffers()
Allocates date components buffers.
|
private void |
initClear()
Resets content to space value.
|
boolean |
input(char ch)
Inputs character.
|
boolean |
isFixedFont()
Determine if this format must use the DEFAULT-FIXED-FONT, if no font is specified.
|
boolean |
isUnknown()
Returns if the presentation currently represents the
unknown value . |
boolean |
moveCursorBegin()
Moves cursor to the beginning of the field.
|
boolean |
moveCursorEnd()
Moves cursor to the end of the field.
|
boolean |
moveCursorLeft()
Moves cursor one character to the left.
|
boolean |
moveCursorRight()
Moves cursor one character to the right.
|
private date |
toDate()
Returns the current presentation's value converted to
date . |
java.lang.String |
toScreenValue()
Formats the data as a string that is ready for display.
|
java.lang.String |
toScreenValue(boolean edit)
Formats the data as a string that is ready for display.
|
void |
toVar(BaseDataType var)
Instantiates a variable that is equivalent to the presentation's
internal representation.
|
ErrorManager.ErrorEntry[] |
validateFormat()
Validate representation according to format rules and return error
message if there is an error.
|
private ErrorManager.ErrorEntry |
verifyYearComponent(char[][] comp)
Validate year without throwing exceptions.
|
activate, getCursorPos, getInitialCursorPos, getInsertMode, getLastPos, isFixedNumeric, isLastCharEntered, isNegative, isOptionalLeftSign, setCursorPos, setInsertMode, setLastCharEntered
private static final char SPACE
private char[][] compBufs
null
which
means UNKNOWN value. Array element must contain a digit or
SPACE
which will be rendered as space.public DateBuf()
public DateBuf(date varDate) throws DisplayFormatCheckException
date
.varDate
- Initial value.DisplayFormatCheckException
- This value can't be displayed with the current format.public boolean isFixedFont()
isFixedFont
in class DisplayFormat.Presentation
true
.public void checkFormat() throws DisplayFormatCheckException
checkFormat
in class DisplayFormat.Presentation
DisplayFormatCheckException
- When data is incompatible with formatpublic ErrorManager.ErrorEntry[] validateFormat()
validateFormat
in class DisplayFormat.Presentation
null
if no error or error message if there is an
error.public boolean isUnknown()
unknown value
. If any editing has occurred, then this
will return false
even if the editing is not complete.isUnknown
in class DisplayFormat.Presentation
true
if this is unknown
.public boolean deleteBack()
deleteBack
in class DisplayFormat.Presentation
true
if input is accepted (nevertheless it
may be silently ignored in reality).public boolean deleteCurrent()
deleteCurrent
in class DisplayFormat.Presentation
true
if input is accepted (nevertheless it
may be silently ignored in reality).public boolean input(char ch)
input
in class DisplayFormat.Presentation
ch
- Input charactertrue
if input is accepted (nevertheless it
may be silently ignored in reality).public boolean moveCursorLeft()
moveCursorLeft
in class DisplayFormat.Presentation
true
if input is accepted (nevertheless it
may be silently ignored in reality).public boolean moveCursorRight()
moveCursorRight
in class DisplayFormat.Presentation
true
if input is accepted (nevertheless it
may be silently ignored in reality).public boolean moveCursorBegin()
moveCursorBegin
in class DisplayFormat.Presentation
true
if input is accepted (nevertheless it
may be silently ignored in reality).public boolean moveCursorEnd()
moveCursorEnd
in class DisplayFormat.Presentation
true
if input is accepted (nevertheless it
may be silently ignored in reality).public boolean finishEdit()
finishEdit
in class DisplayFormat.Presentation
true
if rendering is necessary.public java.lang.String toScreenValue(boolean edit)
toScreenValue
in class DisplayFormat.Presentation
edit
- true
if the screen value is being generated
for interactive editing purposes.public java.lang.String toScreenValue()
toScreenValue
in class DisplayFormat.Presentation
public void toVar(BaseDataType var)
toVar
in class DisplayFormat.Presentation
var
- A variable which must be compatible with the format.private char[][] initBuffers()
private void initClear()
private void clearComponent(char[] comp)
SPACE
.comp
- The component.private void assignComponent(char[] comp, int value)
comp
- The component.value
- The new value.private int extractDayOrMonthComponent(char[] comp)
comp
- The date component (day or month). May partially consist from spaces.private int extractYearComponent(char[][] comp) throws ErrorConditionException
If format separator isn't null
then:
If format separator is null
then:
null
)
comp
- The input date buffer.ErrorConditionException
- If the input sequence does not represent a valid year.private ErrorManager.ErrorEntry verifyYearComponent(char[][] comp)
comp
- Component to verify.null
if no error found, ErrorManager.ErrorEntry
instance otherwise.private void completeComponent(char[][] newCompBufs, char[][] oldCompBufs, int compIndex)
This method uses only one old and one new buffer for component but takes all buffers to simplify coding of its call.
The year completion algorithm can be described as follows:
null
then do nothing.
newCompBufs
- Buffers for new value. May be the same with
oldCompBufs
.oldCompBufs
- Buffers for old value.compIndex
- Component's index (DAY, MONTH, YEAR).private date toDate() throws DisplayFormatCheckException
date
.date
.DisplayFormatCheckException
- Value doesn't represent a correct date.