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).

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final String
    Encoding to use for line input.
    final Charset
    Encoding to use for line input as a Charset.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PlainConsole(String encoding)
    Construct an instance of the console class specifying the character encoding.
  • Method Summary

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

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • 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 Details

  • Method Details

    • 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.