public interface JavaShellToolBuilder
builder()
method. This builder can,
optionally, be configured with the configuration methods. All configuration
methods return the builder instance for use in chained initialization. All
configuration methods have sensible defaults which will be used if they are
not called.. After zero or more calls to configuration methods, the tool is
launched with a call to run(java.lang.String...)
.Modifier and Type | Method | Description |
---|---|---|
static JavaShellToolBuilder |
builder() |
Create a builder for launching the JDK jshell tool.
|
JavaShellToolBuilder |
env(Map<String,String> vars) |
Set the source for environment variables.
|
JavaShellToolBuilder |
err(PrintStream error) |
Set the error channels.
|
JavaShellToolBuilder |
err(PrintStream cmdErr,
PrintStream userErr) |
Set the error channels.
|
JavaShellToolBuilder |
in(InputStream cmdIn,
InputStream userIn) |
Set the input channels.
|
JavaShellToolBuilder |
locale(Locale locale) |
Set the locale.
|
JavaShellToolBuilder |
out(PrintStream output) |
Set the output channels.
|
JavaShellToolBuilder |
out(PrintStream cmdOut,
PrintStream console,
PrintStream userOut) |
Set the output channels.
|
JavaShellToolBuilder |
persistence(Map<String,String> prefsMap) |
Set the storage mechanism for persistent information which includes
input history and retained settings.
|
JavaShellToolBuilder |
persistence(Preferences prefs) |
Set the storage mechanism for persistent information which includes
input history and retained settings.
|
JavaShellToolBuilder |
promptCapture(boolean capture) |
Set to enable a command capturing prompt override.
|
void |
run(String... arguments) |
Run an instance of the Java shell tool as configured by the other methods
in this interface.
|
static JavaShellToolBuilder builder()
JavaShellToolBuilder in(InputStream cmdIn, InputStream userIn)
in(System.in, null)
.cmdIn
- source of command inputuserIn
- source of input for running user code, or null
to
extract user input from cmdInJavaShellToolBuilder
instanceJavaShellToolBuilder out(PrintStream output)
out(output, output, output)
.out
method is called, the behavior should be
equivalent to calling out(System.out)
.output
- destination of command feedback, console interaction, and
user code outputJavaShellToolBuilder
instanceJavaShellToolBuilder out(PrintStream cmdOut, PrintStream console, PrintStream userOut)
out
method is called, the behavior should be
equivalent to calling out(System.out, System.out, System.out)
.cmdOut
- destination of command feedback including error messages
for usersconsole
- destination of console interactionuserOut
- destination of user code output. For example, user snippet
System.out.println("Hello")
when executed Hello
goes to
userOut.JavaShellToolBuilder
instanceJavaShellToolBuilder err(PrintStream error)
err(error, error)
.err
method is called, the behavior should be
equivalent to calling err(System.err)
.error
- destination of tool errors, and
user code errorsJavaShellToolBuilder
instanceJavaShellToolBuilder err(PrintStream cmdErr, PrintStream userErr)
err
method is called, the behavior should be
equivalent to calling err(System.err, System.err, System.err)
.cmdErr
- destination of tool start-up and fatal errorsuserErr
- destination of user code error output.
For example, user snippet System.err.println("Oops")
when executed Oops
goes to userErr.JavaShellToolBuilder
instanceJavaShellToolBuilder persistence(Preferences prefs)
persistence
method is called, the behavior
should be to use the tool's standard persistence mechanism.prefs
- an instance of Preferences
that
is used to retrieve and store persistent informationJavaShellToolBuilder
instanceJavaShellToolBuilder persistence(Map<String,String> prefsMap)
persistence
method is called, the behavior
should be to use the tool's standard persistence mechanism.prefsMap
- an instance of Map
that
is used to retrieve and store persistent informationJavaShellToolBuilder
instanceJavaShellToolBuilder env(Map<String,String> vars)
env(System.getenv())
.vars
- the Map of environment variable names to valuesJavaShellToolBuilder
instanceJavaShellToolBuilder locale(Locale locale)
locale(Locale.getDefault())
.locale
- the localeJavaShellToolBuilder
instanceJavaShellToolBuilder promptCapture(boolean capture)
promptCapture(false)
.capture
- if true
, basic prompt is the ENQ
character and continuation prompt is the ACK
character.
If false, prompts are as set with set-up or user /set
commands.JavaShellToolBuilder
instancevoid run(String... arguments) throws Exception
arguments
- the command-line arguments (including options), if anyException
- an unexpected fatal exception Submit a bug or feature
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 2015, 2017, Oracle and/or its affiliates. 500 Oracle Parkway
Redwood Shores, CA 94065 USA. All rights reserved.
DRAFT 9-Ubuntu+0-9b153-2