Top Description Fields Constructors Methods
org.h2.util

public abstract Class Tool

extends Object
Class Inheritance
Known Direct Subclasses
org.h2.tools.Backup, org.h2.tools.ChangeFileEncryption, org.h2.tools.Console, org.h2.tools.ConvertTraceFile, org.h2.tools.CreateCluster, org.h2.tools.DeleteDbFiles, org.h2.tools.Recover, org.h2.tools.Restore, org.h2.tools.RunScript, org.h2.tools.Script, org.h2.tools.Server, org.h2.tools.Shell
Imports
java.io.ByteArrayInputStream, .IOException, .PrintStream, java.sql.SQLException, java.util.Properties, org.h2.api.ErrorCode, org.h2.message.DbException, org.h2.store.FileLister, org.h2.store.fs.FileUtils

Command line tools implement the tool interface so that they can be used in the H2 Console.

Field Summary

Modifier and TypeField and Description
protected PrintStream
out

The output stream where this tool writes to.

private Properties

Constructor Summary

AccessConstructor and Description
public
Tool()

Method Summary

Modifier and TypeMethod and Description
protected String

Returns:

the name of the main class
getMainClassName
()

Returns main class name of the tool.

public static boolean

Returns:

true if it matches
isOption
(String
the argument
arg
,
String
the command line option
option
)

Check if the argument matches the option.

protected void
printNoDatabaseFilesFound(String
the directory or null
dir
,
String
the database name or null
db
)

Print to the output stream that no database files have been found.

public abstract void
runTool(String...
the argument list
args
)

Run the tool with the given output stream and arguments.

public void
setOut(PrintStream
the new standard output stream
out
)

Sets the standard output stream.

protected void
showUsage()

Print the usage of the tool.

protected SQLException

Returns:

this method never returns normally
showUsageAndThrowUnsupportedOption
(String
the unsupported option
option
)

Throw a SQLException saying this command line option is not supported.

protected SQLException

Returns:

this method never returns normally
throwUnsupportedOption
(String
the unsupported option
option
)

Throw a SQLException saying this command line option is not supported.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

outback to summary
protected PrintStream out

The output stream where this tool writes to.

resourcesback to summary
private Properties resources

Constructor Detail

Toolback to summary
public Tool()

Method Detail

getMainClassNameback to summary
protected String getMainClassName()

Returns main class name of the tool.

Returns:String

the name of the main class

isOptionback to summary
public static boolean isOption(String arg, String option)

Check if the argument matches the option. If the argument starts with this option, but doesn't match, then an exception is thrown.

Parameters
arg:String

the argument

option:String

the command line option

Returns:boolean

true if it matches

printNoDatabaseFilesFoundback to summary
protected void printNoDatabaseFilesFound(String dir, String db)

Print to the output stream that no database files have been found.

Parameters
dir:String

the directory or null

db:String

the database name or null

runToolback to summary
public abstract void runTool(String... args) throws SQLException

Run the tool with the given output stream and arguments.

Parameters
args:String[]

the argument list

Exceptions
SQLException:
on failure
setOutback to summary
public void setOut(PrintStream out)

Sets the standard output stream.

Parameters
out:PrintStream

the new standard output stream

showUsageback to summary
protected void showUsage()

Print the usage of the tool. This method reads the description from the resource file.

showUsageAndThrowUnsupportedOptionback to summary
protected SQLException showUsageAndThrowUnsupportedOption(String option) throws SQLException

Throw a SQLException saying this command line option is not supported.

Parameters
option:String

the unsupported option

Returns:SQLException

this method never returns normally

Exceptions
SQLException:
on failure
throwUnsupportedOptionback to summary
protected SQLException throwUnsupportedOption(String option) throws SQLException

Throw a SQLException saying this command line option is not supported.

Parameters
option:String

the unsupported option

Returns:SQLException

this method never returns normally

Exceptions
SQLException:
on failure