public class KeyReader
extends java.lang.Object
Stream
implementation or the
LogicalTerminal
implementation to back the service based
on runtime state.
The initial last key value is currently set to 401 which is valid for only a sub-set of terminal types (e.g xterm/vt100). It is known that for vt220/vt320 type terminals this would need to be corrected (they report -1 in Progress). For other terminal types, the initial value is not known. The solution will require that a terminal specific value be reported depending on runtime data. This solution has not yet been defined. Part of the problem with the solution is that the server has no knowledge of the terminal type nor does it currently have any other terminal type dependencies.
Modifier and Type | Class and Description |
---|---|
private static class |
KeyReader.ContextContainer
Simple container that stores and returns a context-local instance of
the global work area.
|
private static class |
KeyReader.WorkArea
Stores data relating to the state of the current context's key reading.
|
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
KEY_EVTYPE
LAST-EVENT:EVENT-TYPE for keyboard Progress events
|
private static java.lang.String |
MOUSE_EVTYPE
LAST-EVENT:EVENT-TYPE for mouse Progress events
|
private static java.lang.String |
PROGRESS_EVTYPE
LAST-EVENT:EVENT-TYPE for high-level Progress events
|
private static KeyReader.ContextContainer |
workArea
Context-local data area for last key state.
|
Constructor and Description |
---|
KeyReader() |
Modifier and Type | Method and Description |
---|---|
static handle |
asHandle()
Get a the instance for the LAST-EVENT system handle.
|
static character |
getColumnLabel()
Calls
handle.invalidAttribute(java.lang.String, com.goldencode.p2j.util.handle) , as the COLUMN-LABEL attribute is not supported. |
static character |
getDataType()
Calls
handle.invalidAttribute(java.lang.String, com.goldencode.p2j.util.handle) , as the DATA-TYPE attribute is not supported. |
static character |
getEventType()
Returns the value of the LAST-EVENT:EVENT-TYPE attribute
|
static character |
getFormat()
Calls
handle.invalidAttribute(java.lang.String, com.goldencode.p2j.util.handle) , as the FORMAT attribute is not supported. |
static character |
getLabel()
Returns the value of the LABEL attribute
|
static character |
getLastFunction()
Implementation of the LAST-EVENT system handle's FUNCTION attribute.
|
static int |
getLastKey()
Obtains the last key read from any source (stream or terminal).
|
static character |
getResourceType()
Get the type of its associated handle.
|
static handle |
getWidgetEnter()
Returns the value of the LAST-EVENT:WIDGET-ENTERY attribute
|
static handle |
getWidgetLeave()
Returns the value of the LAST-EVENT:WIDGET-LEAVE attribute
|
static integer |
getX()
Implementation of the LAST-EVENT system handle's X attribute.
|
static integer |
getY()
Implementation of the LAST-EVENT system handle's Y attribute.
|
static java.lang.Long |
id()
Get this resource's ID.
|
static void |
id(long id)
Set this resource's ID.
|
static logical |
isOnFrameBorder()
Implementation of the ON-FRAME-BORDER system handle's EVENT-TYPE attribute.
|
static integer |
lastKey()
Obtains the last key read from any source (stream or terminal).
|
static int |
readKey()
Read a character from the unnamed input stream (if open) or from the
LogicalTerminal , blocking until input is received. |
static int |
readKey(double pause)
Read a character from the unnamed input stream (if open) or from the
LogicalTerminal . |
static int |
readKey(NumberType pause)
Read a character from the unnamed input stream (if open) or from the
LogicalTerminal . |
static int |
readKey(Stream in)
Read a character from the given stream or from the
LogicalTerminal , blocking until input is received. |
static int |
readKey(Stream in,
double pause)
Read a character from the given stream or from the
LogicalTerminal . |
static int |
readKey(Stream in,
NumberType pause)
Read a character from the given stream or from the
LogicalTerminal . |
static void |
readOnlyError(java.lang.String attribute)
API needed to implement read-only attribute assignment (a 4GL
"feature").
|
static void |
setColumnLabel(character columnLabel)
Calls
handle.readOnlyError(com.goldencode.p2j.util.handle, java.lang.String) as this attribute is not supported. |
static void |
setColumnLabel(java.lang.String columnLabel)
Calls
handle.readOnlyError(com.goldencode.p2j.util.handle, java.lang.String) as this attribute is not supported. |
static void |
setDataType(character dataType)
Calls
handle.readOnlyError(com.goldencode.p2j.util.handle, java.lang.String) as this attribute is not supported. |
static void |
setDataType(java.lang.String dataType)
Calls
handle.readOnlyError(com.goldencode.p2j.util.handle, java.lang.String) as this attribute is not supported. |
static void |
setFormat(character format)
Calls
handle.readOnlyError(com.goldencode.p2j.util.handle, java.lang.String) as this attribute is not supported. |
static void |
setFormat(java.lang.String format)
Calls
handle.readOnlyError(com.goldencode.p2j.util.handle, java.lang.String) as this attribute is not supported. |
static void |
setKeyFunctionWorker(int func)
Used internally by P2J to set the
KeyReader.WorkArea.keyFunction |
static void |
setLabel(character label)
Set the
name attribute of handle. |
static void |
setLabel(java.lang.String label)
Set the
name attribute of handle. |
static void |
setLabelWorker(java.lang.String label)
Used internally by P2J to set the
KeyReader.WorkArea.label in server-side event cases. |
static void |
setLastKey(int key)
Sets the last key read and main attributes: LABEL, FUNCTION, EVENT-TYPE
|
static void |
setX(NumberType x)
Set the X attribute.
|
static void |
setY(NumberType y)
Set the Y attribute.
|
static boolean |
unknown()
Implementation for the
WrappedResource.unknown() API. |
static boolean |
valid()
Implementation for the
WrappedResource.valid() API. |
private static final java.lang.String PROGRESS_EVTYPE
private static final java.lang.String KEY_EVTYPE
private static final java.lang.String MOUSE_EVTYPE
private static KeyReader.ContextContainer workArea
public static handle asHandle()
StaticProxy.obtain(Class, Class[])
, using the
CommonLastEvent
interface and its methods implemented by these
classes: KeyReader
.public static java.lang.Long id()
public static void id(long id)
This is a no-op for system handles.
id
- The resource's ID.public static boolean valid()
WrappedResource.valid()
API.public static boolean unknown()
WrappedResource.unknown()
API.public static void readOnlyError(java.lang.String attribute)
attribute
- The attribute's name.handle.readOnlyError(handle, String)
public static integer lastKey()
public static int getLastKey()
public static void setLastKey(int key)
key
- The last key read (LASTKEY).public static character getLastFunction()
public static void setKeyFunctionWorker(int func)
KeyReader.WorkArea.keyFunction
func
- The FUNCTION to be set.public static int readKey() throws StopConditionException
LogicalTerminal
, blocking until input is received.
The exact character read will be stored as the lastkey and can be
accessed via lastKey()
. The lastkey will be set to -1 if there
is any interruption or error during processing or will be set to -2 at
EOF
.
EOF
.StopConditionException
- If any interruption occurs during I/O processing.public static int readKey(Stream in) throws StopConditionException
LogicalTerminal
, blocking until input is received.
The exact character read will be stored as the lastkey and can be
accessed via lastKey()
. The lastkey will be set to -1 if there
is any interruption or error during processing or will be set to -2 at
EOF
.
in
- The stream from which to read. If null
or if
it is an instance of StreamWrapper
which has no
backing stream, then the LogicalTerminal
will
be read.EOF
.StopConditionException
- If any interruption occurs during I/O processing.public static int readKey(NumberType pause) throws StopConditionException
LogicalTerminal
.
The exact character read will be stored as the lastkey and can be
accessed via lastKey()
. The lastkey will be set to -1 if there
is any interruption or error during processing or will be set to -2 at
EOF
.
pause
- The number of seconds to wait for a character to be available
for reading. Use 0 to get an immediate response (it will
return -1 if there is no character immediately available).
Use -1 to specify an infinite timeout (it will never
timeout). If set to the unknown value
, an
indefinite wait will occur.EOF
.StopConditionException
- If any interruption occurs during I/O processing.public static int readKey(double pause) throws StopConditionException
LogicalTerminal
.
The exact character read will be stored as the lastkey and can be
accessed via lastKey()
. The lastkey will be set to -1 if there
is any interruption or error during processing or will be set to -2 at
EOF
.
pause
- The number of seconds to wait for a character to be available
for reading. Use 0 to get an immediate response (it will
return -1 if there is no character immediately available).
Use -1 to specify an infinite timeout (it will never
timeout).EOF
.StopConditionException
- If any interruption occurs during I/O processing.public static int readKey(Stream in, NumberType pause) throws StopConditionException
LogicalTerminal
.
The exact character read will be stored as the lastkey and can be
accessed via lastKey()
. The lastkey will be set to -1 if there
is any interruption, the timeout expires without a character being read
or there is an error during processing. The lastkey will be set to -2
at EOF
.
in
- The stream from which to read. If null
or if
it is an instance of StreamWrapper
which has no
backing stream, then the LogicalTerminal
will
be read.pause
- The number of seconds to wait for a character to be available
for reading. Use 0 to get an immediate response (it will
return -1 if there is no character immediately available).
Use -1 to specify an infinite timeout (it will never
timeout). If set to the unknown value
, an
indefinite wait will occur.EOF
.StopConditionException
- If any interruption occurs during I/O processing.public static int readKey(Stream in, double pause) throws StopConditionException
LogicalTerminal
.
The exact character read will be stored as the lastkey and can be
accessed via lastKey()
. The lastkey will be set to -1 if there
is any interruption, the timeout expires without a character being read
or there is an error during processing. The lastkey will be set to -2
at EOF
.
in
- The stream from which to read. If null
or if
it is an instance of StreamWrapper
which has no
backing stream, then the LogicalTerminal
will
be read.pause
- The number of seconds to wait for a character to be available
for reading. Use 0 to get an immediate response (it will
return -1 if there is no character immediately available).
Use -1 to specify an infinite timeout (it will never
timeout).EOF
.StopConditionException
- If any interruption occurs during I/O processing.public static character getResourceType()
public static character getFormat()
handle.invalidAttribute(java.lang.String, com.goldencode.p2j.util.handle)
, as the FORMAT attribute is not supported.public static void setFormat(character format)
handle.readOnlyError(com.goldencode.p2j.util.handle, java.lang.String)
as this attribute is not supported.format
- Not used.public static void setFormat(java.lang.String format)
handle.readOnlyError(com.goldencode.p2j.util.handle, java.lang.String)
as this attribute is not supported.format
- Not used.public static character getColumnLabel()
handle.invalidAttribute(java.lang.String, com.goldencode.p2j.util.handle)
, as the COLUMN-LABEL attribute is not supported.public static void setColumnLabel(character columnLabel)
handle.readOnlyError(com.goldencode.p2j.util.handle, java.lang.String)
as this attribute is not supported.columnLabel
- Not used.public static void setColumnLabel(java.lang.String columnLabel)
handle.readOnlyError(com.goldencode.p2j.util.handle, java.lang.String)
as this attribute is not supported.columnLabel
- Not used.public static character getDataType()
handle.invalidAttribute(java.lang.String, com.goldencode.p2j.util.handle)
, as the DATA-TYPE attribute is not supported.public static void setDataType(java.lang.String dataType)
handle.readOnlyError(com.goldencode.p2j.util.handle, java.lang.String)
as this attribute is not supported.dataType
- Not used.public static void setDataType(character dataType)
handle.readOnlyError(com.goldencode.p2j.util.handle, java.lang.String)
as this attribute is not supported.dataType
- Not used.public static handle getWidgetLeave()
public static handle getWidgetEnter()
public static character getEventType()
public static character getLabel()
public static void setLabel(java.lang.String label)
name
attribute of handle.label
- The LABEL to be set.public static void setLabel(character label)
name
attribute of handle.label
- The LABEL to be set.public static void setLabelWorker(java.lang.String label)
KeyReader.WorkArea.label
in server-side event cases.label
- The LABEL to be set.public static integer getX()
public static integer getY()
public static void setX(NumberType x)
x
- The X attribute.public static void setY(NumberType y)
y
- The Y attribute.public static logical isOnFrameBorder()
YES
if the last event was a mouse event that occurred on a frame border.