Package org.python.core
Class PlainConsole
java.lang.Object
org.python.core.PlainConsole
- All Implemented Interfaces:
Console
- Direct Known Subclasses:
JLineConsole
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
-
Constructor Summary
ConstructorDescriptionPlainConsole
(String encoding) Construct an instance of the console class specifying the character encoding. -
Method Summary
Modifier and TypeMethodDescriptionName of the encoding, normally supplied during initialisation, and used for line input.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
APlainConsole
may be uninstalled.
-
Field Details
-
encoding
Encoding to use for line input. -
encodingCharset
Encoding to use for line input as aCharset
.
-
-
Constructor Details
-
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 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:
IllegalCharsetNameException
UnsupportedCharsetException
-
-
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 forSystem.in
. -
uninstall
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.- Specified by:
uninstall
in interfaceConsole
- Throws:
UnsupportedOperationException
- unless this class is exactlyPlainConsole
-
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
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.
-