Package com.iizix.term
Class HostSession
java.lang.Object
com.iizix.term.HostSession
The 3270 or 5250 (or EE) host session.
Constructor Summary
ConstructorDescriptionHostSession
(String id, TerminalProps properties, HostSessionOwner owner) Creates an instance of the host session, but does not connect to the host.Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(HostSessionListener listener) Adds a listener for host session changes.boolean
Checks for connect operation possible, used typically for GUI operations.boolean
Checks for disconnect operation possible, used typically for GUI operations.boolean
Checks for resume operation possible, used typically for GUI operations.boolean
Checks for suspend operation possible, used typically for GUI operations.void
Clears the type-ahead buffer.boolean
connect()
Connects the session.boolean
Disconnects the session.boolean
doesHostNeedFieldExit
(int x, int y, int offset, int length, String string) For 5250 only: checks if a field has the attributes that requires this particular string to enter the data followed by a "Field Exit" or "Field Minus" key.Gets the string of characters that can be input by the user using the configured host code page for this session.void
getCharactersAndAttributes
(char[] chars, int[] attrbs, int beginPos, int endPos) Gets the characters and attributes between two positions, including the end position.void
getCharactersAndAttributes
(char[] chars, int[] attrbs, int beginPos, int endPos, char fieldOrNullChar) Gets the characters and attributes between two positions, including the end position.Gets the current host cursor position.Gets the device name of the session.int
Gets the current screen length (width * height).Gets the host screen size.getID()
Gets the terminal session ID.getInfo()
Gets the info of the Terminal Session.Gets the keyboard remapper for this session.getLastError
(boolean doClear) Gets the last error message of the session.Gets the last communication exception, reset at connect.Gets the listeners.getPeer()
Gets the peer.Gets the terminal properties.Gets the current host screen instance.Gets the screen compressor.Gets the current SessionInfo.int
Gets the host session state.Gets the type of session as a String (3270, 5250, EE [when not connected], EE-3270 or EE-5250 [when EE is connected]).getType()
Gets the terminal type.Gets the worker instance of the session.boolean
hasError()
Checks if there is an error state.boolean
Checks if the keyboard is in insert mode or not.boolean
is3270()
Checks the session type against 3270.boolean
Checks if this is a screen capture or a "real" 3270/5250 session.boolean
Checks for session currently connected.boolean
Flag for session is processing a connect request.boolean
Checks if session is disconnected.boolean
Checks if this host screen is field formatted.boolean
Checks if the host session is locked for keyboard input.boolean
isLocked()
Checks if the host session is locked.boolean
Checks if the session is currently processing data stream commands to update the screen/cursor, state, etc.boolean
Check if the session is current being reconnected (e.g.boolean
Check if the session is current being reconnected (e.g.boolean
Checks if session is suspended.boolean
Checks if type-ahead is enabled for this session.void
onConnectChange
(HostSessionPeer peer, boolean connected) Notifies the session of a connect state change.void
onCursorPositionChange
(HostSessionPeer peer, int x, int y) Notifies the session that the cursor position has changed.void
onFieldChange
(HostSessionPeer peer) Notifies the session that fields have changed.void
onHostDataStreamProcessing
(HostSessionPeer peer, boolean isEntering) Called when entering or exiting data stream processing.void
Called when a host printer needs printing of a new page.void
onScreenChange
(HostSessionPeer peer, int beginPos, int endPos) Notifies the session of a screen change.void
onScreenChange
(RemoteHostSessionListener listener, HostSessionPeer peer, int beginPos, int endPos) Method to update the screen of a RemoteHostScreenListener.void
onScreenSizeChange
(HostSessionPeer peer, int cx, int cy) Notifies the session that the screen size has changed.void
onSessionFailure
(HostSessionPeer peer, Throwable exception) Called when a session has had a failure.void
onStateChange
(HostSessionPeer peer) Notifies the session of a state change (such as insert mode, lock state, error state).boolean
performClear
(int x, int y, int cx, int cy) Performs a clear operation in the terminal screen.performCopy
(int oper, int x, int y, int cx, int cy) Performs a copy operation to a clip board string for terminal screen.performPaste
(String data, boolean byField, boolean doPasteTextWrapping) Performs a paste operation.boolean
Resumes the session.boolean
Suspends or resumes the session.boolean
printSession
(HostSessionPeer peer) Print terminal session.final void
Refreshes the host fields of the current session.void
removeListener
(HostSessionListener listener) Removes a listener for host session changes.void
replaceOwner
(HostSessionOwner owner) Replaces the host session owner for this session.boolean
sendCharacterString
(String keys) Sends character keystrokes to host.boolean
sendCharacterString
(String keys, boolean allowTypeAhead) Sends character keystrokes to host without allowing type-ahead.boolean
sendKey
(int key) Sends keystrokes to host without allowing type-ahead.boolean
sendKey
(int key, boolean allowTypeAhead) Sends keystrokes to host.boolean
sendString
(String keys) Sends character keystrokes to host.boolean
sendString
(String keys, boolean allowTypeAhead) Sends character keystrokes to host.boolean
setCursor
(int x, int y) Sets the host cursor position.boolean
setHostString
(int x, int y, int offset, int length, String string) Sets a string to a host field.boolean
setHostStringAsKeys
(int x, int y, int offset, int length, String string) Sets a string to a host field just as if the user typed the characters.boolean
setInsertMode
(boolean on) Sets the insert mode.void
setLastError
(String errMsg) Sets the last error message of the session.void
soundAlarm
(HostSessionPeer peer) Sound alarm on the client.
Constructor Details
HostSession
Creates an instance of the host session, but does not connect to the host.- Throws:
IOException
- if an I/O error occurs.
Method Details
addListener
Adds a listener for host session changes.- Parameters:
listener
- The host session listener.
removeListener
Removes a listener for host session changes.- Parameters:
listener
- The host session listener.
getListeners
Gets the listeners.getProperties
Gets the terminal properties.getKeyboardRemapper
Gets the keyboard remapper for this session.getType
Gets the terminal type.getStringType
Gets the type of session as a String (3270, 5250, EE [when not connected], EE-3270 or EE-5250 [when EE is connected]).getID
Gets the terminal session ID.is3270
public boolean is3270()Checks the session type against 3270. If no session type is available, 3270 is assumed.isConnected
public boolean isConnected()Checks for session currently connected.isDisconnected
public boolean isDisconnected()Checks if session is disconnected.isConnecting
public boolean isConnecting()Flag for session is processing a connect request.isReconnecting
public boolean isReconnecting()Check if the session is current being reconnected (e.g. to avoid logging of host sessions being established, disconnected).isReconnecting
Check if the session is current being reconnected (e.g. to avoid logging of host sessions being established, disconnected).getLastException
Gets the last communication exception, reset at connect.- Returns:
- The exception, or null for none.
connect
public boolean connect()Connects the session.disconnect
public boolean disconnect()Disconnects the session.sendString
Sends character keystrokes to host.sendString
Sends character keystrokes to host.sendCharacterString
Sends character keystrokes to host.sendCharacterString
Sends character keystrokes to host without allowing type-ahead.isTypeAheadEnabled
public boolean isTypeAheadEnabled()Checks if type-ahead is enabled for this session.sendKey
public boolean sendKey(int key) Sends keystrokes to host without allowing type-ahead.- See Also:
sendKey
public boolean sendKey(int key, boolean allowTypeAhead) Sends keystrokes to host.- See Also:
printSession
Print terminal session.- Returns:
- false if this is not a Java client session, true otherwise.
doesHostNeedFieldExit
For 5250 only: checks if a field has the attributes that requires this particular string to enter the data followed by a "Field Exit" or "Field Minus" key. For 3270 it's always false.setHostString
Sets a string to a host field.setHostStringAsKeys
Sets a string to a host field just as if the user typed the characters. The host field is first cleared with (3270) Clear EOF or (5250) Field Exit or Field Minus (for negative numbers in a numeric field). The string is then entered as a set of keystrokes, followed by a potential Field Exit or Field Minus (for negative numbers in a numeric field), but only for 5250.setCursor
public boolean setCursor(int x, int y) Sets the host cursor position.getCursor
Gets the current host cursor position.getCharactersAndAttributes
public void getCharactersAndAttributes(char[] chars, int[] attrbs, int beginPos, int endPos) Gets the characters and attributes between two positions, including the end position.getCharactersAndAttributes
public void getCharactersAndAttributes(char[] chars, int[] attrbs, int beginPos, int endPos, char fieldOrNullChar) Gets the characters and attributes between two positions, including the end position. The character "fieldOrNullChar" is the character that will be used instead of field attributes and null characters.onScreenChange
Notifies the session of a screen change.onScreenChange
public void onScreenChange(RemoteHostSessionListener listener, HostSessionPeer peer, int beginPos, int endPos) Method to update the screen of a RemoteHostScreenListener.- Parameters:
listener
- The listener to update, or null for all.peer
- The peer.
getScreenCompression
Gets the screen compressor.onFieldChange
Notifies the session that fields have changed.onScreenSizeChange
Notifies the session that the screen size has changed.onCursorPositionChange
Notifies the session that the cursor position has changed.onConnectChange
Notifies the session of a connect state change.onStateChange
Notifies the session of a state change (such as insert mode, lock state, error state).getScreen
Gets the current host screen instance.getHostScreenSize
Gets the host screen size.getHostScreenLength
public int getHostScreenLength()Gets the current screen length (width * height).getSessionState
public int getSessionState()Gets the host session state.- Returns:
- A combination of STATE_* flags is returned.
isLocked
public boolean isLocked()Checks if the host session is locked.isKeyboardInputAllowed
public boolean isKeyboardInputAllowed()Checks if the host session is locked for keyboard input. Keyboard input is allowed for 5250 sessions when in System Request mode or the Attention key is sent.hasError
public boolean hasError()Checks if there is an error state.inInsertMode
public boolean inInsertMode()Checks if the keyboard is in insert mode or not.refreshHostFields
public final void refreshHostFields()Refreshes the host fields of the current session. The host session will add all available host fields sorted left to right, top to bottom.getSessionInfo
Gets the current SessionInfo.soundAlarm
Sound alarm on the client.onSessionFailure
Called when a session has had a failure.getLastError
Gets the last error message of the session.- Returns:
- null if the session doesn't support it (3270 doesn't).
setLastError
Sets the last error message of the session.getDeviceName
Gets the device name of the session.- Returns:
- null if no device name exists.
onHostPrintPage
Called when a host printer needs printing of a new page.getPeer
Gets the peer.Note that manipulation of the peer directly needs synchronization of that object.
clearTypeAhead
public void clearTypeAhead()Clears the type-ahead buffer.setInsertMode
public boolean setInsertMode(boolean on) Sets the insert mode.- Returns:
- true for success, false for failure.
replaceOwner
Replaces the host session owner for this session.isProcessingDataStream
public boolean isProcessingDataStream()Checks if the session is currently processing data stream commands to update the screen/cursor, state, etc.onHostDataStreamProcessing
Called when entering or exiting data stream processing.getAllowedCharacters
Gets the string of characters that can be input by the user using the configured host code page for this session.If the return string is empty, for the EE package for example, all characters are "inputable".
isFieldFormatted
public boolean isFieldFormatted()Checks if this host screen is field formatted. This method is not like the one in HostScreen, this one checks directly to see if any fields are present.getWorker
Gets the worker instance of the session.- Throws:
IOException
performCopy
Performs a copy operation to a clip board string for terminal screen.- Parameters:
oper
- 0=divide by field, 1=by word, 2=data only.x
- The x position.y
- The y position.cx
- The width.cy
- The height.- Returns:
- null if the operation could not be completed due to invalid host session or parameters, otherwise the copied string.
performClear
public boolean performClear(int x, int y, int cx, int cy) Performs a clear operation in the terminal screen.- Returns:
- false if the operation could not be completed due to invalid host session or parameters, true otherwise.
performPaste
Performs a paste operation.- Parameters:
byField
- Flag used only when tabs are in the string.doPasteTextWrapping
- Flag to paste too long text wrapping.- Returns:
- The rest of the clip board data that couldn't be pasted (in order to perform another Continue paste operation), or null for failure.
performSuspend
public boolean performSuspend()Suspends or resumes the session.- Returns:
- true for success, false for failure.
isSuspended
public boolean isSuspended()Checks if session is suspended.performResume
public boolean performResume()Resumes the session.- Returns:
- true for success, false for failure.
canConnect
public boolean canConnect()Checks for connect operation possible, used typically for GUI operations.canSuspend
public boolean canSuspend()Checks for suspend operation possible, used typically for GUI operations.canResume
public boolean canResume()Checks for resume operation possible, used typically for GUI operations.canDisconnect
public boolean canDisconnect()Checks for disconnect operation possible, used typically for GUI operations.isCaptured
public boolean isCaptured()Checks if this is a screen capture or a "real" 3270/5250 session.getInfo
Gets the info of the Terminal Session. The name is either the file name for a capture session or the terminal properties name. The first character is '0'=live 3270/5250, '1'=capture, '2'=recorded.