PlainConsole (Jython API documentation)
Date: 2017-06-30

org.python.core

## Class PlainConsole

- java.lang.Object
- - org.python.core.PlainConsole

- All Implemented Interfaces:
    Console
  Direct Known Subclasses:
    JLineConsole

      public class PlainConsole
      extends Object
      implements Console

  A base class for classes that can install a console wrapper for a specific console-handling library. The Jython command-line application, when it detects that the console is an interactive session, chooses and installs a class named in registry item `python.console`, and implementing interface `Console`. `PlainConsole` may be selected by the user through that registry, and is the default console when the selected one fails to load. It will also be installed by the Jython command-line application when in non-interactive mode.

  Unlike some consoles, `PlainConsole` does not install a replacement for `System.in` or `System.out`, or use a native library. It prompts on `System.out` and reads from `System.in` (wrapped with the console encoding).

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `String` | `encoding` Encoding to use for line input.
    `Charset` | `encodingCharset` Encoding to use for line input as a `Charset`.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PlainConsole(String encoding)` Construct an instance of the console class specifying the character encoding.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getEncoding()` Name of the encoding, normally supplied during initialisation, and used for line input.
    `Charset` | `getEncodingCharset()` Accessor for encoding to use for line input as a `Charset`.
    `void` | `install()` Complete initialization and (optionally) install a stream object with line-editing as the replacement for `System.in`.
    `void` | `uninstall()` A `PlainConsole` may be uninstalled.

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

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

- - ### Field Detail

    - #### encoding

          public final String encoding

      Encoding to use for line input.

    - #### encodingCharset

          public final Charset encodingCharset

      Encoding to use for line input as a `Charset`.

  - ### Constructor Detail

    - #### PlainConsole

          public PlainConsole(String encoding)
                       throws IllegalCharsetNameException,
                              UnsupportedCharsetException

      Construct an instance of the console class specifying the character encoding. This encoding must be one supported by the JVM. The PlainConsole does not replace `System.in` or `System.out`, and does not add any line-editing capability to what is standard for your OS console.
      Parameters:
        `encoding` - name of a supported encoding or `null` for `Charset.defaultCharset()`
      Throws:
        `IllegalCharsetNameException`
        `UnsupportedCharsetException`

  - ### Method Detail

    - #### install

          public void install()

      Description copied from interface: `Console`
      Complete initialization and (optionally) install a stream object with line-editing as the replacement for `System.in`.
      Specified by:
        `install` in interface `Console`

    - #### uninstall

          public void uninstall()
                         throws UnsupportedOperationException

      A `PlainConsole` may be uninstalled. This method assumes any sub-class may not be uninstalled. Sub-classes that permit themselves to be uninstalled must override (and not call) this method.
      Specified by:
        `uninstall` in interface `Console`
      Throws:
        `UnsupportedOperationException` - unless this class is exactly `PlainConsole`

    - #### getEncoding

          public String getEncoding()

      Description copied from interface: `Console`
      Name of the encoding, normally supplied during initialisation, and used for line input. This may not be the cononoical name of the codec returned by `Console.getEncodingCharset()`.
      Specified by:
        `getEncoding` in interface `Console`
      Returns:
        name of the encoding in use.

    - #### getEncodingCharset

          public Charset getEncodingCharset()

      Description copied from interface: `Console`
      Accessor for encoding to use for line input as a `Charset`.
      Specified by:
        `getEncodingCharset` in interface `Console`
      Returns:
        Charset of the encoding in use.

Jython homepage