dk.netarkivet.common.exceptions
Class ArgumentNotValid

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by dk.netarkivet.common.exceptions.NetarkivetException
                  extended by dk.netarkivet.common.exceptions.ArgumentNotValid
All Implemented Interfaces:
java.io.Serializable

public class ArgumentNotValid
extends NetarkivetException

Indicates that one or more arguments are invalid.

See Also:
Serialized Form

Constructor Summary
ArgumentNotValid(java.lang.String message)
          Constructs new ArgumentNotValid with the specified detail message.
ArgumentNotValid(java.lang.String message, java.lang.Throwable cause)
          Constructs new ArgumentNotValid with the specified detail message and cause.
 
Method Summary
static void checkNotNegative(int num, java.lang.String name)
          Check if an int argument is less than 0.
static void checkNotNegative(long num, java.lang.String name)
          Check if a long argument is less than 0.
static void checkNotNull(java.lang.Object val, java.lang.String name)
          Check if an Object argument is null.
static void checkNotNullOrEmpty(java.util.Collection<?> c, java.lang.String name)
          Check if a List argument is not null and the list is not empty.
static void checkNotNullOrEmpty(java.lang.String val, java.lang.String name)
          Check if a String argument is null or the empty string.
static void checkPositive(int num, java.lang.String name)
          Check if an int argument is less than or equal to 0.
static void checkPositive(long num, java.lang.String name)
          Check if a long argument is less than 0.
static void checkTrue(boolean b, java.lang.String s)
          Check that some condition on input parameters is true and throw an ArgumentNotValid if it is false.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ArgumentNotValid

public ArgumentNotValid(java.lang.String message)
Constructs new ArgumentNotValid with the specified detail message.

Parameters:
message - The detail message

ArgumentNotValid

public ArgumentNotValid(java.lang.String message,
                        java.lang.Throwable cause)
Constructs new ArgumentNotValid with the specified detail message and cause.

Parameters:
message - The detail message
cause - The cause
Method Detail

checkNotNullOrEmpty

public static void checkNotNullOrEmpty(java.lang.String val,
                                       java.lang.String name)
Check if a String argument is null or the empty string.

Parameters:
val - the value to check
name - the name and type of the value being checked
Throws:
ArgumentNotValid - if test fails

checkNotNull

public static void checkNotNull(java.lang.Object val,
                                java.lang.String name)
Check if an Object argument is null.

Parameters:
val - the value to check
name - the name and type of the value being checked.
Throws:
ArgumentNotValid - if test fails

checkNotNegative

public static void checkNotNegative(int num,
                                    java.lang.String name)
Check if an int argument is less than 0.

Parameters:
num - argument to check
name - the name and type of the value being checked.
Throws:
ArgumentNotValid - if test fails

checkNotNegative

public static void checkNotNegative(long num,
                                    java.lang.String name)
Check if a long argument is less than 0.

Parameters:
num - argument to check
name - the name and type of the value being checked.
Throws:
ArgumentNotValid - if test fails

checkPositive

public static void checkPositive(int num,
                                 java.lang.String name)
Check if an int argument is less than or equal to 0.

Parameters:
num - argument to check
name - the name and type of the value being checked.
Throws:
ArgumentNotValid - if test fails

checkPositive

public static void checkPositive(long num,
                                 java.lang.String name)
Check if a long argument is less than 0.

Parameters:
num - argument to check
name - the name and type of the value being checked.
Throws:
ArgumentNotValid - if test fails

checkNotNullOrEmpty

public static void checkNotNullOrEmpty(java.util.Collection<?> c,
                                       java.lang.String name)
Check if a List argument is not null and the list is not empty.

Parameters:
c - argument to check
name - the name and type of the value being checked.
Throws:
ArgumentNotValid - if test fails

checkTrue

public static void checkTrue(boolean b,
                             java.lang.String s)
Check that some condition on input parameters is true and throw an ArgumentNotValid if it is false.

Parameters:
b - the condition to check
s - the error message to be reported
Throws:
ArgumentNotValid - if b is false