com.jscape.inet.terminal

## Class Terminal

- java.lang.Object
- - java.util.Observable
  - - com.jscape.inet.terminal.Terminal

- All Implemented Interfaces:
    TelnetListener

      public class Terminal
      extends java.util.Observable
      implements TelnetListener

  Main emulator class. Contains `Telnet` object as low-level transport, `Screen` object as terminal screen, two references to `CharacterSet` objects as G0 and G1 registers of terminal and reference to `CommandSet` object as current command set (ANSI or VT52). Together with `TerminalListener` implements "Observer" pattern ([Gamma94]). In general this class parses incoming characters which may be directed to terminal screen or be interpreted as control character or a part of control sequence. In last two cases `Terminal` class uses current `CommandSet` object to find and execute corresponded command ("Command" pattern [Gamma94]);

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `DEFAULT_NAME`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Terminal(java.lang.String host, int port)` Creates `Terminal` object giving host and port to connect, screen dimensions.
    `Terminal(java.lang.String host, int port, int historySize)` Creates `Terminal` object giving host and port to connect, history size.
    `Terminal(java.lang.String host, int port, int rowNum, int colNum)` Creates `Terminal` object giving host and port to connect, screen dimensions.
    `Terminal(java.lang.String terminalName, java.lang.String host, int port, int rowNum, int colNum, int historySize)` Creates `Terminal` object giving its name, host and port to connect, screen dimensions and history size.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `breakSequence()` Breaks current control sequence.
    `void` | `connect()` Connects to remote host.
    `void` | `connected(TelnetConnectedEvent event)` Handles "connected" event from underlying transport.
    `void` | `dataReceived(TelnetDataReceivedEvent event)` Handles "dataReceived" event from underlying transport.
    `void` | `disconnect()` Disconnects from remote host.
    `void` | `disconnected(TelnetDisconnectedEvent event)` Handles "disconnected" event from underlying transport.
    `void` | `dontOption(DontOptionEvent event)` Handles "dontOption" event from underlying transport.
    `void` | `doOption(DoOptionEvent event)` Handles "doOption" event from underlying transport.
    `void` | `doSubOption(DoSubOptionEvent event)` Handles "doSubOption" event from underlying transport.
    `CellAttributes` | `getCellAttributes()` Returns current screen cell attributes.
    `CharacterSet` | `getCharSet()` Returns current character set which is used to encode incoming characters.
    `CommandSet` | `getCommandSet()` Returns current command set.
    `java.lang.Exception` | `getException()` Returns current exception.
    `CharacterSet` | `getG0()` Returns current character set in G0 register.
    `CharacterSet` | `getG1()` Returns current character set in G1 register.
    `Screen` | `getScreen()` Returns current screen.
    `Screen` | `getScreenCopy()` Returns current screen copy.
    `boolean` | `isAutoWrapMode()` Checks if AutoWrap mode is on.
    `boolean` | `isLNMMode()` Checks if Line Feed/New Line Mode is set.
    `void` | `newSequence()` Performs new control sequence start.
    `void` | `send(char ch)` Sends char to remote host.
    `void` | `send(java.lang.String sequence)` Sends char sequence to remote host.
    `void` | `setAutoWrapMode(boolean autoWrapMode)` Sets AutoWrap mode.
    `void` | `setCellAttributes(CellAttributes attributes)` Sets new screen cell attributes.
    `void` | `setCharSet(CharacterSet charSet)` Sets new character set which is used to encode incoming characters.
    `void` | `setCommandSet(CommandSet commandSet)` Sets new command set.
    `void` | `setG0(CharacterSet g0)` Sets character set to G0 register.
    `void` | `setG1(CharacterSet g1)` Sets character set to G1 register.
    `void` | `setLNMMode(boolean lnmMode)` Sets Line Feed/New Line Mode.
    `void` | `willOption(WillOptionEvent event)` Handles "willOption" event from underlying transport.
    `void` | `wontOption(WontOptionEvent event)` Handles "wontOption" event from underlying transport.

    - ### Methods inherited from class java.util.Observable

      `addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_NAME

          public static final java.lang.String DEFAULT_NAME

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Terminal

          public Terminal(java.lang.String terminalName,
                          java.lang.String host,
                          int port,
                          int rowNum,
                          int colNum,
                          int historySize)

      Creates `Terminal` object giving its name, host and port to connect, screen dimensions and history size.
      Parameters:
        `terminalName` - terminal name.
        `host` - host to connect.
        `port` - port to connect.
        `rowNum` - screen row dimension.
        `colNum` - screen column dimension.
        `historySize` - history size.

    - #### Terminal

          public Terminal(java.lang.String host,
                          int port,
                          int historySize)

      Creates `Terminal` object giving host and port to connect, history size.
      Parameters:
        `host` - host to connect.
        `port` - port to connect.
        `historySize` - history size.

    - #### Terminal

          public Terminal(java.lang.String host,
                          int port,
                          int rowNum,
                          int colNum)

      Creates `Terminal` object giving host and port to connect, screen dimensions.
      Parameters:
        `host` - host to connect.
        `port` - port to connect.
        `rowNum` - screen row dimension.
        `colNum` - screen column dimension.

    - #### Terminal

          public Terminal(java.lang.String host,
                          int port)

      Creates `Terminal` object giving host and port to connect, screen dimensions.
      Parameters:
        `host` - host to connect.
        `port` - port to connect.

  - ### Method Detail

    - #### connect

          public void connect()
                       throws TelnetException

      Connects to remote host.
      Throws:
        `TelnetException` - if underlying transport exception occurs.

    - #### disconnect

          public void disconnect()

      Disconnects from remote host.

    - #### getScreen

          public Screen getScreen()

      Returns current screen.
      Returns:
        current screen.

    - #### getScreenCopy

          public Screen getScreenCopy()

      Returns current screen copy.
      Returns:
        current screen copy.

    - #### getException

          public java.lang.Exception getException()

      Returns current exception.
      Returns:
        current exception.

    - #### getG0

          public CharacterSet getG0()

      Returns current character set in G0 register.
      Returns:
        current character set in G0 register.

    - #### setG0

          public void setG0(CharacterSet g0)

      Sets character set to G0 register.
      Parameters:
        `g0` - new character set for G0 register.

    - #### getG1

          public CharacterSet getG1()

      Returns current character set in G1 register.
      Returns:
        current character set in G1 register.

    - #### setG1

          public void setG1(CharacterSet g1)

      Sets character set to G1 register.
      Parameters:
        `g1` - new character set for G1 register.

    - #### getCharSet

          public CharacterSet getCharSet()

      Returns current character set which is used to encode incoming characters.
      Returns:
        current character set.

    - #### setCharSet

          public void setCharSet(CharacterSet charSet)

      Sets new character set which is used to encode incoming characters.
      Parameters:
        `charSet` - new character set.

    - #### isAutoWrapMode

          public boolean isAutoWrapMode()

      Checks if AutoWrap mode is on.
      Returns:
        true if AutoWrap mode is on.

    - #### setAutoWrapMode

          public void setAutoWrapMode(boolean autoWrapMode)

      Sets AutoWrap mode.
      Parameters:
        `autoWrapMode` - true if AutoWrap mode must be on.

    - #### isLNMMode

          public boolean isLNMMode()

      Checks if Line Feed/New Line Mode is set.
      Returns:
        true if Line Feed/New Line Mode is set.

    - #### setLNMMode

          public void setLNMMode(boolean lnmMode)

      Sets Line Feed/New Line Mode.
      Parameters:
        `lnmMode` -

    - #### getCommandSet

          public CommandSet getCommandSet()

      Returns current command set.
      Returns:
        current command set.

    - #### setCommandSet

          public void setCommandSet(CommandSet commandSet)

      Sets new command set.
      Parameters:
        `commandSet` - new command set.

    - #### send

          public void send(java.lang.String sequence)

      Sends char sequence to remote host.
      Parameters:
        `sequence` - char sequence to be sent.

    - #### send

          public void send(char ch)

      Sends char to remote host.
      Parameters:
        `ch` - char to be sent.

    - #### newSequence

          public void newSequence()

      Performs new control sequence start.

    - #### breakSequence

          public void breakSequence()

      Breaks current control sequence.

    - #### getCellAttributes

          public CellAttributes getCellAttributes()

      Returns current screen cell attributes.
      Returns:
        current screen cell attributes.

    - #### setCellAttributes

          public void setCellAttributes(CellAttributes attributes)

      Sets new screen cell attributes.
      Parameters:
        `attributes` - new screen cell attributes.

    - #### connected

          public void connected(TelnetConnectedEvent event)

      Handles "connected" event from underlying transport.
      Specified by:
        `connected` in interface `TelnetListener`
      Parameters:
        `event` - `TelnetConnectedEvent` event.
      See Also:
        `TelnetConnectedEvent`, `Telnet.connect()`

    - #### disconnected

          public void disconnected(TelnetDisconnectedEvent event)

      Handles "disconnected" event from underlying transport.
      Specified by:
        `disconnected` in interface `TelnetListener`
      Parameters:
        `event` - `TelnetDisconnectedEvent` event.
      See Also:
        `TelnetDisconnectedEvent`, `Telnet.disconnect()`

    - #### doOption

          public void doOption(DoOptionEvent event)

      Handles "doOption" event from underlying transport.
      Specified by:
        `doOption` in interface `TelnetListener`
      Parameters:
        `event` - `DoOptionEvent` event.
      See Also:
        `DoOptionEvent`, `TelnetOption`, `Telnet.sendDontOption(com.jscape.inet.telnet.TelnetOption)`, `Telnet.sendWillOption(com.jscape.inet.telnet.TelnetOption)`

    - #### dontOption

          public void dontOption(DontOptionEvent event)

      Handles "dontOption" event from underlying transport.
      Specified by:
        `dontOption` in interface `TelnetListener`
      Parameters:
        `event` - `DontOptionEvent` event.
      See Also:
        `DontOptionEvent`, `TelnetOption`

    - #### willOption

          public void willOption(WillOptionEvent event)

      Handles "willOption" event from underlying transport.
      Specified by:
        `willOption` in interface `TelnetListener`
      Parameters:
        `event` - `WillOptionEvent` event.
      See Also:
        `WillOptionEvent`, `TelnetOption`, `Telnet.sendDoOption(com.jscape.inet.telnet.TelnetOption)`, `Telnet.sendDontOption(com.jscape.inet.telnet.TelnetOption)`

    - #### wontOption

          public void wontOption(WontOptionEvent event)

      Handles "wontOption" event from underlying transport.
      Specified by:
        `wontOption` in interface `TelnetListener`
      Parameters:
        `event` - `WontOptionEvent` event.
      See Also:
        `WontOptionEvent`, `TelnetOption`

    - #### doSubOption

          public void doSubOption(DoSubOptionEvent event)

      Handles "doSubOption" event from underlying transport.
      Specified by:
        `doSubOption` in interface `TelnetListener`
      Parameters:
        `event` - `DoSubOptionEvent` event.
      See Also:
        `DoSubOptionEvent`, `Telnet.sendOptionSubnegotiation(com.jscape.inet.telnet.TelnetOption)`

    - #### dataReceived

          public void dataReceived(TelnetDataReceivedEvent event)

      Handles "dataReceived" event from underlying transport.
      Specified by:
        `dataReceived` in interface `TelnetListener`
      Parameters:
        `event` - `TelnetDataReceivedEvent` event.
      See Also:
        `TelnetDataReceivedEvent`

Copyright © JSCAPE LLC. 1999-2021. All Rights Reserved