public abstract class DisplayFormat
extends java.lang.Object
DisplayFormatFactory
is provided to make this selection
automatic.
After format instantiation fromVar()
method may be called to
get an internal presentation
of data of
corresponding data type.
Modifier and Type | Class and Description |
---|---|
class |
DisplayFormat.Presentation
Format specific internal presentation of data.
|
Modifier and Type | Field and Description |
---|---|
protected EditableField |
editableSource
A reference to the editable widget using this display.
|
protected int |
fmtScreenWidth
Default width which should be reserved for a screen value.
|
private java.lang.String |
formatDef
Saved Progress format definition string.
|
Constructor and Description |
---|
DisplayFormat(java.lang.String format)
Constructs format from the Progress format string.
|
Modifier and Type | Method and Description |
---|---|
abstract DisplayFormat.Presentation |
clear(DisplayFormat.Presentation pres)
Returns a new presentation instance with a default initialized insert
mode and cursor position.
|
DisplayFormat.Presentation |
clear(DisplayFormat.Presentation pres,
boolean zapClear)
Returns a new presentation instance with a default initialized insert
mode and cursor position.
|
static java.lang.String |
formatScreenValue(java.lang.String screen,
int width,
int offsScroll,
boolean leftTrim,
boolean rightAlign)
Formats screen value into screen chars.
|
abstract DisplayFormat.Presentation |
fromVar(BaseDataType var)
Initializes a presentation for variable's value.
|
private static java.lang.String |
generateMultichar(char ch,
int len)
Fast generation of short string from repetitions of the same char.
|
static java.lang.String |
generateQuestions(int len)
Generates string from question marks.
|
static java.lang.String |
generateSpaces(int len)
Generates string from spaces.
|
java.lang.String |
getFormatDef()
Returns format definition string.
|
int |
getScreenWidth()
Returns screen width of the format.
|
static BaseDataType |
instanceOfType(java.lang.String dataType)
Generate instance of
BaseDataType and default value. |
static BaseDataType |
instanceOfType(java.lang.String dataType,
java.lang.String value)
Generate instance of
BaseDataType for given type name and
value. |
static BaseDataType |
instanceOfType(java.lang.String dataType,
java.lang.String value,
java.lang.String format)
Generate instance of
BaseDataType for given type name and
value. |
boolean |
isFormatCheck()
Verify if this format needs explicit validation.
|
boolean |
isRightPositioning()
Indicates if the screen value or a column's title could be formatted
with trimming from the left and right alignment based on this format.
|
boolean |
isZapSupported()
Indicates that ZAP operation can be performed on field with this format.
|
void |
setEditableSource(EditableField source)
Set the editable source being displayed.
|
protected EditableField editableSource
protected int fmtScreenWidth
private java.lang.String formatDef
public DisplayFormat(java.lang.String format)
format
- Progress format definition string.public int getScreenWidth()
public abstract DisplayFormat.Presentation clear(DisplayFormat.Presentation pres)
pres
- A Presentation instance which was constructed by this format.
May be null
. This presentation instance is not
changed in this method.public DisplayFormat.Presentation clear(DisplayFormat.Presentation pres, boolean zapClear)
pres
- A Presentation instance which was constructed by this format.
May be null
. This presentation instance is not
changed in this method.zapClear
- If true
then presentation is cleared completely,
like if zap mode is ON. If false
then it is
cleared like if CLEAR event was applied (that means it may
be cleared from the current cursor position).public abstract DisplayFormat.Presentation fromVar(BaseDataType var) throws DisplayFormatCheckException
var
- Variable which should be compatible with format.DisplayFormatCheckException
- Variable's value is incompatible with format.public static java.lang.String generateQuestions(int len)
len
- Requested result string length.public static java.lang.String generateSpaces(int len)
len
- Requested result string length.public static java.lang.String formatScreenValue(java.lang.String screen, int width, int offsScroll, boolean leftTrim, boolean rightAlign)
screen
- Screen value or column's title. May contain null
.
In this case return value will consists from question marks.width
- Width on display. The result string will have this length.offsScroll
- Scroll offset. Display width plus this offset must be no more
than screen value length. Used only when screen value is longer
than display width and left trimming is not requested.leftTrim
- Indicates that screen value should be truncated from the left.
Used only when screen value is longer than display width.rightAlign
- Indicates that short screen value should be padded on the left.width
length which can be placed to
terminal.public static BaseDataType instanceOfType(java.lang.String dataType)
BaseDataType
and default value.
Default value for string is empty string, 0 for numbers, false for
logical and unknown value
for dates.
dataType
- Data type name.BaseDataType
or null
if type name is not recognized.public static BaseDataType instanceOfType(java.lang.String dataType, java.lang.String value)
BaseDataType
for given type name and
value.dataType
- Data type name.value
- Initial value for the variable.BaseDataType
or null
if type name is not recognized.public static BaseDataType instanceOfType(java.lang.String dataType, java.lang.String value, java.lang.String format)
BaseDataType
for given type name and
value.dataType
- Data type name.value
- Initial value for the variable.format
- Data format. For some data types it can help with the value string parsing.BaseDataType
or null
if type name is not recognized.private static java.lang.String generateMultichar(char ch, int len)
ch
- Character to duplicate.len
- Requested result string length.public boolean isFormatCheck()
false
by default.public java.lang.String getFormatDef()
public boolean isRightPositioning()
This value only notes if this format supports such trimming/alignment but it doesn't specify if it should be applied in every case (which may be a configuration option for a given caller).
false
.public boolean isZapSupported()
public void setEditableSource(EditableField source)
source
- The source.