Package org.h2.util

Class Tool

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.io.PrintStream out
      The output stream where this tool writes to.
      private java.util.Properties resources  
    • Constructor Summary

      Constructors 
      Constructor Description
      Tool()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean isOption​(java.lang.String arg, java.lang.String option)
      Check if the argument matches the option.
      protected void printNoDatabaseFilesFound​(java.lang.String dir, java.lang.String db)
      Print to the output stream that no database files have been found.
      abstract void runTool​(java.lang.String... args)
      Run the tool with the given output stream and arguments.
      void setOut​(java.io.PrintStream out)
      Sets the standard output stream.
      protected void showUsage()
      Print the usage of the tool.
      protected java.sql.SQLException showUsageAndThrowUnsupportedOption​(java.lang.String option)
      Throw a SQLException saying this command line option is not supported.
      protected java.sql.SQLException throwUnsupportedOption​(java.lang.String option)
      Throw a SQLException saying this command line option is not supported.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • out

        protected java.io.PrintStream out
        The output stream where this tool writes to.
      • resources

        private java.util.Properties resources
    • Constructor Detail

      • Tool

        public Tool()
    • Method Detail

      • setOut

        public void setOut​(java.io.PrintStream out)
        Sets the standard output stream.
        Parameters:
        out - the new standard output stream
      • runTool

        public abstract void runTool​(java.lang.String... args)
                              throws java.sql.SQLException
        Run the tool with the given output stream and arguments.
        Parameters:
        args - the argument list
        Throws:
        java.sql.SQLException - on failure
      • showUsageAndThrowUnsupportedOption

        protected java.sql.SQLException showUsageAndThrowUnsupportedOption​(java.lang.String option)
                                                                    throws java.sql.SQLException
        Throw a SQLException saying this command line option is not supported.
        Parameters:
        option - the unsupported option
        Returns:
        this method never returns normally
        Throws:
        java.sql.SQLException - on failure
      • throwUnsupportedOption

        protected java.sql.SQLException throwUnsupportedOption​(java.lang.String option)
                                                        throws java.sql.SQLException
        Throw a SQLException saying this command line option is not supported.
        Parameters:
        option - the unsupported option
        Returns:
        this method never returns normally
        Throws:
        java.sql.SQLException - on failure
      • printNoDatabaseFilesFound

        protected void printNoDatabaseFilesFound​(java.lang.String dir,
                                                 java.lang.String db)
        Print to the output stream that no database files have been found.
        Parameters:
        dir - the directory or null
        db - the database name or null
      • showUsage

        protected void showUsage()
        Print the usage of the tool. This method reads the description from the resource file.
      • isOption

        public static boolean isOption​(java.lang.String arg,
                                       java.lang.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 - the argument
        option - the command line option
        Returns:
        true if it matches