com.jscape.inet.telnet

## Class TelnetOption

- java.lang.Object
- - com.jscape.inet.telnet.TelnetOption

- All Implemented Interfaces:
    java.lang.Cloneable
  Direct Known Subclasses:
    Binary, TerminalType, TimingMark

      public class TelnetOption
      extends java.lang.Object
      implements java.lang.Cloneable

  TelnetOption class enables developers to implement and use existing and future telnet protocol options. The framework is specified in RFC 855 and standard options are specified in separate RFC documents.

  Notes for subclassing:
  For some options (i.e. ECHO or BINARY), it is enough to pass an option code to the constructor to be able to use it. Many options, however, use subnegotiation and the TelnetOption class should be subclassed. For those options requiring subnegotiation the option class should set `optionCode` in constructor and override methods `readSubnegotation` and `writeSubnegotiation` for formatting/parsing option specific data.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TelnetOption(int optionCode)` Creates a new TelnetOption instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getOptionCode()` Gets option code.
    `java.lang.String` | `getOptionName()` Gets name of this option based on its option code.
    `void` | `readSubnegotiation(java.io.InputStream in)` Reads subnegotiation data for this TelnetOption By default this method is empty and and is intended for use in subclasses requiring option negotiation.
    `void` | `writeSubnegotiation(java.io.OutputStream out)` Writes subnegotiation data for this TelnetOption.

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

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

- - ### Constructor Detail

    - #### TelnetOption

          public TelnetOption(int optionCode)

      Creates a new TelnetOption instance.

      The optionCode parameter identifies the option code for this Telnet option. For a list of valid option codes please consult the Telnet RFCs. Some examples of valid option codes include the following:

      0 - BINARY
      Negotiates transmission of binary data
      1 - ECHO
      Negotiates echoing of data exchanged
      24 - TERMINAL TYPE
      Negotiates terminal display options

      Parameters:
        `optionCode` - the option code

  - ### Method Detail

    - #### getOptionCode

          public int getOptionCode()

      Gets option code.
      Returns:
        option code

    - #### writeSubnegotiation

          public void writeSubnegotiation(java.io.OutputStream out)
                                   throws java.io.IOException

      Writes subnegotiation data for this TelnetOption. By default this method is empty and and is intended for use in subclasses requiring option negotiation.
      Parameters:
        `out` - the OutputStream to write data to.
      Throws:
        `java.io.IOException` - if an I/O related error occurs.

    - #### readSubnegotiation

          public void readSubnegotiation(java.io.InputStream in)
                                  throws java.io.IOException

      Reads subnegotiation data for this TelnetOption By default this method is empty and and is intended for use in subclasses requiring option negotiation.
      Parameters:
        `in` - the InputStream to read from
      Throws:
        `java.io.IOException` - if an I/O related error occurs

    - #### getOptionName

          public java.lang.String getOptionName()

      Gets name of this option based on its option code.
      Returns:
        option name or null if name cannot be found

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