Package br.app.pw3270
Class Terminal
- java.lang.Object
-
- br.app.pw3270.Terminal
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class Terminal extends java.lang.Object implements java.lang.AutoCloseable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
Terminal.Action
class
Terminal.CursorPosition
Cursor position.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
activatable(java.lang.String action)
Test if a lib3270 action is activatable.void
activate(java.lang.String action)
Launch a lib3270 action by name.void
close()
Close tn3270 session, release resources.void
connect(int seconds)
Connect to default 3270 host.void
connect(java.lang.String url, int seconds)
Connect to 3270 host.boolean
contains(java.lang.String chars)
Test for string in terminal.void
disconnect()
Disconnect from tn3270 host.void
enter()
void
erase()
void
erase_eof()
Erase from cursor position until the end of the field.void
erase_eol()
void
erase_input()
int
find(java.lang.String chars)
Find string in the terminal.int
find(java.lang.String chars, int pos)
Find string in the terminal.java.lang.String
getAssociatedLUName()
Get the LU name associated with the session, if there is one.boolean
getConnected()
boolean
getConnected(int timeout)
Get connected state.int
getConnectionState()
int
getCursorAddress()
Terminal.CursorPosition
getCursorPosition()
int
getHeight()
int
getKeyboardLockState()
Get bitmask with keyboard lock state.int
getLength()
java.lang.String
getLib3270Revision()
Get the lib3270 revision string.java.lang.String
getLib3270Version()
Get the lib3270 version string.int
getProgramMessage()
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 java.lang.String
getRevision()
Get the current ipc3270 revision.int
getSSLState()
Get SSL state.java.lang.String
getText()
Get all terminal contents.java.lang.String
getText(int baddr, int len)
Get terminal contents at address.java.lang.String
getText(int row, int col, int len)
Get terminal contents at position.java.lang.String
getURL()
static java.lang.String
getVersion()
Get the current ipc3270 version.int
getWidth()
int
input(java.lang.String str)
Insert string parsing the action codes prefixed with the defined control character.int
input(java.lang.String str, char control)
Input string parsing control char.void
open()
Open headless tn3270 session with default charset (UTF-8).void
open(java.lang.String id)
Open tn3270 session with default charset (UTF-8).void
open(java.lang.String id, java.lang.String charset)
Open tn3270 session.void
pakey(int key)
Send a pakey to host.void
pfkey(int key)
Send a pfkey to host.void
setCharSet(java.lang.String charset)
int
setCursorPosition(int addr)
int
setCursorPosition(int row, int col)
int
setCursorPosition(Terminal.CursorPosition position)
void
setLockOnOperatorError(boolean lock)
void
setProperty(java.lang.String name, boolean value)
void
setProperty(java.lang.String name, int value)
void
setProperty(java.lang.String name, java.lang.String value)
void
setTimeout(int timeout)
void
setUnlockDelay(int delay)
void
setURL(java.lang.String url)
void
sleep(int seconds)
Wait for an specified amount of time.java.lang.String
toString()
java.lang.String
toString(int baddr, int len)
java.lang.String
toString(int row, int col, int len)
void
wait(int seconds)
Wait for terminal negociation.void
wait(int row, int col, java.lang.String text, int seconds)
Wait for text at defined row,colvoid
wait(int baddr, java.lang.String text, int seconds)
Wait for text at defined address.void
wait(java.lang.String text, int seconds)
Wait for an specified string in terminal.
-
-
-
Method Detail
-
getVersion
public static java.lang.String getVersion()
Get the current ipc3270 version.- Returns:
- String with the version of the ipc3270 library.
-
getRevision
public static java.lang.String getRevision()
Get the current ipc3270 revision.- Returns:
- String with the revision of the ipc3270 library.
-
open
public void open(java.lang.String id, java.lang.String charset)
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
public void open(java.lang.String id)
Open tn3270 session with default charset (UTF-8).
-
close
public void close()
Close tn3270 session, release resources.- Specified by:
close
in interfacejava.lang.AutoCloseable
-
connect
public void connect(java.lang.String url, int seconds)
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
public java.lang.String getText(int baddr, int len)
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
public java.lang.String getText(int row, int col, int len)
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
public java.lang.String 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
public Terminal.CursorPosition getCursorPosition()
-
contains
public boolean contains(java.lang.String chars)
Test for string in terminal.- Parameters:
chars
- The string to search.- Returns:
- true if the terminal contains 'chars'
-
find
public int find(java.lang.String chars, int pos)
Find string in the terminal.- Parameters:
chars
- The string to search.pos
- Starting address.- Returns:
- The address of string on terminal.
-
find
public int find(java.lang.String chars)
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
public java.lang.String getLib3270Version()
Get the lib3270 version string.
-
getLib3270Revision
public java.lang.String getLib3270Revision()
Get the lib3270 revision string.
-
getAssociatedLUName
public java.lang.String getAssociatedLUName()
Get the LU name associated with the session, if there is one.
-
getURL
public java.lang.String getURL()
-
toString
public java.lang.String toString(int baddr, int len)
-
toString
public java.lang.String toString(int row, int col, int len)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
setURL
public void setURL(java.lang.String url)
-
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
public void setCharSet(java.lang.String charset)
-
setProperty
public void setProperty(java.lang.String name, int value)
-
setProperty
public void setProperty(java.lang.String name, boolean value)
-
setProperty
public void setProperty(java.lang.String name, java.lang.String value)
-
setCursorPosition
public int setCursorPosition(Terminal.CursorPosition position)
-
input
public int input(java.lang.String str, char control)
Input string parsing control char.- Returns:
- The keyboard lock state.
-
input
public int input(java.lang.String str)
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
public void activate(java.lang.String action)
Launch a lib3270 action by name.- Parameters:
action
- The action to activate.
-
activatable
public boolean activatable(java.lang.String action)
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
public void wait(java.lang.String text, int seconds)
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
public void wait(int baddr, java.lang.String text, int seconds)
Wait for text at defined address.- Parameters:
baddr
- address of string.text
- String to compare.seconds
- Maximum time (in seconds) to wait for.
-
wait
public void wait(int row, int col, java.lang.String text, int seconds)
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.
-
-