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.PlainConsolemay 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,
PlainConsoledoes not install a replacement forSystem.inorSystem.out, or use a native library. It prompts onSystem.outand reads fromSystem.in(wrapped with the console encoding).- See Also:
RegistryKey.PYTHON_CONSOLE
-
-
Field Summary
Fields Modifier and Type Field Description java.lang.StringencodingEncoding to use for line input.java.nio.charset.CharsetencodingCharsetEncoding 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.StringgetEncoding()Name of the encoding, normally supplied during initialisation, and used for line input.java.nio.charset.CharsetgetEncodingCharset()Accessor for encoding to use for line input as aCharset.voidinstall()Complete initialization and (optionally) install a stream object with line-editing as the replacement forSystem.in.voiduninstall()APlainConsolemay be uninstalled.
-
-
-
Constructor Detail
-
PlainConsole
public PlainConsole(java.lang.String encoding) throws java.nio.charset.IllegalCharsetNameException, java.nio.charset.UnsupportedCharsetExceptionConstruct an instance of the console class specifying the character encoding. This encoding must be one supported by the JVM. The PlainConsole does not replaceSystem.inorSystem.out, and does not add any line-editing capability to what is standard for your OS console.- Parameters:
encoding- name of a supported encoding ornullforCharset.defaultCharset()- Throws:
java.nio.charset.IllegalCharsetNameExceptionjava.nio.charset.UnsupportedCharsetException
-
-
Method Detail
-
install
public void install()
Description copied from interface:ConsoleComplete initialization and (optionally) install a stream object with line-editing as the replacement forSystem.in.
-
uninstall
public void uninstall() throws java.lang.UnsupportedOperationExceptionAPlainConsolemay 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:ConsoleName 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:
getEncodingin interfaceConsole- Returns:
- name of the encoding in use.
-
getEncodingCharset
public java.nio.charset.Charset getEncodingCharset()
Description copied from interface:ConsoleAccessor for encoding to use for line input as aCharset.- Specified by:
getEncodingCharsetin interfaceConsole- Returns:
- Charset of the encoding in use.
-
-