Class Util

java.lang.Object
org.basex.util.Util

public final class Util extends Object
This class contains static methods, which are used throughout the project. The methods are used for dumping error output, debugging information, getting the application path, etc.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Method Details

    • bug

      public static String bug(Throwable throwable)
      Returns an information string for an unexpected exception.
      Parameters:
      throwable - exception
      Returns:
      dummy object
    • notExpected

      public static RuntimeException notExpected()
      Throws a runtime exception for an unexpected exception.
      Returns:
      runtime exception (indicates that an error is raised)
    • notExpected

      public static RuntimeException notExpected(Object message, Object... ext)
      Throws a runtime exception for an unexpected exception.
      Parameters:
      message - message
      ext - optional extension
      Returns:
      runtime exception (indicates that an error is raised)
    • className

      public static String className(Object object)
      Returns the class name of the specified object, excluding its path.
      Parameters:
      object - object
      Returns:
      class name
    • className

      public static String className(Class<?> clazz)
      Returns the name of the specified class, excluding its path.
      Parameters:
      clazz - class
      Returns:
      class name
    • input

      public static String input()
      Returns a single line from standard input.
      Returns:
      string
    • password

      public static String password()
      Returns a password from standard input.
      Returns:
      password or empty string
    • outln

      public static void outln()
      Prints a newline to standard output.
    • outln

      public static void outln(Object string, Object... ext)
      Prints a string to standard output, followed by a newline.
      Parameters:
      string - output string
      ext - text optional extensions
    • out

      public static void out(Object string, Object... ext)
      Prints a string to standard output.
      Parameters:
      string - output string
      ext - text optional extensions
    • rootException

      public static Throwable rootException(Throwable throwable)
      Returns the root query exception.
      Parameters:
      throwable - throwable
      Returns:
      root exception
    • errln

      public static void errln(Object object, Object... ext)
      Prints a string to standard error, followed by a newline.
      Parameters:
      object - error object
      ext - text optional extensions
    • err

      public static void err(String string, Object... ext)
      Prints a string to standard error.
      Parameters:
      string - debug string
      ext - text optional extensions
    • message

      public static String message(Throwable throwable)
      Returns a more user-friendly error message for the specified exception.
      Parameters:
      throwable - throwable reference
      Returns:
      error message
    • debug

      public static void debug(Throwable throwable)
      Prints the exception stack trace if the Prop.debug flag is set.
      Parameters:
      throwable - exception
    • debug

      public static void debug(Object string, Object... ext)
      Prints a string to standard error if the Prop.debug flag is set.
      Parameters:
      string - debug string
      ext - text optional extensions
    • info

      public static String info(Object string, Object... ext)
      Returns a string and replaces all % characters by the specified extensions (see TokenBuilder.addExt(java.lang.Object, java.lang.Object...) for details).
      Parameters:
      string - string to be extended
      ext - text text extensions
      Returns:
      extended string
    • inf

      public static byte[] inf(Object string, Object... ext)
      Returns a token and replaces all % characters by the specified extensions (see TokenBuilder.addExt(java.lang.Object, java.lang.Object...) for details).
      Parameters:
      string - string to be extended
      ext - text text extensions
      Returns:
      token
    • stack

      public static void stack(String message)
      Prints the current stack trace to System.err.
      Parameters:
      message - error message
    • stack

      public static void stack(int depth)
      Prints the current stack trace to System.err.
      Parameters:
      depth - number of steps to print
    • stack

      public static void stack(Throwable throwable)
      Prints the stack of the specified error to standard error.
      Parameters:
      throwable - error/exception instance
    • start

      public static Process start(Class<?> clazz, String... args)
      Starts the specified class in a separate process. A -D (daemon) flag will be added to the command-line options.
      Parameters:
      clazz - class to start
      args - command-line arguments
      Returns:
      reference to a Process instance representing the started process
    • error

      public static String error(Process process, int timeout)
      Returns the error message of a process.
      Parameters:
      process - process
      timeout - time out in milliseconds
      Returns:
      error message or null