private class DateFormat.DateBuf extends DisplayFormat.Presentation
| Modifier and Type | Field and Description |
|---|---|
private boolean |
edited
The behavior changes after any editing was done.
|
private java.lang.StringBuilder |
screenValue
The screen value buffer
|
private static char |
SPACE
Special value for an empty digit place.
|
forFieldValue, presCursorPos, presInsertMode| Modifier | Constructor and Description |
|---|---|
private |
DateBuf()
Constructs default presentation used for clear operation.
|
|
DateBuf(date varDate)
Constructs presentation initialized with given
date. |
| Modifier and Type | Method and Description |
|---|---|
private boolean |
charIsDelimiter(char ch,
int cursorPos)
Test if a character at given position is a delimiter.
|
void |
checkFormat()
Checks format rules.
|
void |
clear()
Delete the screen value.
|
boolean |
deleteBack()
Erases one symbol before the cursor position.
|
boolean |
deleteCurrent()
Erases one symbol in the cursor position.
|
boolean |
deleteRegion(int start,
int end)
Erases a region.
|
private java.lang.String |
extractComponentText(java.lang.String screen,
byte kind)
Extract component text.
|
private int |
extractDayOrMonth(java.lang.String screen,
byte kind)
Extract day or month component value as integer.
|
boolean |
finishEdit()
Indicates completion of an edit.
|
private void |
initScreen(java.lang.StringBuilder sb,
date varDate)
Format a date for using in fill-in.
|
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 boolean |
normalizeComponent(java.lang.String screen,
int kind)
Normalize component text: remove possible leading or trailing spaces
and pad with leading zeroes.
|
private int |
parseYear(java.lang.String yearSpec,
java.util.List<ErrorManager.ErrorEntry> errors)
Parse a string into a year.
|
private void |
setAppendCharacter(char ch,
int index)
Set or append a character at given position.
|
private boolean |
setCursor(int newPosition)
Move cursor to the new position
|
private date |
toDate(java.util.List<ErrorManager.ErrorEntry> errors)
Returns the current presentation's value converted to
date
or just validates the format |
private date |
toDateNoDelimiters(java.lang.String screen,
java.util.List<ErrorManager.ErrorEntry> errors)
Parse a string to a date for formats with no delimiters.
|
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 java.lang.String |
yearNormalize(java.lang.String spec)
Normalize the year component to use for display
|
activate, forFieldValue, getCursorPos, getInitialCursorPos, getInsertMode, getLastPos, isFixedNumeric, isLastCharEntered, isNegative, isOptionalLeftSign, setCursorPos, setInsertMode, setLastCharEnteredprivate boolean edited
private final java.lang.StringBuilder screenValue
private static final char SPACE
private DateBuf()
public DateBuf(date varDate)
date.varDate - Initial value.private final void initScreen(java.lang.StringBuilder sb,
date varDate)
sb - the buffer to initialize, must be initially emptyvarDate - the object to format to the bufferpublic void checkFormat()
throws DisplayFormatCheckException
checkFormat in class DisplayFormat.PresentationDisplayFormatCheckException - When data is incompatible with formatpublic 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 delete operation completed successfully.public boolean deleteRegion(int start,
int end)
deleteRegion in class DisplayFormat.Presentationstart - region start index inclusiveend - region end index exclusivetrue if something has changedpublic boolean finishEdit()
finishEdit in class DisplayFormat.Presentationtrue if rendering is necessary.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 isFixedFont()
isFixedFont in class DisplayFormat.Presentationtrue.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 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 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 java.lang.String toScreenValue()
toScreenValue in class DisplayFormat.Presentationpublic java.lang.String toScreenValue(boolean edit)
toScreenValue in class DisplayFormat.Presentationedit - true if the screen value is being generated
for interactive editing purposes.public void toVar(BaseDataType var)
toVar in class DisplayFormat.Presentationvar - A variable which must be compatible with the format.public ErrorManager.ErrorEntry[] validateFormat()
validateFormat in class DisplayFormat.Presentationnull if no error or error message if there is an
error.private java.lang.String extractComponentText(java.lang.String screen,
byte kind)
screen - the screen valuekind - the component type (DAY, MONTH or YEAR)private final boolean charIsDelimiter(char ch,
int cursorPos)
ch - the character to testcursorPos - the positiontrue if the character value is one of allowed delimiter values, and equals
to the formatting character at the same positionprivate int extractDayOrMonth(java.lang.String screen,
byte kind)
screen - the screen valuekind - the day or month component type (DAY, MONTH)private final boolean normalizeComponent(java.lang.String screen,
int kind)
screen - current screen value to extract the unnormalized component
textkind - component type, one of DAY, MONTH or YEARtrue if the screen value was changedprivate final int parseYear(java.lang.String yearSpec,
java.util.List<ErrorManager.ErrorEntry> errors)
throws ErrorConditionException
If format separator isn't null then:
If format separator is null then:
null)
yearSpec - The input year specification, auto-completed.errors - if not null, then this is an output list of error entries.
The method adds errors to the list instead of throwing themErrorConditionException - If the input sequence does not represent a valid year.private void setAppendCharacter(char ch,
int index)
ch - the character to setindex - the screen value indexprivate final boolean setCursor(int newPosition)
newPosition - the new cursor positiontrue if the cursor position was changedprivate date toDate(java.util.List<ErrorManager.ErrorEntry> errors) throws ErrorConditionException
date
or just validates the formaterrors - if not null, then this is an output list of error entries.
The method adds errors to the list instead of throwing themdate
or null if the error list is not emptyErrorConditionException - Value doesn't represent a correct date.private date toDateNoDelimiters(java.lang.String screen, java.util.List<ErrorManager.ErrorEntry> errors)
null is returned.screen - the screen valueerrors - the errors to reportprivate java.lang.String yearNormalize(java.lang.String spec)
spec - the year specification before normalizationpublic void clear()
clear in class DisplayFormat.Presentation