com.tensegrity.generic.util
Class Assert

java.lang.Object
  extended bycom.tensegrity.generic.util.Assert

public final class Assert
extends java.lang.Object

The target platforms for the Tensegrity Graph API are the JDK versions 1.3 or newer. Unfortunately there is no assert keyword or mechanism shipped with the 1.3 version of the JDK. Because of this, the Tensegrity Graph Framework comes with a mechanism that resembles assertions and permits their use.

Class Assert therefore contains methods for assertions thrown at runtime. Specifying what effects failed assertions have at runtime is done by means of a flag defined in class Debug, namely Debug.DO_ASSERT. This flag determines whether a subclass of a runtime exception is thrown if an assertion fails.

Using the if-statement on the global flag Debug.DO_ASSERT is mandatory. This global final static boolean flag allows a compiler to safely exclude the body of the if-statement from non-debug builds. In order to exclude all assertion code from a production build, it is sufficient to set the flag Debug.DO_ASSERT to false.

Class Assert provides static methods and no public constructors.

Version:
$Id: Assert.java,v 1.17 2005/11/18 14:17:34 KevinCVS Exp $
Author:
S. Rutz

Field Summary
static java.lang.String DIVIDE_BY_ZERO
          Predefined reasons for failed assertions.
static java.lang.String ILLEGAL_ARRAY_LENGTH
          Predefined reasons for failed assertions.
static java.lang.String ILLEGAL_TYPE
          Predefined reasons for failed assertions.
static java.lang.String ILLEGAL_VALUE
          Predefined reasons for failed assertions.
static java.lang.String NON_NEGATIVE_ARGUMENT
          Predefined reasons for failed assertions.
static java.lang.String NON_NULL_ARGUMENT
          Predefined reasons for failed assertions.
static java.lang.String NON_NULL_ARGUMENTS
          Predefined reasons for failed assertions.
static java.lang.String POSITIVE_ARGUMENT
          Predefined reasons for failed assertions.
 
Method Summary
static void check(boolean condition)
          Triggers an assert failed processing if the condition is not true.
static void check(boolean condition, java.lang.String what)
          Triggers an assert failed processing if the condition is not true.
static void fail()
          Always triggers an assert failed processing.
static void fail(java.lang.String what)
          Always triggers an assert failed processing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NON_NEGATIVE_ARGUMENT

public static final java.lang.String NON_NEGATIVE_ARGUMENT
Predefined reasons for failed assertions.

See Also:
Constant Field Values

POSITIVE_ARGUMENT

public static final java.lang.String POSITIVE_ARGUMENT
Predefined reasons for failed assertions.

See Also:
Constant Field Values

NON_NULL_ARGUMENT

public static final java.lang.String NON_NULL_ARGUMENT
Predefined reasons for failed assertions.

See Also:
Constant Field Values

NON_NULL_ARGUMENTS

public static final java.lang.String NON_NULL_ARGUMENTS
Predefined reasons for failed assertions.

See Also:
Constant Field Values

DIVIDE_BY_ZERO

public static final java.lang.String DIVIDE_BY_ZERO
Predefined reasons for failed assertions.

See Also:
Constant Field Values

ILLEGAL_ARRAY_LENGTH

public static final java.lang.String ILLEGAL_ARRAY_LENGTH
Predefined reasons for failed assertions.

See Also:
Constant Field Values

ILLEGAL_TYPE

public static final java.lang.String ILLEGAL_TYPE
Predefined reasons for failed assertions.

See Also:
Constant Field Values

ILLEGAL_VALUE

public static final java.lang.String ILLEGAL_VALUE
Predefined reasons for failed assertions.

See Also:
Constant Field Values
Method Detail

fail

public static final void fail()
Always triggers an assert failed processing.

Throws:
AssertException - thrown only if the Debug flag for assertion is enabled.

fail

public static final void fail(java.lang.String what)
Always triggers an assert failed processing.

Parameters:
what - additional information associated with the particular failure
Throws:
AssertException - thrown only if the Debug flag for assertion is enabled.

check

public static final void check(boolean condition)
Triggers an assert failed processing if the condition is not true.

Parameters:
condition - the condition to check
Throws:
AssertException - thrown only if the Debug flag for assertion is enabled.

check

public static final void check(boolean condition,
                               java.lang.String what)
Triggers an assert failed processing if the condition is not true.

Parameters:
condition - the condition to check
what - additional information associated with the particular check
Throws:
AssertException - thrown only if the Debug flag for assertion is enabled.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.