public class SqlLine extends Object
TODO:
Modifier and Type | Class and Description |
---|---|
static class |
SqlLine.Status
Exit status returned to the operating system.
|
Modifier and Type | Field and Description |
---|---|
static String |
COMMAND_PREFIX |
static String |
SQLLINE_BASE_DIR |
Constructor and Description |
---|
SqlLine() |
Modifier and Type | Method and Description |
---|---|
SqlLine.Status |
begin(String[] args,
InputStream inputStream,
boolean saveHistory)
Runs SQLLine, accepting input from the given input stream,
dispatching it to the appropriate
CommandHandler until the global variable exit is
true. |
void |
debug(String msg) |
boolean |
error(String msg)
Issue the specified error message
|
boolean |
error(Throwable t) |
jline.console.completer.Completer |
getCommandCompleter() |
Collection<CommandHandler> |
getCommandHandlers() |
jline.console.ConsoleReader |
getConsoleReader(InputStream inputStream,
jline.console.history.FileHistory fileHistory) |
SqlLineOpts |
getOpts() |
Map<String,OutputFormat> |
getOutputFormats() |
sqlline.Reflector |
getReflector() |
static String |
getSeparator() |
void |
handleException(Throwable e) |
void |
info(sqlline.ColorBuffer msg) |
void |
info(String msg) |
boolean |
isExit() |
static void |
main(String[] args)
Starts the program.
|
static SqlLine.Status |
mainWithInputRedirection(String[] args,
InputStream inputStream)
Starts the program with redirected input.
|
void |
output(sqlline.ColorBuffer msg) |
void |
output(sqlline.ColorBuffer msg,
boolean newline) |
void |
output(sqlline.ColorBuffer msg,
boolean newline,
PrintStream out) |
void |
output(String msg)
Print the specified message to the console
|
void |
output(String msg,
boolean newline)
Print the specified message to the console
|
void |
output(String msg,
boolean newline,
PrintStream out) |
int |
runCommands(List<String> cmds,
DispatchCallback callback) |
void |
setErrorStream(PrintStream errorStream) |
void |
setExit(boolean exit) |
void |
setOutputStream(PrintStream outputStream) |
String[] |
split(String line,
String delim,
int limit) |
String[][] |
splitCompound(String line)
Splits the line into an array of possibly-compound identifiers, observing
the database's quoting syntax.
|
static SqlLine.Status |
start(String[] args,
InputStream inputStream,
boolean saveHistory)
Backwards compatibility method to allow
mainWithInputRedirection(String[], java.io.InputStream) proxied
calls to keep method signature but add in new behavior of not saving
queries. |
void |
updateCommandHandlers(Collection<CommandHandler> commandHandlers) |
void |
updateOutputFormats(Map<String,OutputFormat> formats) |
public static final String COMMAND_PREFIX
public static final String SQLLINE_BASE_DIR
public static void main(String[] args) throws IOException
args
- Arguments specified on the command-lineIOException
- on errorpublic static SqlLine.Status mainWithInputRedirection(String[] args, InputStream inputStream) throws IOException
For redirected output, use setOutputStream(java.io.PrintStream)
and
setErrorStream(java.io.PrintStream)
.
Exits with 0 on success, 1 on invalid arguments, and 2 on any other error.
args
- same as main()inputStream
- redirected input, or null to use standard inputIOException
- on errorpublic static SqlLine.Status start(String[] args, InputStream inputStream, boolean saveHistory) throws IOException
mainWithInputRedirection(String[], java.io.InputStream)
proxied
calls to keep method signature but add in new behavior of not saving
queries.args
- args[] passed in directly from main(String[])
inputStream
- Stream to read sql commands from (stdin or a file) or
null for an interactive shellsaveHistory
- Whether to save the commands issued to SQLLine's history
fileIOException
- if SQLLine cannot obtain
history file or start console readerpublic SqlLine.Status begin(String[] args, InputStream inputStream, boolean saveHistory) throws IOException
CommandHandler
until the global variable exit
is
true.
Before you invoke this method, you can redirect output by
calling setOutputStream(PrintStream)
and/or setErrorStream(PrintStream)
.
args
- Command-line argumentsinputStream
- Input streamsaveHistory
- Whether to save the commands issued to SQLLine's history
fileIOException
- if SQLLine cannot obtain
history file or start console readerpublic jline.console.ConsoleReader getConsoleReader(InputStream inputStream, jline.console.history.FileHistory fileHistory) throws IOException
IOException
public void output(String msg)
msg
- the message to printpublic void info(String msg)
public void info(sqlline.ColorBuffer msg)
public boolean error(String msg)
msg
- the message to issuepublic boolean error(Throwable t)
public void debug(String msg)
public void output(sqlline.ColorBuffer msg)
public void output(String msg, boolean newline, PrintStream out)
public void output(sqlline.ColorBuffer msg, boolean newline)
public void output(sqlline.ColorBuffer msg, boolean newline, PrintStream out)
public void output(String msg, boolean newline)
msg
- the message to printnewline
- if false, do not append a newlinepublic String[][] splitCompound(String line)
For example, on Oracle, which uses double-quote (") as quote character,
!tables "My Schema"."My Table"
returns
{ {"!tables"}, {"My Schema", "My Table"} }
line
- the line to break uppublic void handleException(Throwable e)
public int runCommands(List<String> cmds, DispatchCallback callback)
public SqlLineOpts getOpts()
public boolean isExit()
public void setExit(boolean exit)
public static String getSeparator()
public void setOutputStream(PrintStream outputStream)
public void setErrorStream(PrintStream errorStream)
public sqlline.Reflector getReflector()
public jline.console.completer.Completer getCommandCompleter()
public Collection<CommandHandler> getCommandHandlers()
public void updateCommandHandlers(Collection<CommandHandler> commandHandlers)
public Map<String,OutputFormat> getOutputFormats()
public void updateOutputFormats(Map<String,OutputFormat> formats)
Copyright © 2002–2018 Julian Hyde. All rights reserved.