Package br.app.pw3270

Class Terminal

java.lang.Object
br.app.pw3270.Terminal
All Implemented Interfaces:
AutoCloseable

public class Terminal extends Object implements AutoCloseable
  • Constructor Details

    • Terminal

      public Terminal()
      Build a headless TN3270 session.
    • Terminal

      public Terminal(String id)
      Build session binded to pw3270's session window.
      Parameters:
      id - pw3270 window id (A: for the first one, B: for second ... )
  • Method Details

    • getVersion

      public static String getVersion()
      Get the current ipc3270 version.
      Returns:
      String with the version of the ipc3270 library.
    • getRevision

      public static String getRevision()
      Get the current ipc3270 revision.
      Returns:
      String with the revision of the ipc3270 library.
    • open

      public void open(String id, 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(String id)
      Open tn3270 session with default charset (UTF-8).
    • close

      public void close()
      Close tn3270 session, release resources.
      Specified by:
      close in interface AutoCloseable
    • connect

      public void connect(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 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 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 String getText()
      Get all terminal contents.
      Returns:
      The terminal contents.
    • getProgramMessage

      public int getProgramMessage()
      Get the current program message id.

      Message IDs
      ValueLib3270 nameDescription
      0LIB3270_MESSAGE_NONENo message
      1LIB3270_MESSAGE_SYSWAIT
      2LIB3270_MESSAGE_TWAIT
      3LIB3270_MESSAGE_CONNECTEDConnected to host
      4LIB3270_MESSAGE_DISCONNECTEDDisconnected from host
      5LIB3270_MESSAGE_AWAITING_FIRST
      6LIB3270_MESSAGE_MINUS
      7LIB3270_MESSAGE_PROTECTED
      8LIB3270_MESSAGE_NUMERIC
      9LIB3270_MESSAGE_OVERFLOW
      10LIB3270_MESSAGE_INHIBIT
      11LIB3270_MESSAGE_KYBDLOCKKeyboard is locked
      12LIB3270_MESSAGE_X
      13LIB3270_MESSAGE_RESOLVINGResolving hostname (running DNS query)
      14LIB3270_MESSAGE_CONNECTINGConnecting to host
      Returns:
      The ProgramMessage value.
    • getConnectionState

      public int getConnectionState()
    • getSSLState

      public int getSSLState()
      Get SSL state.

      SSL States
      ValueState
      0Unsafe
      1Valid CA
      2Invalid CA or self-signed
      3Negotiating
      4Undefined
      Returns:
      State of SSL connection.
    • getKeyboardLockState

      public int getKeyboardLockState()
      Get bitmask with keyboard lock state.

      Lock State flags
      ValueLib3270 idDescription
      0x0000LIB3270_KL_UNLOCKEDKeyboard is unlocked.
      0x0001LIB3270_KL_OERR_PROTECTED
      0x0002LIB3270_KL_OERR_NUMERIC
      0x0003LIB3270_KL_OERR_OVERFLOW
      0x0004LIB3270_KL_OERR_DBCS
      0x0010LIB3270_KL_NOT_CONNECTEDNot connected to host.
      0x0020LIB3270_KL_AWAITING_FIRST
      0x0040LIB3270_KL_OIA_TWAIT
      0x0080LIB3270_KL_OIA_LOCKED
      0x0100LIB3270_KL_DEFERRED_UNLOCK
      0x0200LIB3270_KL_ENTER_INHIBIT
      0x0400LIB3270_KL_SCROLLED
      0x0800LIB3270_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(String chars)
      Test for string in terminal.
      Parameters:
      chars - The string to search.
      Returns:
      true if the terminal contains 'chars'
    • find

      public int find(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(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 String getLib3270Version()
      Get the lib3270 version string.
    • getLib3270Revision

      public String getLib3270Revision()
      Get the lib3270 revision string.
    • getAssociatedLUName

      public String getAssociatedLUName()
      Get the LU name associated with the session, if there is one.
    • getURL

      public String getURL()
    • toString

      public String toString(int baddr, int len)
    • toString

      public String toString(int row, int col, int len)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setURL

      public void setURL(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(String charset)
    • setProperty

      public void setProperty(String name, int value)
    • setProperty

      public void setProperty(String name, boolean value)
    • setProperty

      public void setProperty(String name, String value)
    • setCursorPosition

      public int setCursorPosition(Terminal.CursorPosition position)
    • input

      public int input(String str, char control)
      Input string parsing control char.
      Returns:
      The keyboard lock state.
    • input

      public int input(String str)
      Insert string parsing the action codes prefixed with the defined control character.
      Valid action codes
      ValueActionDescription
      @@PPrint the screen contents (if available)
      @@@@Input the @@ char.
      @@EENTER
      @@FERASE_EOF
      @@1PF1Send the PF1 key.
      @@2PF2Send the PF2 key.
      @@3PF3Send the PF3 key.
      @@4PF4Send the PF4 key.
      @@5PF5Send the PF5 key.
      @@6PF6Send the PF6 key.
      @@7PF7Send the PF7 key.
      @@8PF8Send the PF8 key.
      @@9PF9Send the PF9 key.
      @@aPF10Send the PF10 key.
      @@bPF11Send the PF11 key.
      @@cPF12Send the PF12 key.
      @@dPF13Send the PF13 key.
      @@ePF14Send the PF14 key.
      @@fPF15Send the PF15 key.
      @@gPF16Send the PF16 key.
      @@hPF17Send the PF17 key.
      @@uPF18Send the PF18 key.
      @@jPF19Send the PF19 key.
      @@kPF20Send the PF20 key.
      @@lPF21Send the PF21 key.
      @@mPF22Send the PF22 key.
      @@nPF23Send the PF23 key.
      @@oPF24Send the PF24 key.
      @@xPA1Send the PA1 key.
      @@yPA2Send the PA2 key.
      @@zPA3Send the PA3 key.
      @@DCHAR_DELETE
      @@NNEWLINE
      @@CCLEAR
      @@RKYBD_RESET
      Returns:
      The keyboard lock state.
    • activate

      public void activate(String action)
      Launch a lib3270 action by name.
      Parameters:
      action - The action to activate.
    • activatable

      public boolean activatable(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(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, 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, 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.