ArgCheckerpublic class ArgChecker extends Object Use ArgChecker to check method parameters
Example usage:
ArgChecker.check( name != null, "null name" );
ArgChecker.check( index, 0, numItems, "index" );
ArgChecker.check( str, "userName");
ArgChecker.check( str, minimumStringLength, "userName");
ArgChecker.checkValid(parameter, "parameter-name"); |
Fields Summary |
---|
private static final boolean | sChecksEnabled | private static final com.sun.enterprise.admin.util.AssertImpl | sImpl |
Constructors Summary |
---|
private ArgChecker()
// need to do this in a static block to guarantee the
// setWantStackTrace() call
sImpl = new AssertImpl("ArgChecker Failure", AssertImpl.sIllegalArgument);
sImpl.setWantStackTrace(false);
Assert.assertit(false, "You can't call the ArgChecker constructor!");
|
Methods Summary |
---|
public static void | check(java.lang.String checkMe, int minimumLength, java.lang.String name)Check the String with a custom StringValidator
check(checkMe, name, new StringValidator(minimumLength));
| public static final void | check(boolean b, java.lang.Object msg)If expression is false, take appropriate action to note the failure.
If expression is true, do nothing.
if ( sChecksEnabled )
{
sImpl.assertIt(b, msg);
}
| public static final void | check(long value, long min, long max, java.lang.Object userMsg)Checks that the specified value is in a specified range.
A convenience method which calls checkRange()
checkRange(value, min, max, userMsg);
| public static void | check(java.lang.Object object, java.lang.String name, com.sun.enterprise.admin.util.Validator validator)Checks that the object is valid generically by using a Validation object.
Convenience method. Calls checkValid().
checkValid(object, name, validator);
| public static void | check(java.lang.Object object, java.lang.String name)Check that the object is valid.
Convenience method. Calls checkValid().
checkValid( object, name);
| public static void | check(java.lang.String checkMe, java.lang.String name)Check the String with the standard StringValidator
check(checkMe, name, StringValidator.getInstance());
| public static final void | checkRange(long value, long min, long max, java.lang.Object userMsg)Checks that the specified value is in a specified range.
The test done is ( value >= min && value <= max )
If the test fails, then a descriptive string is generated
which lists the value together with the min and max and
user-specified message.
if ( sChecksEnabled )
{
sImpl.assertRange(value, min, max, userMsg);
}
| public static void | checkValid(java.lang.Object object, java.lang.String name, com.sun.enterprise.admin.util.Validator validator)Checks that the object is valid generically by using a Validation
object.
If the validation fails, then the check fails as with other checks.
if ( sChecksEnabled )
{
sImpl.assertValid(object, name, validator);
}
| public static void | checkValid(java.lang.Object object, java.lang.String name)Check that the object is valid.
Calls check( object, name, validator ) where validator is either
the non-null validator or the object itself, if the object implements
IValidator.
final Validator validator = (object instanceof Validator ) ?
(Validator)object :
BaseValidator.getInstance();
check( object, name, validator );
|
|