Package com.iizix.term.tn5250e
Class HostSession5250
- java.lang.Object
- com.iizix.term.tn5250e.HostSession5250
- All Implemented Interfaces:
TelnetCommListener
,HostSessionPeer
public class HostSession5250 extends java.lang.Object implements HostSessionPeer, TelnetCommListener
The 5250 host session peer.- Author:
- Christopher Mindus
Field Summary
Fields inherited from interface com.iizix.term.HostSessionPeer
STATE_AnyLock, STATE_Connected, STATE_Connecting, STATE_Error, STATE_FieldFullError, STATE_InsertMode, STATE_Lock, STATE_MessageWaiting, STATE_MinusError, STATE_NonNumericError, STATE_OnFieldOrProtected, STATE_ReceiveWait, STATE_Reconnecting, STATE_Secure, STATE_Sending, STATE_SSCPLUOwned, STATE_SystemAvailable
Constructor Summary
Constructors Constructor Description HostSession5250(HostSession owner, TerminalProps properties)
Constructor only from this package.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
connect()
Connects the session to host.boolean
disconnect()
Disconnects the session from host.boolean
doesFieldHaveExtendedAttributes(HostField hostField)
Checks if a host field has extended attributes or not.boolean
doesHostNeedFieldExit(int x, int y, int offset, int length, java.lang.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.java.lang.String
getAllowedCharacters()
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.int
getClientHostFieldFlags(HostField hostField)
Gets flags that are required for the client host fields for local editing, etc.SocketCommNIO
getComm()
Gets the communication engine.Position
getCursor()
Gets the current host cursor position.java.lang.String
getDeviceName()
Gets the device name of the session.int
getHomeAddress()
Gets the host address index on the screen.HostSession
getHostSession()
Gets the host session owner.java.lang.String
getLastError(boolean doClear)
Gets the last error message of the session.int
getNewCharAttribute(HostField hostField)
Gets the attribute to use for new characters in a field that contains extended attributes (always zero for non-3270).int
getScreenLength()
Gets the current screen length (width * height).Size
getScreenSize()
Gets the current screen size.int
getSessionState()
Gets the current session state.void
hostAcceptedDataStream(TelnetComm comm, java.lang.String terminalType)
The host accepted the options for the terminal type and went into BINARY mode.boolean
is3270()
Checks if a session is 3270 or 5250.boolean
isAutoReconnectSessionEnabled()
Checks if the use of auto reconnect session is handled or not.boolean
isDisplayInSystemRequestMode()
Checks if the display (5250 only) is in System Request mode.boolean
isFieldFormatted()
Checks if this host screen is field formatted.boolean
isPrinter()
Checks if this is a printer or not (always false).boolean
isProcessingDataStream()
Checks if the session is currently processing data stream commands to update the screen/cursor, state, etc.void
onCommClosed(TelnetComm comm)
Called when the communication link is closed.void
onCommConnected(TelnetComm comm)
Called when the communication link is connected.void
onCommError(TelnetComm comm, java.io.IOException e)
Called when the communication link is closed.void
onCommOpen(TelnetComm comm)
Called when the communication link is opened.void
onCommState(SocketCommNIO comm)
Called when the state changes.void
processInboundDataStream(TelnetComm comm, byte[] inputBuf, int pos, int inputBufLen)
Processes the inbound 3270 or 5250 data stream.void
processInboundSCSDataStream(TelnetComm comm, byte[] inputBuf, int inputBufLen)
Processes the inbound 3270 printer data stream.void
processInboundSSCPLUDataStream(TelnetComm comm, byte[] inputBuf, int pos, int inputBufLen)
Processes the inbound 3270 SSCP-LU data stream.void
processPrintEOJ(TelnetComm comm)
Processes a Print End-of-Job for 3270 printers.void
refreshHostFields(HostFields fields)
Refreshes the host fields of the current session.boolean
sendCharacterString(java.lang.String keys)
Sends character keystrokes to host.boolean
sendKey(int key)
Sends character keystrokes to host.boolean
setCursor(int x, int y)
Sets the host cursor position.boolean
setHostField(HostField hostField, java.lang.String data, int[] attrs)
Sets a host field fully with text data and perhaps attributes (if these are non-null).boolean
setHostString(int x, int y, int offset, int length, java.lang.String string)
Sets a string to a host field.boolean
setHostStringAsKeys(int x, int y, int offset, int length, java.lang.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(java.lang.String errMsg)
Sets the last error message of the session.
Constructor Detail
HostSession5250
public HostSession5250(HostSession owner, TerminalProps properties) throws java.io.IOException
Constructor only from this package.- Parameters:
owner
- Owner of session.properties
- The terminal and communication properties.- Throws:
java.io.IOException
- For connection failure.
Method Detail
getHostSession
public HostSession getHostSession()
Gets the host session owner.- Specified by:
getHostSession
in interfaceHostSessionPeer
is3270
public boolean is3270()
Checks if a session is 3270 or 5250.- Specified by:
is3270
in interfaceHostSessionPeer
- Returns:
- false is always 5250.
isProcessingDataStream
public boolean isProcessingDataStream()
Checks if the session is currently processing data stream commands to update the screen/cursor, state, etc.- Specified by:
isProcessingDataStream
in interfaceHostSessionPeer
connect
public boolean connect()
Connects the session to host.- Specified by:
connect
in interfaceHostSessionPeer
disconnect
public boolean disconnect()
Disconnects the session from host.- Specified by:
disconnect
in interfaceHostSessionPeer
sendCharacterString
public boolean sendCharacterString(java.lang.String keys)
Sends character keystrokes to host.- Specified by:
sendCharacterString
in interfaceHostSessionPeer
sendKey
public boolean sendKey(int key)
Sends character keystrokes to host.- Specified by:
sendKey
in interfaceHostSessionPeer
- See Also:
HostSendKeys
setHostString
public boolean setHostString(int x, int y, int offset, int length, java.lang.String string)
Sets a string to a host field.- Specified by:
setHostString
in interfaceHostSessionPeer
setHostStringAsKeys
public boolean setHostStringAsKeys(int x, int y, int offset, int length, java.lang.String string)
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.- Specified by:
setHostStringAsKeys
in interfaceHostSessionPeer
doesHostNeedFieldExit
public boolean doesHostNeedFieldExit(int x, int y, int offset, int length, java.lang.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. For 3270 it's always false.- Specified by:
doesHostNeedFieldExit
in interfaceHostSessionPeer
- Returns:
- false=field doesn't require field exit, true=field requires field exit.
setCursor
public boolean setCursor(int x, int y)
Sets the host cursor position.- Specified by:
setCursor
in interfaceHostSessionPeer
getCursor
public Position getCursor()
Gets the current host cursor position.- Specified by:
getCursor
in interfaceHostSessionPeer
getScreenSize
public Size getScreenSize()
Gets the current screen size.- Specified by:
getScreenSize
in interfaceHostSessionPeer
getScreenLength
public int getScreenLength()
Gets the current screen length (width * height).- Specified by:
getScreenLength
in interfaceHostSessionPeer
getSessionState
public int getSessionState()
Gets the current session state.- Specified by:
getSessionState
in interfaceHostSessionPeer
- Returns:
- A combination of HostSessionPeer.STATE_* flags is returned.
getCharactersAndAttributes
public void getCharactersAndAttributes(char[] chars, int[] attrbs, int beginPos, int endPos)
Gets the characters and attributes between two positions, including the end position.- Specified by:
getCharactersAndAttributes
in interfaceHostSessionPeer
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.- Specified by:
getCharactersAndAttributes
in interfaceHostSessionPeer
refreshHostFields
public void refreshHostFields(HostFields fields)
Refreshes the host fields of the current session. The host session will add all available host fields sorted left to right, top to bottom.- Specified by:
refreshHostFields
in interfaceHostSessionPeer
getLastError
public java.lang.String getLastError(boolean doClear)
Gets the last error message of the session.- Specified by:
getLastError
in interfaceHostSessionPeer
- Returns:
- null if the session doesn't support it (3270 doesn't).
setLastError
public void setLastError(java.lang.String errMsg)
Sets the last error message of the session.- Specified by:
setLastError
in interfaceHostSessionPeer
getDeviceName
public java.lang.String getDeviceName()
Gets the device name of the session.- Specified by:
getDeviceName
in interfaceHostSessionPeer
- Returns:
- null if no device name exists.
isPrinter
public boolean isPrinter()
Checks if this is a printer or not (always false).- Specified by:
isPrinter
in interfaceHostSessionPeer
setInsertMode
public boolean setInsertMode(boolean on)
Sets the insert mode.- Specified by:
setInsertMode
in interfaceHostSessionPeer
- Returns:
- true for success, false for failure.
doesFieldHaveExtendedAttributes
public boolean doesFieldHaveExtendedAttributes(HostField hostField)
Checks if a host field has extended attributes or not. 5250 never has, but 3270 could have, e.g. special highlighting.- Specified by:
doesFieldHaveExtendedAttributes
in interfaceHostSessionPeer
getNewCharAttribute
public int getNewCharAttribute(HostField hostField)
Gets the attribute to use for new characters in a field that contains extended attributes (always zero for non-3270).- Specified by:
getNewCharAttribute
in interfaceHostSessionPeer
getClientHostFieldFlags
public int getClientHostFieldFlags(HostField hostField)
Gets flags that are required for the client host fields for local editing, etc.- Specified by:
getClientHostFieldFlags
in interfaceHostSessionPeer
isAutoReconnectSessionEnabled
public boolean isAutoReconnectSessionEnabled()
Checks if the use of auto reconnect session is handled or not.- Specified by:
isAutoReconnectSessionEnabled
in interfaceHostSessionPeer
getHomeAddress
public int getHomeAddress()
Gets the host address index on the screen.- Specified by:
getHomeAddress
in interfaceHostSessionPeer
setHostField
public boolean setHostField(HostField hostField, java.lang.String data, int[] attrs)
Sets a host field fully with text data and perhaps attributes (if these are non-null).- Specified by:
setHostField
in interfaceHostSessionPeer
- Returns:
- true for success, false for failure.
getAllowedCharacters
public java.lang.String 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".
- Specified by:
getAllowedCharacters
in interfaceHostSessionPeer
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.- Specified by:
isFieldFormatted
in interfaceHostSessionPeer
- Returns:
- true 5250 is always field formatted.
isDisplayInSystemRequestMode
public boolean isDisplayInSystemRequestMode()
Checks if the display (5250 only) is in System Request mode.- Specified by:
isDisplayInSystemRequestMode
in interfaceHostSessionPeer
onCommOpen
public void onCommOpen(TelnetComm comm)
Description copied from interface:TelnetCommListener
Called when the communication link is opened.- Specified by:
onCommOpen
in interfaceTelnetCommListener
- Parameters:
comm
- The telnet communication instance.
onCommConnected
public void onCommConnected(TelnetComm comm)
Description copied from interface:TelnetCommListener
Called when the communication link is connected.- Specified by:
onCommConnected
in interfaceTelnetCommListener
- Parameters:
comm
- The telnet communication instance.
hostAcceptedDataStream
public void hostAcceptedDataStream(TelnetComm comm, java.lang.String terminalType)
Description copied from interface:TelnetCommListener
The host accepted the options for the terminal type and went into BINARY mode. This means that 3270/5250 data stream will follow. Inform the host session listener of a connect change.- Specified by:
hostAcceptedDataStream
in interfaceTelnetCommListener
- Parameters:
comm
- The telnet communication instance.terminalType
- The terminal type accepted by the host at Telnet terminal negotiation.
processInboundDataStream
public void processInboundDataStream(TelnetComm comm, byte[] inputBuf, int pos, int inputBufLen) throws java.io.IOException
Description copied from interface:TelnetCommListener
Processes the inbound 3270 or 5250 data stream.- Specified by:
processInboundDataStream
in interfaceTelnetCommListener
- Parameters:
comm
- The telnet communication instance.inputBuf
- The input buffer.pos
- Start position in buffer.inputBufLen
- Length of input buffer.- Throws:
java.io.IOException
- If an I/O error occurs.
processInboundSCSDataStream
public void processInboundSCSDataStream(TelnetComm comm, byte[] inputBuf, int inputBufLen) throws java.io.IOException
Description copied from interface:TelnetCommListener
Processes the inbound 3270 printer data stream. Processing of the buffer always starts at position 0.- Specified by:
processInboundSCSDataStream
in interfaceTelnetCommListener
- Parameters:
comm
- The telnet communication instance.inputBuf
- The input buffer.inputBufLen
- Length of input buffer.- Throws:
java.io.IOException
- If an I/O error occurs.
processInboundSSCPLUDataStream
public void processInboundSSCPLUDataStream(TelnetComm comm, byte[] inputBuf, int pos, int inputBufLen) throws java.io.IOException
Description copied from interface:TelnetCommListener
Processes the inbound 3270 SSCP-LU data stream.- Specified by:
processInboundSSCPLUDataStream
in interfaceTelnetCommListener
- Parameters:
comm
- The telnet communication instance.inputBuf
- The input buffer.pos
- Start position in buffer.inputBufLen
- Length of input buffer.- Throws:
java.io.IOException
- If an I/O error occurs.
processPrintEOJ
public void processPrintEOJ(TelnetComm comm) throws java.io.IOException
Description copied from interface:TelnetCommListener
Processes a Print End-of-Job for 3270 printers.- Specified by:
processPrintEOJ
in interfaceTelnetCommListener
- Parameters:
comm
- The telnet communication instance.- Throws:
java.io.IOException
- If an I/O error occurs.
onCommError
public void onCommError(TelnetComm comm, java.io.IOException e)
Description copied from interface:TelnetCommListener
Called when the communication link is closed.- Specified by:
onCommError
in interfaceTelnetCommListener
- Parameters:
comm
- The telnet communication instance.e
- The exception.
getComm
public SocketCommNIO getComm()
Gets the communication engine.- Specified by:
getComm
in interfaceHostSessionPeer
- Returns:
- The NIO instance.
onCommState
public void onCommState(SocketCommNIO comm)
Called when the state changes.- Specified by:
onCommState
in interfaceTelnetCommListener
- Parameters:
comm
- Socket communication instance.
onCommClosed
public void onCommClosed(TelnetComm comm)
Description copied from interface:TelnetCommListener
Called when the communication link is closed.- Specified by:
onCommClosed
in interfaceTelnetCommListener
- Parameters:
comm
- The telnet communication instance.