Secure iNet Factory

com.jscape.util
Class Assert

java.lang.Object
  extended by com.jscape.util.Assert

public final class Assert
extends java.lang.Object

The utility class for various run-time verifications. It is intended to use as standard "assert" keyword for method parameter verification. DO NOT USE IT FOR OTHER PURPOSES!!!

Version:
1.0
Author:
Alex Usun

Method Summary
static void areEqual(long leftValue, long rightValue, java.lang.String message)
          Asserts that two specified values are equal.
static void areEqual(java.lang.Object leftObject, java.lang.Object rightObject, java.lang.String msg)
          Asserts that two specified objects are equal.
static void greater(long value, long bound, java.lang.String message)
          Asserts that the specified value is greater than the lower bound.
static void greaterOrEqual(long value, long bound, java.lang.String message)
          Asserts that the specified value is greater or equal than the lower bound.
static void inRangeExclusive(long value, long lowerBound, long upperBound, java.lang.String message)
          Asserts that the specified value is in range exclusive.
static void inRangeInclusive(long value, long lowerBound, long upperBound, java.lang.String message)
          Asserts that the specified value is in range inclusive.
static void isContained(java.lang.Object value, java.lang.Object[] array, java.lang.String message)
           
static void isFalse(boolean condition, java.lang.String message)
          Asserts that the specified condition is false.
static void isTrue(boolean condition, java.lang.String message)
          Asserts that the specified condition is truth.
static void isValidArray(byte[] array, int offset, int len)
          Asserts that the specified array parameters are valid.
static void isValidPort(int port)
           
static void isValidState(boolean condition, java.lang.String message)
          Checks if state condition is true.
static void isValidString(java.lang.String str)
          Asserts that the specified string are valid.
static void less(long value, long bound, java.lang.String message)
          Asserts that the specified value is less that the upper bound.
static void lessOrEqual(long value, long bound, java.lang.String message)
          Asserts that the specified value is less or equal that the upper bound.
static void notNull(java.lang.Object reference)
          Asserts that the specified reference is not null.
static void notNull(java.lang.Object reference, java.lang.String message)
          Asserts that the specified reference is not null.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

notNull

public static void notNull(java.lang.Object reference,
                           java.lang.String message)
Asserts that the specified reference is not null.

Parameters:
reference - the reference to check
message - the error message
Throws:
java.lang.NullPointerException - if the specified reference is null

notNull

public static void notNull(java.lang.Object reference)
Asserts that the specified reference is not null.

Parameters:
reference - the reference to check
Throws:
java.lang.NullPointerException - if the specified reference is null

isTrue

public static void isTrue(boolean condition,
                          java.lang.String message)
Asserts that the specified condition is truth.

Parameters:
condition - the condition to check
message - the error message
Throws:
java.lang.IllegalArgumentException - if the specified condition is false

isFalse

public static void isFalse(boolean condition,
                           java.lang.String message)
Asserts that the specified condition is false.

Parameters:
condition - the condition to check
message - the error message
Throws:
java.lang.IllegalArgumentException - if the specified condition is truth

greater

public static void greater(long value,
                           long bound,
                           java.lang.String message)
Asserts that the specified value is greater than the lower bound.

Parameters:
value - the value to check
bound - the value lower bound
message - the error message
Throws:
java.lang.IllegalArgumentException - if the specified value is not greater than the lower bound

greaterOrEqual

public static void greaterOrEqual(long value,
                                  long bound,
                                  java.lang.String message)
Asserts that the specified value is greater or equal than the lower bound.

Parameters:
value - the value to check
bound - the value lower bound
message - the error message
Throws:
java.lang.IllegalArgumentException - if the specified value is less than the lower bound

less

public static void less(long value,
                        long bound,
                        java.lang.String message)
Asserts that the specified value is less that the upper bound.

Parameters:
value - the value to check
bound - the value upper bound
message - the error message
Throws:
java.lang.IllegalArgumentException - if the specified value is not less than the upper bound

lessOrEqual

public static void lessOrEqual(long value,
                               long bound,
                               java.lang.String message)
Asserts that the specified value is less or equal that the upper bound.

Parameters:
value - the value to check
bound - the value upper bound
message - the error message
Throws:
java.lang.IllegalArgumentException - if the specified value is not greater than the upper bound

inRangeInclusive

public static void inRangeInclusive(long value,
                                    long lowerBound,
                                    long upperBound,
                                    java.lang.String message)
Asserts that the specified value is in range inclusive.

Parameters:
value - the value to check
lowerBound - the value lower bound
upperBound - the value upper bound
message - the error message
Throws:
java.lang.IllegalArgumentException - if the specified value is not in range inclusive

inRangeExclusive

public static void inRangeExclusive(long value,
                                    long lowerBound,
                                    long upperBound,
                                    java.lang.String message)
Asserts that the specified value is in range exclusive.

Parameters:
value - the value to check
lowerBound - the value lower bound
upperBound - the value upper bound
message - the error message
Throws:
java.lang.IllegalArgumentException - if the specified value is not in range exclusive

areEqual

public static void areEqual(long leftValue,
                            long rightValue,
                            java.lang.String message)
Asserts that two specified values are equal.

Parameters:
leftValue - the first value
rightValue - the second value
message - the error message
Throws:
java.lang.IllegalArgumentException - if the specified values are not equal

areEqual

public static void areEqual(java.lang.Object leftObject,
                            java.lang.Object rightObject,
                            java.lang.String msg)
Asserts that two specified objects are equal.

Parameters:
leftObject - the first object
rightObject - the second object
msg - the error message
Throws:
java.lang.IllegalArgumentException - if the specified objects are not equal
java.lang.NullPointerException - if some of the objects are null

isValidArray

public static void isValidArray(byte[] array,
                                int offset,
                                int len)
Asserts that the specified array parameters are valid.

Parameters:
array - the array to check
offset - the array offset
len - the data length
Throws:
java.lang.IllegalArgumentException - if the offset or length parameters are invalid
java.lang.NullPointerException - if the array reference is null

isValidString

public static void isValidString(java.lang.String str)
Asserts that the specified string are valid.

Parameters:
str - string to check
Throws:
java.lang.IllegalArgumentException - if the string is empty
java.lang.NullPointerException - if the string reference is null

isValidState

public static void isValidState(boolean condition,
                                java.lang.String message)
Checks if state condition is true.

Parameters:
condition - state condition to check
message - error message
Throws:
java.lang.IllegalStateException - if state condition is false

isValidPort

public static void isValidPort(int port)

isContained

public static void isContained(java.lang.Object value,
                               java.lang.Object[] array,
                               java.lang.String message)

Secure iNet Factory

Copyright © JSCAPE LLC. 1999-2011. All Rights Reserved