private class DatetimeFormat.DatetimeBuf extends DisplayFormat.Presentation
| Modifier and Type | Field and Description |
|---|---|
private char[][] |
compBufs
Buffers for datetime component digits.
|
private static char |
SPACE
Special value for an empty digit place.
|
forFieldValue, presCursorPos, presInsertMode| Constructor and Description |
|---|
DatetimeBuf()
Constructs default presentation used for clear operation.
|
DatetimeBuf(datetime varDatetime)
Constructs presentation initialized with given
datetime. |
| Modifier and Type | Method and Description |
|---|---|
private void |
assignAMComponent(char[] comp,
int value,
boolean upper)
Fills the AMPM component with the computed value from current hours.
|
private boolean |
assignComponent(char[] comp,
int value,
char leftPad,
boolean sign)
Fills the date/time component with the given value.
|
void |
checkFormat()
Checks format rules.
|
void |
clear()
Delete the screen value.
|
private void |
clearComponent(char[] comp,
int compIdx)
Fills the date component with
SPACE. |
private void |
completeComponent(char[][] newCompBufs,
char[][] oldCompBufs,
int compIndex)
Completes datetime component.
|
boolean |
deleteBack()
Erases one symbol before the cursor position.
|
boolean |
deleteCurrent()
Erases one symbol in the cursor position.
|
private int |
extractDateOrTimeComponent(char[] comp,
boolean includeSign,
int defVal)
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 datetime 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 datetime |
toDatetime()
Returns the current presentation's value converted to
datetime. |
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, deleteRegion, forFieldValue, getCursorPos, getInitialCursorPos, getInsertMode, getLastPos, isFixedNumeric, isLastCharEntered, isNegative, isOptionalLeftSign, setCursorPos, setInsertMode, setLastCharEnteredprivate 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 DatetimeBuf()
public DatetimeBuf(datetime varDatetime) throws DisplayFormatCheckException
datetime.varDatetime - Initial value.DisplayFormatCheckException - This value can't be displayed with the current format.public void clear()
clear in class DisplayFormat.Presentationpublic boolean isFixedFont()
isFixedFont in class DisplayFormat.Presentationtrue.public void checkFormat()
throws DisplayFormatCheckException
checkFormat in class DisplayFormat.PresentationDisplayFormatCheckException - When data is incompatible with formatpublic ErrorManager.ErrorEntry[] validateFormat()
validateFormat in class DisplayFormat.Presentationnull 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.Presentationtrue if this is unknown.public boolean deleteBack()
deleteBack in class DisplayFormat.Presentationtrue if input is accepted (nevertheless it
may be silently ignored in reality).public boolean deleteCurrent()
deleteCurrent in class DisplayFormat.Presentationtrue if input is accepted (nevertheless it
may be silently ignored in reality).public boolean input(char ch)
input in class DisplayFormat.Presentationch - Input charactertrue if input is accepted (nevertheless it may be silently
ignored in reality).public boolean moveCursorLeft()
moveCursorLeft in class DisplayFormat.Presentationtrue if input is accepted (nevertheless it
may be silently ignored in reality).public boolean moveCursorRight()
moveCursorRight in class DisplayFormat.Presentationtrue if input is accepted (nevertheless it
may be silently ignored in reality).public boolean moveCursorBegin()
moveCursorBegin in class DisplayFormat.Presentationtrue if input is accepted (nevertheless it
may be silently ignored in reality).public boolean moveCursorEnd()
moveCursorEnd in class DisplayFormat.Presentationtrue if input is accepted (nevertheless it
may be silently ignored in reality).public boolean finishEdit()
finishEdit in class DisplayFormat.Presentationtrue if rendering is necessary.public java.lang.String toScreenValue(boolean edit)
toScreenValue in class DisplayFormat.Presentationedit - true if the screen value is being generated
for interactive editing purposes.public java.lang.String toScreenValue()
toScreenValue in class DisplayFormat.Presentationpublic void toVar(BaseDataType var)
toVar in class DisplayFormat.Presentationvar - A variable which must be compatible with the format.private char[][] initBuffers()
private void initClear()
private void clearComponent(char[] comp,
int compIdx)
SPACE.comp - The component.compIdx - The id of the component.private boolean assignComponent(char[] comp,
int value,
char leftPad,
boolean sign)
comp - The component.value - The new value.leftPad - Character to be used for left padding.sign - The first character is reserved for the sign (only used for hours TZ).true if the value could be assigned or if component is optional and
false if value cannot be represented in the available spaceprivate void assignAMComponent(char[] comp,
int value,
boolean upper)
comp - The AMPM component.value - The hours to be processed in 24H format.private int extractDateOrTimeComponent(char[] comp,
boolean includeSign,
int defVal)
comp - The date or time component. May partially consist from spaces.includeSign - The component is sign prefixed (for TZ_HOURS only).defVal - Default value to be returned if field not found or could not be parseddefVal on error.private int extractYearComponent(char[][] comp)
throws ErrorConditionException
If format separator isn't null then:
If format separator is null then:
null)
comp - The input datetime 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.
date.windowingImpl() which takes as input the digits
from the sequence (the one that was created on the third step)
is used (if the sequence contains no digits then 0 is used).
newCompBufs - Buffers for new value. May be the same with oldCompBufs.oldCompBufs - Buffers for old value.compIndex - Component's index (DAY, MONTH, YEAR, HOURS, MINUTES, SECONDS, MILLIS, AMPM,
TZ_HOURS, TZ_MINS).private datetime toDatetime() throws DisplayFormatCheckException
datetime.datetime.DisplayFormatCheckException - Value doesn't represent a correct datetime.