|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jsesoft.jse.Root | +--org.jsesoft.jse.Assert
A work-around for assertions lacking in Java.
Summary:
The Assert
class provides a rudimentary assertion mechanism.
This mechanism serves for checking runtime conditions throwing an error
if the check fails.
Description:
The Assert
class provides two overloads of the assert
function. Both check the specified runtime condition and throw an assertion error in case
the condition does not hold. Whether or not this assertion is in effect is controlled by the system property
ASSERT
and the class variable inEffect
, resp.
If it is defined, the error might be thrown. If it is not defined, the error will not be thrown noway.
By convention, the (optional) message argument contains the checked condition as a String.
Usage:
Assert.assert( ref != null, "ref != null" );
Field Summary |
Fields inherited from class org.jsesoft.jse.Root |
logger, messages, resources |
Method Summary | |
static void |
ASSERT(boolean assertion)
Checks the runtime-condition and throws an error if check failed. |
static void |
ASSERT(boolean assertion,
java.lang.String message)
Checks the runtime-condition and throws an error with a custom message if check failed. |
static boolean |
isInEffect()
Checks whether or not the assertion mechanism is in effect. |
static void |
setInEffect(boolean value)
Sets the inEffect property to a new value. |
Methods inherited from class org.jsesoft.jse.Root |
decrementNumber, getResourceMessage, getResourceMessage, getResourceObject, getResourceString, incrementNumber, intFromByteArray, intToByteArray, longFromByteArray, longToByteArray, setMessageResourceBundle, setPackageResourceBundle, shortFromByteArray, shortToByteArray |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static boolean isInEffect()
If this function returns true, the assertion mechanism is in effect, that is, errors are thrown if the assertion is false.
public static void setInEffect(boolean value)
value
- the new value of the inEffect propertypublic static void ASSERT(boolean assertion, java.lang.String message)
This method checks the boolean assertion. If the assertion mechanism is in effect and the assertion is false, it throws an error with the specified message.
assertion
- the runtime-condition to checkmessage
- the message to print
AssertionError
- if the assertion is falsepublic static void ASSERT(boolean assertion)
This method checks the boolean assertion. If the assertion mechanism is in effect and the assertion is false, it throws an error with a null message.
assertion
- the runtime-condition to check
AssertionError
- if the assertion is false
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |