org.basex.util
Class Util

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

public final class Util
extends java.lang.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-12, BSD License, Christian Gruen

Method Summary
static java.lang.String bug(java.lang.Throwable ex)
          Returns an information string for an unexpected exception.
static void debug(java.lang.Object str, java.lang.Object... ext)
          Prints a string to standard error if the Prop.debug flag is set.
static void debug(java.lang.Throwable ex)
          Prints the exception stack trace if the Prop.debug flag is set.
static void err(java.lang.String string, java.lang.Object... ext)
          Prints a string to standard error.
static void errln(java.lang.Object obj, java.lang.Object... ext)
          Prints a string to standard error, followed by a newline.
static java.lang.String flag(boolean flag)
          Returns an info message for the specified flag.
static byte[] inf(java.lang.Object str, java.lang.Object... ext)
          Returns a token and replaces all % characters by the specified extensions (see TokenBuilder.addExt(java.lang.Object, java.lang.Object...) for details).
static java.lang.String info(java.lang.Object str, java.lang.Object... ext)
          Returns a string and replaces all % characters by the specified extensions (see TokenBuilder.addExt(java.lang.Object, java.lang.Object...) for details).
static java.lang.String input()
          Returns a single line from standard input.
static java.lang.String message(java.lang.Throwable ex)
          Returns a more user-friendly error message for the specified exception.
static java.lang.String name(java.lang.Class<?> o)
          Returns the name of the specified class.
static java.lang.String name(java.lang.Object o)
          Returns the class name of the specified object.
static boolean no(java.lang.String string)
          Checks if the specified string is "no", "false" or "off".
static java.lang.RuntimeException notexpected(java.lang.Object... ext)
          Throws a runtime exception for an unexpected exception.
static java.lang.RuntimeException notimplemented(java.lang.Object... ext)
          Throws a runtime exception for an unimplemented method.
static void out(java.lang.Object str, java.lang.Object... ext)
          Prints a string to standard output.
static void outln()
          Prints a newline to standard output.
static void outln(java.lang.Object str, java.lang.Object... ext)
          Prints a string to standard output, followed by a newline.
static java.lang.String password()
          Returns a password from standard input.
static void stack(int i)
          Prints the current stack trace to System.err.
static void stack(java.lang.Throwable th)
          Prints the stack of the specified error to standard error.
static java.lang.Process start(java.lang.Class<?> clz, java.lang.String... args)
          Starts the specified class in a separate process.
static boolean yes(java.lang.String string)
          Checks if the specified string is "yes", "true" or "on".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

bug

public static java.lang.String bug(java.lang.Throwable ex)
Returns an information string for an unexpected exception.

Parameters:
ex - exception
Returns:
dummy object

notexpected

public static java.lang.RuntimeException notexpected(java.lang.Object... ext)
Throws a runtime exception for an unexpected exception.

Parameters:
ext - optional extension
Returns:
runtime exception (indicates that an error is raised)

notimplemented

public static java.lang.RuntimeException notimplemented(java.lang.Object... ext)
Throws a runtime exception for an unimplemented method.

Parameters:
ext - optional extension
Returns:
runtime exception (indicates that an error is raised)

name

public static java.lang.String name(java.lang.Object o)
Returns the class name of the specified object.

Parameters:
o - object
Returns:
class name

name

public static java.lang.String name(java.lang.Class<?> o)
Returns the name of the specified class.

Parameters:
o - object
Returns:
class name

input

public static java.lang.String input()
Returns a single line from standard input.

Returns:
string

password

public static java.lang.String password()
Returns a password from standard input.

Returns:
password

outln

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


outln

public static void outln(java.lang.Object str,
                         java.lang.Object... ext)
Prints a string to standard output, followed by a newline.

Parameters:
str - output string
ext - text optional extensions

out

public static void out(java.lang.Object str,
                       java.lang.Object... ext)
Prints a string to standard output.

Parameters:
str - output string
ext - text optional extensions

errln

public static void errln(java.lang.Object obj,
                         java.lang.Object... ext)
Prints a string to standard error, followed by a newline.

Parameters:
obj - error string
ext - text optional extensions

err

public static void err(java.lang.String string,
                       java.lang.Object... ext)
Prints a string to standard error.

Parameters:
string - debug string
ext - text optional extensions

message

public static java.lang.String message(java.lang.Throwable ex)
Returns a more user-friendly error message for the specified exception.

Parameters:
ex - throwable reference
Returns:
error message

debug

public static void debug(java.lang.Throwable ex)
Prints the exception stack trace if the Prop.debug flag is set.

Parameters:
ex - exception

debug

public static void debug(java.lang.Object str,
                         java.lang.Object... ext)
Prints a string to standard error if the Prop.debug flag is set.

Parameters:
str - debug string
ext - text optional extensions

info

public static java.lang.String info(java.lang.Object str,
                                    java.lang.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:
str - string to be extended
ext - text text extensions
Returns:
extended string

inf

public static byte[] inf(java.lang.Object str,
                         java.lang.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:
str - string to be extended
ext - text text extensions
Returns:
token

stack

public static void stack(int i)
Prints the current stack trace to System.err.

Parameters:
i - number of steps to print

stack

public static void stack(java.lang.Throwable th)
Prints the stack of the specified error to standard error.

Parameters:
th - error/exception instance

start

public static java.lang.Process start(java.lang.Class<?> clz,
                                      java.lang.String... args)
Starts the specified class in a separate process.

Parameters:
clz - class to start
args - command-line arguments
Returns:
reference to a Process instance representing the started process

yes

public static boolean yes(java.lang.String string)
Checks if the specified string is "yes", "true" or "on".

Parameters:
string - string to be checked
Returns:
result of check

no

public static boolean no(java.lang.String string)
Checks if the specified string is "no", "false" or "off".

Parameters:
string - string to be checked
Returns:
result of check

flag

public static java.lang.String flag(boolean flag)
Returns an info message for the specified flag.

Parameters:
flag - current flag status
Returns:
ON/OFF message