Package org.basex.util
Class Util
java.lang.Object
org.basex.util.Util
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 Summary
Modifier and TypeMethodDescriptionstatic StringReturns an information string for an unexpected exception.static StringReturns the name of the specified class, excluding its path.static StringReturns the class name of the specified object, excluding its path.static voidPrints a string to standard error if theProp.debugflag is set.static voidPrints the exception stack trace if theProp.debugflag is set.static voidPrints a string to standard error.static voidPrints a string to standard error, followed by a newline.static StringReturns the error message of a process.static byte[]Returns a token and replaces all % characters by the specified extensions (seeTokenBuilder.addExt(java.lang.Object, java.lang.Object...)for details).static StringReturns a string and replaces all % characters by the specified extensions (seeTokenBuilder.addExt(java.lang.Object, java.lang.Object...)for details).static Stringinput()Returns a single line from standard input.static StringReturns a more user-friendly error message for the specified exception.static RuntimeExceptionThrows a runtime exception for an unexpected exception.static RuntimeExceptionnotExpected(Object message, Object... ext) Throws a runtime exception for an unexpected exception.static voidPrints a string to standard output.static voidoutln()Prints a newline to standard output.static voidPrints a string to standard output, followed by a newline.static Stringpassword()Returns a password from standard input.static ThrowablerootException(Throwable throwable) Returns the root query exception.static voidstack(int depth) Prints the current stack trace to System.err.static voidPrints the current stack trace to System.err.static voidPrints the stack of the specified error to standard error.static ProcessStarts the specified class in a separate process.
-
Method Details
-
bug
Returns an information string for an unexpected exception.- Parameters:
throwable- exception- Returns:
- dummy object
-
notExpected
Throws a runtime exception for an unexpected exception.- Returns:
- runtime exception (indicates that an error is raised)
-
notExpected
Throws a runtime exception for an unexpected exception.- Parameters:
message- messageext- optional extension- Returns:
- runtime exception (indicates that an error is raised)
-
className
Returns the class name of the specified object, excluding its path.- Parameters:
object- object- Returns:
- class name
-
className
Returns the name of the specified class, excluding its path.- Parameters:
clazz- class- Returns:
- class name
-
input
Returns a single line from standard input.- Returns:
- 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
Prints a string to standard output, followed by a newline.- Parameters:
string- output stringext- text optional extensions
-
out
Prints a string to standard output.- Parameters:
string- output stringext- text optional extensions
-
rootException
Returns the root query exception.- Parameters:
throwable- throwable- Returns:
- root exception
-
errln
Prints a string to standard error, followed by a newline.- Parameters:
object- error objectext- text optional extensions
-
err
Prints a string to standard error.- Parameters:
string- debug stringext- text optional extensions
-
message
Returns a more user-friendly error message for the specified exception.- Parameters:
throwable- throwable reference- Returns:
- error message
-
debug
Prints the exception stack trace if theProp.debugflag is set.- Parameters:
throwable- exception
-
debug
Prints a string to standard error if theProp.debugflag is set.- Parameters:
string- debug stringext- text optional extensions
-
info
Returns a string and replaces all % characters by the specified extensions (seeTokenBuilder.addExt(java.lang.Object, java.lang.Object...)for details).- Parameters:
string- string to be extendedext- text text extensions- Returns:
- extended string
-
inf
Returns a token and replaces all % characters by the specified extensions (seeTokenBuilder.addExt(java.lang.Object, java.lang.Object...)for details).- Parameters:
string- string to be extendedext- text text extensions- Returns:
- token
-
stack
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
Prints the stack of the specified error to standard error.- Parameters:
throwable- error/exception instance
-
start
Starts the specified class in a separate process. A -D (daemon) flag will be added to the command-line options.- Parameters:
clazz- class to startargs- command-line arguments- Returns:
- reference to a
Processinstance representing the started process
-
error
Returns the error message of a process.- Parameters:
process- processtimeout- time out in milliseconds- Returns:
- error message or
null
-