FileDocCategorySizeDatePackage
Assertion.javaAPI DocGlassfish v2 API6518Fri May 04 22:32:06 BST 2007com.sun.enterprise.util

Assertion

public class Assertion extends Object
A class for assertion checking
version
1.00 1 May 1999
version
1.10 5 June 2000
author
Byron Nevins

Fields Summary
private static boolean
doCheck
private static Assertion
staticInstance
Constructors Summary
Methods Summary
public static voidcheck(boolean b, java.lang.String s)
Check an assertion

param
b the condition to check
param
s a string describing the check
throws
Assertion.Failure if condition not true

  if (doCheck && !b)
         toss(s);
   
public static voidcheck(long x)
Check an assertion

param
x a number
throws
Assertion.Failure if number is 0

  if (doCheck && x == 0)
         toss();
   
public static voidcheck(boolean b)
Check an assertion

param
b the condition to check
throws
Assertion.Failure if condition not true

  if (doCheck && !b)
         toss();
   
public static voidcheck(java.lang.Object obj, java.lang.String s)
Check an assertion

param
obj an object to check
param
s a string describing the check
throws
Assertion.Failure if object is null

  if (doCheck && obj == null)
         toss(s);
   
public static voidcheck(java.lang.String checkMe, java.lang.String s)
Check an assertion

param
checkMe a String to check for length > 0
param
s a string describing the check
throws
Assertion.Failure if checkMe is null or zero-length

  if (doCheck && (checkMe == null || checkMe.length() <= 0))
         toss(s);
   
public static voidcheck(java.lang.String checkMe)
Check an assertion

param
checkMe a String to check for length > 0
throws
Assertion.Failure if checkMe is null or zero-length

  if (doCheck && (checkMe == null || checkMe.length() <= 0))
         toss();
   
public static voidcheck(java.lang.Object obj)
Check an assertion

param
obj an object to check
throws
Assertion.Failure if object is null

  if (doCheck && obj == null)
         toss();
   
public static voidcheck(double x, java.lang.String s)
Check an assertion

param
x a number
param
s a string describing the check
throws
Assertion.Failure if number is 0

  if (doCheck && x == 0)
         toss(s);
   
public static voidcheck(double x)
Check an assertion

param
x a number
throws
Assertion.Failure if number is 0

  if (doCheck && x == 0)
         toss();
   
public static voidcheck(long x, java.lang.String s)
Check an assertion

param
x a number
param
s a string describing the check
throws
Assertion.Failure if number is 0

  if (doCheck && x == 0)
         toss(s);
   
private static java.lang.StringgetCallerInfo()

		try
		{
			CallerInfo ci = new CallerInfo( new Object[] { staticInstance });
			return ci.toString();
		}
		catch(CallerInfoException e)
		{
			return null;
		}
	
public static voidmain(java.lang.String[] args)
test stub


             

       
     Assertion.check(args);
      Assertion.check(args.length, "No command line arguments");//NOI18N
   
public static voidsetCheck(boolean c)
Turn checking on or off

param
c true to turn checking on, false to turn checking off

  doCheck = c;
   
private static voidtoss()

		toss(null);
	
private static voidtoss(java.lang.String gripe)

		String msg = "\nAssertion failed";//NOI18N
		String ci = getCallerInfo();
		
		if(ci != null)
		{
			msg += " at " + ci;//NOI18N
		}

		if(gripe != null)
			msg += " --> " + gripe;//NOI18N
		
		//assert false : gripe;
		//assert false;
		throw new Failure(msg);