Package org.python.core
Class PlainConsole
- java.lang.Object
-
- org.python.core.PlainConsole
-
- All Implemented Interfaces:
Console
- Direct Known Subclasses:
JLineConsole
public class PlainConsole extends java.lang.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 itempython.console
, and implementing interfaceConsole
.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 forSystem.in
orSystem.out
, or use a native library. It prompts onSystem.out
and reads fromSystem.in
(wrapped with the console encoding).
-
-
Field Summary
Fields Modifier and Type Field Description java.lang.String
encoding
Encoding to use for line input.java.nio.charset.Charset
encodingCharset
Encoding to use for line input as aCharset
.
-
Constructor Summary
Constructors Constructor Description PlainConsole(java.lang.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 Description java.lang.String
getEncoding()
Name of the encoding, normally supplied during initialisation, and used for line input.java.nio.charset.Charset
getEncodingCharset()
Accessor for encoding to use for line input as aCharset
.void
install()
Complete initialization and (optionally) install a stream object with line-editing as the replacement forSystem.in
.void
uninstall()
APlainConsole
may be uninstalled.
-
-
-
Constructor Detail
-
PlainConsole
public PlainConsole(java.lang.String encoding) throws java.nio.charset.IllegalCharsetNameException, java.nio.charset.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 replaceSystem.in
orSystem.out
, and does not add any line-editing capability to what is standard for your OS console.- Parameters:
encoding
- name of a supported encoding ornull
forCharset.defaultCharset()
- Throws:
java.nio.charset.IllegalCharsetNameException
java.nio.charset.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 forSystem.in
.
-
uninstall
public void uninstall() throws java.lang.UnsupportedOperationException
APlainConsole
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.
-
getEncoding
public java.lang.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 byConsole.getEncodingCharset()
.- Specified by:
getEncoding
in interfaceConsole
- Returns:
- name of the encoding in use.
-
getEncodingCharset
public java.nio.charset.Charset getEncodingCharset()
Description copied from interface:Console
Accessor for encoding to use for line input as aCharset
.- Specified by:
getEncodingCharset
in interfaceConsole
- Returns:
- Charset of the encoding in use.
-
-