Class Assert

java.lang.Object
   |
   +----Assert

public class Assert
extends Object
A facility for asserts based on the C/C++ macro. Note that the java type system requires several overloaded assert methods. Expanded from java.sun.com Tech Tips, February 17, 1998. Java 1.1 Implementation


Constructor Index

 o Assert()

Method Index

 o abort()
Abort program with a stack trace.
 o abort(String)
Print message and abort program with a stack trace.
 o assert(boolean)
Boolean assertions.
 o assert(boolean, String)
Boolean assertions.
 o assert(double)
Float and double assertions.
 o assert(double, String)
Float and double assertions.
 o assert(long)
Byte, char, short, int, and long assertions.
 o assert(long, String)
Byte, char, short, int, and long assertions.
 o assert(Object)
Reference assertions.
 o assert(Object, String)
Reference assertions.

Constructors

 o Assert
 public Assert()

Methods

 o abort
 public static void abort()
Abort program with a stack trace.

 o abort
 public static void abort(String description)
Print message and abort program with a stack trace.

Parameters:
String - a description of the fatal error.
 o assert
 public static void assert(boolean b)
Boolean assertions. If the argument is false then a stack trace is printed and the program is exited.

Parameters:
boolean - the asserted condition.
 o assert
 public static void assert(boolean b,
                           String description)
Boolean assertions. If the first argument is false then a description and a stack trace are printed and the program is exited.

Parameters:
boolean - the asserted condition.
String - a description of the fatal error.
 o assert
 public static void assert(long l)
Byte, char, short, int, and long assertions. If the argument is equal to zero then a stack trace is printed and the program is exited.

Parameters:
long - the asserted condition.
 o assert
 public static void assert(long l,
                           String description)
Byte, char, short, int, and long assertions. If the first argument is equal to zero then a description and a stack trace are printed and the program is exited.

Parameters:
long - the asserted condition.
String - a description of the fatal error.
 o assert
 public static void assert(double d)
Float and double assertions. If the argument is equal to zero then a stack trace is printed and the program is exited.

Parameters:
double - the asserted condition.
 o assert
 public static void assert(double d,
                           String description)
Float and double assertions. If the first argument is equal to zero then a description and a stack trace are printed and the program is exited.

Parameters:
double - the asserted condition.
String - a description of the fatal error.
 o assert
 public static void assert(Object ref)
Reference assertions. If the argument is equal to null then a stack trace is printed and the program is exited. Example usage: Object p = f() ; Assert.assert(p) ; // checks that p is not null

Parameters:
Object - the asserted condition.
 o assert
 public static void assert(Object ref,
                           String description)
Reference assertions. If the first argument is equal to null then a description and a stack trace are printed and the program is exited. Example usage: Object p = f() ; Assert.assert(p, "bang") ; // checks that p is not null

Parameters:
Object - the asserted condition.
String - a description of the fatal error.