Package net.jangaroo.jooc
Class Debug
- java.lang.Object
-
- net.jangaroo.jooc.Debug
-
public final class Debug extends Object
A class to provide debug facilities in java.For
assertTrue, to avoid evaluation of the boolean expression with debugging turned off on sun's java interpreter and with sun's javac use the following:Debug.assertTrue(Debug.enabled && anExpression, "error message");The short-cut semantics of '&&' will guarantee that anExpression will not be evaluated if enabled is set to false.
Debug.printalso won't print its argument ifDebug.enabledis false. If the generation of the argument is already costly, you have to wrap it in an if-statement.- Author:
- Andreas Gawecki
-
-
Field Summary
Fields Modifier and Type Field Description static booleanenabled
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassertTrue(boolean b, String s)static booleanisInArray(int[] array, int find)Method to use to assert that an array contains an int.static booleanisInArray(Object[] array, Object find)Method to use to assert that an array contains an object.static booleanisInArray(String[] array, String find)Method to use to assert that an array contains a String.static booleanisSorted(int[] array)Method to use to assert that an array is sortedstatic voidprintArray(int[] x)Print an Array.static voidprintArray(Object[] x)Print an Array.static StringprintArrayToString(int[] x)Print an int Array to a String.static StringprintArrayToString(Object[] x)Print an Object Array to a String.static voidprintln(Object x)Print an Object, and then finish the line.static voidprintln(String x)Print a String, and then finish the line.
-
-
-
Field Detail
-
enabled
public static final boolean enabled
- See Also:
- Constant Field Values
-
-
Method Detail
-
assertTrue
public static void assertTrue(boolean b, String s)
-
isSorted
public static boolean isSorted(int[] array)
Method to use to assert that an array is sorted- Parameters:
array- the array- Returns:
- true/false
-
isInArray
public static boolean isInArray(Object[] array, Object find)
Method to use to assert that an array contains an object. Uses ==- Parameters:
array- the arrayfind- the Object to find- Returns:
- true/false
-
isInArray
public static boolean isInArray(String[] array, String find)
Method to use to assert that an array contains a String. Uses equals.- Parameters:
array- the arrayfind- the string to find- Returns:
- if the array contains the string or not
-
isInArray
public static boolean isInArray(int[] array, int find)Method to use to assert that an array contains an int.- Parameters:
array- the arrayfind- the int to find in the array- Returns:
- if the array contains the int or not
-
println
public static void println(String x)
Print a String, and then finish the line.- Parameters:
x- the string
-
println
public static void println(Object x)
Print an Object, and then finish the line.- Parameters:
x- the object
-
printArray
public static void printArray(Object[] x)
Print an Array.- Parameters:
x- the array
-
printArrayToString
public static String printArrayToString(Object[] x)
Print an Object Array to a String.- Parameters:
x- the array- Returns:
- the string
-
printArrayToString
public static String printArrayToString(int[] x)
Print an int Array to a String.- Parameters:
x- the array- Returns:
- the string
-
printArray
public static void printArray(int[] x)
Print an Array.- Parameters:
x- the array
-
-