Package br.app.pw3270
Class Terminal
java.lang.Object
br.app.pw3270.Terminal
- All Implemented Interfaces:
AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
class
Cursor position. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
activatable
(String action) Test if a lib3270 action is activatable.void
Launch a lib3270 action by name.void
close()
Close tn3270 session, release resources.void
connect
(int seconds) Connect to default 3270 host.void
Connect to 3270 host.boolean
Test for string in terminal.void
Disconnect from tn3270 host.void
enter()
void
erase()
void
Erase from cursor position until the end of the field.void
void
int
Find string in the terminal.int
Find string in the terminal.Get the LU name associated with the session, if there is one.boolean
boolean
getConnected
(int timeout) Get connected state.int
int
int
int
Get bitmask with keyboard lock state.int
Get the lib3270 revision string.Get the lib3270 version string.int
Get the current program message id.boolean
getReady()
Check if terminal is ready to receive inputs.boolean
getReady
(int timeout) Get 'readyness' of terminal.static String
Get the current ipc3270 revision.int
Get SSL state.getText()
Get all terminal contents.getText
(int baddr, int len) Get terminal contents at address.getText
(int row, int col, int len) Get terminal contents at position.getURL()
static String
Get the current ipc3270 version.int
getWidth()
int
Insert string parsing the action codes prefixed with the defined control character.int
Input string parsing control char.void
open()
Open headless tn3270 session with default charset (UTF-8).void
Open tn3270 session with default charset (UTF-8).void
Open tn3270 session.void
pakey
(int key) Send a pakey to host.void
pfkey
(int key) Send a pfkey to host.void
setCharSet
(String charset) int
setCursorPosition
(int addr) int
setCursorPosition
(int row, int col) int
setCursorPosition
(Terminal.CursorPosition position) void
setLockOnOperatorError
(boolean lock) void
setProperty
(String name, boolean value) void
setProperty
(String name, int value) void
setProperty
(String name, String value) void
setTimeout
(int timeout) void
setUnlockDelay
(int delay) void
void
sleep
(int seconds) Wait for an specified amount of time.toString()
toString
(int baddr, int len) toString
(int row, int col, int len) void
wait
(int seconds) Wait for terminal negociation.void
Wait for text at defined row,colvoid
Wait for text at defined address.void
Wait for an specified string in terminal.
-
Constructor Details
-
Terminal
public Terminal()Build a headless TN3270 session. -
Terminal
Build session binded to pw3270's session window.- Parameters:
id
- pw3270 window id (A: for the first one, B: for second ... )
-
-
Method Details
-
getVersion
Get the current ipc3270 version.- Returns:
- String with the version of the ipc3270 library.
-
getRevision
Get the current ipc3270 revision.- Returns:
- String with the revision of the ipc3270 library.
-
open
Open tn3270 session.- Parameters:
id
- Session ID ("" for headless).charset
- Local charset.
-
open
public void open()Open headless tn3270 session with default charset (UTF-8). -
open
Open tn3270 session with default charset (UTF-8). -
close
public void close()Close tn3270 session, release resources.- Specified by:
close
in interfaceAutoCloseable
-
connect
Connect to 3270 host.Connect to the 3270 host
URI formats:
- tn3270://[HOSTNAME]:[HOSTPORT] for non SSL connections.
- tn3270s://[HOSTNAME]:[HOSTPORT] for ssl connection.
- Parameters:
url
- Host URL.seconds
- How many seconds to wait for a connection.
-
connect
public void connect(int seconds) Connect to default 3270 host.When using a GUI session this connected to the session defined tn3270 host.
- Parameters:
seconds
- How many seconds to wait for a connection.
-
disconnect
public void disconnect()Disconnect from tn3270 host. -
getText
Get terminal contents at address.- Parameters:
baddr
- address of string to get.len
- length of string to get.- Returns:
- String at address with length chars.
-
getText
Get terminal contents at position.- Parameters:
row
- row of the string start.col
- column of the string start.len
- length of string to get.- Returns:
- String at position with length chars.
-
getText
Get all terminal contents.- Returns:
- The terminal contents.
-
getProgramMessage
public int getProgramMessage()Get the current program message id.Message IDs Value Lib3270 name Description 0 LIB3270_MESSAGE_NONE No message 1 LIB3270_MESSAGE_SYSWAIT 2 LIB3270_MESSAGE_TWAIT 3 LIB3270_MESSAGE_CONNECTED Connected to host 4 LIB3270_MESSAGE_DISCONNECTED Disconnected from host 5 LIB3270_MESSAGE_AWAITING_FIRST 6 LIB3270_MESSAGE_MINUS 7 LIB3270_MESSAGE_PROTECTED 8 LIB3270_MESSAGE_NUMERIC 9 LIB3270_MESSAGE_OVERFLOW 10 LIB3270_MESSAGE_INHIBIT 11 LIB3270_MESSAGE_KYBDLOCK Keyboard is locked 12 LIB3270_MESSAGE_X 13 LIB3270_MESSAGE_RESOLVING Resolving hostname (running DNS query) 14 LIB3270_MESSAGE_CONNECTING Connecting to host - Returns:
- The ProgramMessage value.
-
getConnectionState
public int getConnectionState() -
getSSLState
public int getSSLState()Get SSL state.SSL States Value State 0 Unsafe 1 Valid CA 2 Invalid CA or self-signed 3 Negotiating 4 Undefined - Returns:
- State of SSL connection.
-
getKeyboardLockState
public int getKeyboardLockState()Get bitmask with keyboard lock state.Lock State flags Value Lib3270 id Description 0x0000 LIB3270_KL_UNLOCKED Keyboard is unlocked. 0x0001 LIB3270_KL_OERR_PROTECTED 0x0002 LIB3270_KL_OERR_NUMERIC 0x0003 LIB3270_KL_OERR_OVERFLOW 0x0004 LIB3270_KL_OERR_DBCS 0x0010 LIB3270_KL_NOT_CONNECTED Not connected to host. 0x0020 LIB3270_KL_AWAITING_FIRST 0x0040 LIB3270_KL_OIA_TWAIT 0x0080 LIB3270_KL_OIA_LOCKED 0x0100 LIB3270_KL_DEFERRED_UNLOCK 0x0200 LIB3270_KL_ENTER_INHIBIT 0x0400 LIB3270_KL_SCROLLED 0x0800 LIB3270_KL_OIA_MINUS - Returns:
- The value of keyboard lock state.
-
getWidth
public int getWidth() -
getHeight
public int getHeight() -
getLength
public int getLength() -
getCursorAddress
public int getCursorAddress() -
getCursorPosition
-
contains
Test for string in terminal.- Parameters:
chars
- The string to search.- Returns:
- true if the terminal contains 'chars'
-
find
Find string in the terminal.- Parameters:
chars
- The string to search.pos
- Starting address.- Returns:
- The address of string on terminal.
-
find
Find string in the terminal.- Parameters:
chars
- The string to search.- Returns:
- The address of string on terminal.
-
getConnected
public boolean getConnected(int timeout) Get connected state.- Parameters:
timeout
- Time to wait for state (0 = no wait).- Returns:
- true if the terminal is connected.
-
getConnected
public boolean getConnected() -
getReady
public boolean getReady(int timeout) Get 'readyness' of terminal.- Parameters:
timeout
- Time to wait for 'ready' state (0 = no wait).- Returns:
- true if the terminal is ready.
-
getReady
public boolean getReady()Check if terminal is ready to receive inputs.- Returns:
- true if the terminal is ready.
-
getLib3270Version
Get the lib3270 version string. -
getLib3270Revision
Get the lib3270 revision string. -
getAssociatedLUName
Get the LU name associated with the session, if there is one. -
getURL
-
toString
-
toString
-
toString
-
setURL
-
setUnlockDelay
public void setUnlockDelay(int delay) -
setTimeout
public void setTimeout(int timeout) -
setLockOnOperatorError
public void setLockOnOperatorError(boolean lock) -
setCursorPosition
public int setCursorPosition(int addr) -
setCursorPosition
public int setCursorPosition(int row, int col) -
setCharSet
-
setProperty
-
setProperty
-
setProperty
-
setCursorPosition
-
input
Input string parsing control char.- Returns:
- The keyboard lock state.
-
input
Insert string parsing the action codes prefixed with the defined control character.Valid action codes Value Action Description @@P Print the screen contents (if available) @@@@ Input the @@ char. @@E ENTER @@F ERASE_EOF @@1 PF1 Send the PF1 key. @@2 PF2 Send the PF2 key. @@3 PF3 Send the PF3 key. @@4 PF4 Send the PF4 key. @@5 PF5 Send the PF5 key. @@6 PF6 Send the PF6 key. @@7 PF7 Send the PF7 key. @@8 PF8 Send the PF8 key. @@9 PF9 Send the PF9 key. @@a PF10 Send the PF10 key. @@b PF11 Send the PF11 key. @@c PF12 Send the PF12 key. @@d PF13 Send the PF13 key. @@e PF14 Send the PF14 key. @@f PF15 Send the PF15 key. @@g PF16 Send the PF16 key. @@h PF17 Send the PF17 key. @@u PF18 Send the PF18 key. @@j PF19 Send the PF19 key. @@k PF20 Send the PF20 key. @@l PF21 Send the PF21 key. @@m PF22 Send the PF22 key. @@n PF23 Send the PF23 key. @@o PF24 Send the PF24 key. @@x PA1 Send the PA1 key. @@y PA2 Send the PA2 key. @@z PA3 Send the PA3 key. @@D CHAR_DELETE @@N NEWLINE @@C CLEAR @@R KYBD_RESET - Returns:
- The keyboard lock state.
-
activate
Launch a lib3270 action by name.- Parameters:
action
- The action to activate.
-
activatable
Test if a lib3270 action is activatable.- Parameters:
action
- Name of the action.- Returns:
- true if the action can be activated.
-
pfkey
public void pfkey(int key) Send a pfkey to host.- Parameters:
key
- PFkey number.
-
pakey
public void pakey(int key) Send a pakey to host.- Parameters:
key
- PAkey number.
-
enter
public void enter() -
erase
public void erase() -
erase_eol
public void erase_eol() -
erase_input
public void erase_input() -
erase_eof
public void erase_eof()Erase from cursor position until the end of the field. -
sleep
public void sleep(int seconds) Wait for an specified amount of time.Wait for the specified time keeping the main loop active.
- Parameters:
seconds
- Number of seconds to wait.
-
wait
Wait for an specified string in terminal.- Parameters:
text
- The string to wait.seconds
- How many seconds to wait for text to appear.
-
wait
public void wait(int seconds) Wait for terminal negociation.Wait on a loop until the terminal contents are ready for reading.
- Parameters:
seconds
- Maximum time (in seconds) to wait for.
-
wait
Wait for text at defined address.- Parameters:
baddr
- address of string.text
- String to compare.seconds
- Maximum time (in seconds) to wait for.
-
wait
Wait for text at defined row,col- Parameters:
row
- Row for text to compare.col
- Column for text to compare.text
- String to compare.seconds
- Maximum time (in seconds) to wait for.
-