JDeveloper SCM API

oracle.ide.scm.util
Class SCMAssert

java.lang.Object
  |
  +--oracle.ide.scm.util.SCMAssert

public final class SCMAssert
extends java.lang.Object

The version control framework's assertion and exception handler. Use this class to test code states, raising runtime exceptions if conditions fail. Serious exceptions should always be reported through this class.


Method Summary
static void check(boolean condition)
          Check a condition within a method body.
static void check(boolean condition, java.lang.String description)
          Check a condition within a method body.
static void checkAWTThread()
          Checks that the current thread is the AWT event dispatcher.
static void fail()
          Shorthand for causing a check exception if the code reaches an unexpected location.
static void fail(java.lang.Exception ex)
          Shorthand for causing a check exception if the code reaches an unexpected location.
static void fail(java.lang.String description)
          Shorthand for causing a check exception if the code reaches an unexpected location.
static boolean isEnabled()
          Asks whether assertion checking and message reporting is enabled.
static void precondition(boolean condition)
          Assert a precondition before a method body run.
static void precondition(boolean condition, java.lang.String description)
          Assert a precondition before a method body run.
static void print(boolean condition, java.lang.String s)
          Print a string to standard error if a condition is true.
static void print(boolean condition, java.lang.String trueString, java.lang.String falseString)
          Print a string to standard error based on the evaluation of a condition.
static void print(java.lang.String s)
          Print a string to standard error.
static void println(boolean condition, java.lang.String s)
          Print a string and a newline to standard error if a condition is true
static void println(boolean condition, java.lang.String trueString, java.lang.String falseString)
          Print a string and a newline to standard error based on the evaluation of a condition.
static void println(java.lang.String s)
          Print a string and a newline to standard error.
static void printStackTrace()
          Print a diagnostic stack trace of the current thread.
static void printStackTrace(boolean condition, java.lang.String s)
          Print a diagnostic stack trace if the specified condition is true.
static void printStackTrace(java.lang.Throwable ex)
          Print the stack trace of a Throwable.
static void report(java.lang.Throwable t)
          Reports the given exception through the UI.
static void report(java.lang.Throwable t, java.awt.Component parent)
          Reports the given exception through the UI, parented to the given component.
static void setEnabled(boolean enabled)
          Sets whether assertion checking and message printing is enabled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setEnabled

public static void setEnabled(boolean enabled)
Sets whether assertion checking and message printing is enabled.

Note that errors can be reported in the form of stack traces to the console (runtime exceptions only) and UI dialogs without enabling this property.

Parameters:
enabled - the enablement value to set.

isEnabled

public static boolean isEnabled()
Asks whether assertion checking and message reporting is enabled.
Returns:
the current enablement value.

precondition

public static void precondition(boolean condition,
                                java.lang.String description)
                         throws oracle.ide.scm.util.SCMAssert.PreconditionException
Assert a precondition before a method body run. Use this to describe assumed state and parameter values. A precondition is raised if the given condition is not true. An error here usually indicates a problem with the use of the class.
Parameters:
condition - The condition being asserted.
description - The description of the failed assertion

precondition

public static void precondition(boolean condition)
                         throws oracle.ide.scm.util.SCMAssert.PreconditionException
Assert a precondition before a method body run. Use this to describe assumed state and parameter values. A precondition is raised if the given condition is not true. An error here usually indicates a problem with the use of the class.
Parameters:
condition - The condition being asserted.

check

public static void check(boolean condition,
                         java.lang.String description)
                  throws oracle.ide.scm.util.SCMAssert.CheckException
Check a condition within a method body. Use this to describe assumed results and state after internal operations. A check is raised if the given condition is not true. An error here usually indicates an internal problem with the class.
Parameters:
condition - The condition being asserted.
description - The description of the failed assertion

check

public static void check(boolean condition)
                  throws oracle.ide.scm.util.SCMAssert.CheckException
Check a condition within a method body. Use this to describe assumed results and state after internal operations. A check is raised if the given condition is not true. An error here usually indicates an internal problem with the class.
Parameters:
condition - The condition being asserted.

checkAWTThread

public static void checkAWTThread()
                           throws oracle.ide.scm.util.SCMAssert.CheckException
Checks that the current thread is the AWT event dispatcher.

fail

public static void fail(java.lang.String description)
                 throws oracle.ide.scm.util.SCMAssert.CheckException
Shorthand for causing a check exception if the code reaches an unexpected location.
Parameters:
description - The description of the failure

fail

public static void fail()
                 throws oracle.ide.scm.util.SCMAssert.CheckException
Shorthand for causing a check exception if the code reaches an unexpected location.

fail

public static void fail(java.lang.Exception ex)
                 throws oracle.ide.scm.util.SCMAssert.CheckException
Shorthand for causing a check exception if the code reaches an unexpected location.
Parameters:
ex - An exception encapsulating the failure

printStackTrace

public static void printStackTrace()
Print a diagnostic stack trace of the current thread.

printStackTrace

public static void printStackTrace(java.lang.Throwable ex)
Print the stack trace of a Throwable.

This method does not require the assertion class to be enabled if the given exception is an instance of RuntimeException.

Parameters:
ex - The Throwable with the stack trace info.

printStackTrace

public static void printStackTrace(boolean condition,
                                   java.lang.String s)
Print a diagnostic stack trace if the specified condition is true.
Parameters:
condition - the condition that determines whether to print the stack trace.
s - the string to print before the stack trace.

print

public static void print(java.lang.String s)
Print a string to standard error.
Parameters:
s - the string to print.

print

public static void print(boolean condition,
                         java.lang.String s)
Print a string to standard error if a condition is true.
Parameters:
condition - the condition to evaluate
s - the string to print.

print

public static void print(boolean condition,
                         java.lang.String trueString,
                         java.lang.String falseString)
Print a string to standard error based on the evaluation of a condition.
Parameters:
condition - the condition to evaluate
trueString - the string to print if condition is true.
falseString - the string to print if condition is false.

println

public static void println(java.lang.String s)
Print a string and a newline to standard error.
Parameters:
s - the string to print

println

public static void println(boolean condition,
                           java.lang.String s)
Print a string and a newline to standard error if a condition is true
Parameters:
condition - the condition to evaluate
s - the string to print.

println

public static void println(boolean condition,
                           java.lang.String trueString,
                           java.lang.String falseString)
Print a string and a newline to standard error based on the evaluation of a condition.
Parameters:
condition - the condition to evaluate
trueString - the string to print if condition is true.
falseString - the string to print if condition is false.

report

public static void report(java.lang.Throwable t)
Reports the given exception through the UI. If the exception is an SCM exception or derivative, the manner of reporting will be based on its attributed severity.

This method does not require the assertion class to be enabled.

Parameters:
t - the exception to report.

report

public static void report(java.lang.Throwable t,
                          java.awt.Component parent)
Reports the given exception through the UI, parented to the given component.

This method does not require the assertion class to be enabled.

Parameters:
t - the exception to report.
parent - the component parent for the exception report dialog.

Copyright © 2002 Oracle Corporation