Package br.app.pw3270

Class Terminal

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class Terminal
    extends java.lang.Object
    implements java.lang.AutoCloseable
    • Constructor Summary

      Constructors 
      Constructor Description
      Terminal()
      Build a headless TN3270 session.
      Terminal​(java.lang.String id)
      Build session binded to pw3270's session window.
    • 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,col
      void 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Terminal

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

        public Terminal​(java.lang.String id)
        Build session binded to pw3270's session window.
        Parameters:
        id - pw3270 window id (A: for the first one, B: for second ... )
    • 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 interface java.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
        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()
      • 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 class java.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)
      • 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
        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​(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.