
Static Public Member Functions | |
| static boolean | assertTrue (boolean booleanCond, String stringCond) |
| static void | main (String[] args) |
Static Private Member Functions | |
| static final void | init () |
Static Private Attributes | |
| static final String | NB_ERRORMANAGER_CLASSNAME = "org.openide.ErrorManager" |
| static boolean | IN_NETBEANS |
| static final String | NB_ASSERT_CLASSNAME = "cern.gp.util.NbAssert" |
| static IAssert | NB_ASSERT |
| static boolean | initialized = false |
An assertion class, that enables programmers to make certain affirmations about things that have to be true in the code. If an assertion is broken, this means that there is a bad error in the code. Often, assertions are used in to assure that the parameters of a function call are correct, e.g. if a non-null parameter has been passed.
,
,
| static boolean cern::gp::util::Assertion::assertTrue | ( | boolean | booleanCond, | |
| String | stringCond | |||
| ) | [inline, static] |
Assert a function to assert a certain property of the code. If the asserted property is false, the Assertion is violated and an RuntimeException is thrown.
For example, assert that str is non-null:
<blockquote>
void myFunction(String str) { Assert.assertTrue(str != null, "str != null"); }
</pre</blockquote> Example: make sure min <= max: <blockquote>
boolean compare(int min, int max) { Assert.assertTrue(min <= max, "min <= max"); }</blockquote>
Example: make sure that num is greater or equal 0:
<blockquote>
double squareRoot(double num) { Assert.assertTrue(num >= 0, "num >= 0"); }
</pre</blockquote> | booleanCond | the condition expressed as a boolean | |
| stringCond | the same condition, given as a String. This is used to fill in the error message in the Exception that is launched if the Assertion is violated. |
| RuntimeException | if the Assertion is violated. The message in the
exception is the string in the stringCond parameter.
|
References cern::gp::util::IAssert::doAssert(), IN_NETBEANS, init(), and NB_ASSERT.
Referenced by main().
| static final void cern::gp::util::Assertion::init | ( | ) | [inline, static, private] |
Lazy initialization method. Checks whether we are in a Netbeans Environment or in a normal environment
References IN_NETBEANS, initialized, NB_ASSERT, NB_ASSERT_CLASSNAME, and NB_ERRORMANAGER_CLASSNAME.
Referenced by assertTrue().
| static void cern::gp::util::Assertion::main | ( | String[] | args | ) | [inline, static] |
The main program for the Assert class
| args | The command line arguments |
References assertTrue().
boolean cern::gp::util::Assertion::IN_NETBEANS [static, private] |
Referenced by assertTrue(), and init().
boolean cern::gp::util::Assertion::initialized = false [static, private] |
Referenced by init().
IAssert cern::gp::util::Assertion::NB_ASSERT [static, private] |
Referenced by assertTrue(), and init().
final String cern::gp::util::Assertion::NB_ASSERT_CLASSNAME = "cern.gp.util.NbAssert" [static, private] |
Referenced by init().
final String cern::gp::util::Assertion::NB_ERRORMANAGER_CLASSNAME = "org.openide.ErrorManager" [static, private] |
Referenced by init().
1.6.2