edu.mines.jtk.util
Class Check

java.lang.Object
  extended by edu.mines.jtk.util.Check

public class Check
extends java.lang.Object

Facilitates checks for common conditions. Methods in this class throw appropriate exceptions when specified conditions are not satisfied.

Version:
2004.11.24
Author:
Dave Hale, Colorado School of Mines

Method Summary
static void argument(boolean condition, java.lang.String message)
          Ensures that the specified condition for an argument is true.
static void index(byte[] a, int i)
          Ensures that the specified array index is in bounds.
static void index(double[] a, int i)
          Ensures that the specified array index is in bounds.
static void index(float[] a, int i)
          Ensures that the specified array index is in bounds.
static void index(int[] a, int i)
          Ensures that the specified array index is in bounds.
static void index(int n, int i)
          Ensures that the specified zero-based index is in bounds.
static void index(long[] a, int i)
          Ensures that the specified array index is in bounds.
static void index(short[] a, int i)
          Ensures that the specified array index is in bounds.
static void state(boolean condition, java.lang.String message)
          Ensures that the specified condition of state is true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

argument

public static void argument(boolean condition,
                            java.lang.String message)
Ensures that the specified condition for an argument is true.

Parameters:
condition - the condition.
message - a description of the condition.
Throws:
java.lang.IllegalArgumentException - if the condition is false.

state

public static void state(boolean condition,
                         java.lang.String message)
Ensures that the specified condition of state is true.

Parameters:
condition - the condition.
message - a description of the condition.
Throws:
java.lang.IllegalStateException - if the condition is false.

index

public static void index(int n,
                         int i)
Ensures that the specified zero-based index is in bounds.

Parameters:
n - the smallest positive number that is not in bounds.
i - the index.
Throws:
java.lang.IndexOutOfBoundsException - if index is out of bounds.

index

public static void index(byte[] a,
                         int i)
Ensures that the specified array index is in bounds.

Parameters:
a - the array.
i - the index.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if index is out of bounds.

index

public static void index(short[] a,
                         int i)
Ensures that the specified array index is in bounds.

Parameters:
a - the array.
i - the index.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if index is out of bounds.

index

public static void index(int[] a,
                         int i)
Ensures that the specified array index is in bounds.

Parameters:
a - the array.
i - the index.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if index is out of bounds.

index

public static void index(long[] a,
                         int i)
Ensures that the specified array index is in bounds.

Parameters:
a - the array.
i - the index.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if index is out of bounds.

index

public static void index(float[] a,
                         int i)
Ensures that the specified array index is in bounds.

Parameters:
a - the array.
i - the index.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if index is out of bounds.

index

public static void index(double[] a,
                         int i)
Ensures that the specified array index is in bounds.

Parameters:
a - the array.
i - the index.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if index is out of bounds.