Subversion Repositories sokoban

Rev

Blame | Last modification | View Log | RSS feed

  1. package gdi1sokoban.exceptions;
  2.  
  3. /*============================================================================*/
  4.  
  5. /**
  6.  * Exception that is thrown whenever a method's parameter falls out of the scope
  7.  * of allowed values
  8.  *
  9.  * @author Steven Arzt, Oren Avni, Guido Roessling
  10.  * @version 1.0
  11.  */
  12. public class ParameterOutOfRangeException extends Exception {
  13.  
  14.         /* ======================================================================== */
  15.  
  16.         private static final long serialVersionUID = 1L;
  17.  
  18.         private String parameterName = "";
  19.         private Object value = null;
  20.  
  21.         /* ======================================================================== */
  22.  
  23.         /**
  24.          * Creates a new instance of the ParameterOutOfRangeException class
  25.          *
  26.          * @param paramName
  27.          *            The name of the parameter that has failed the validity check
  28.          */
  29.  
  30.         public ParameterOutOfRangeException(final String paramName) {
  31.                 this(paramName, null);
  32.         }
  33.  
  34.         /* ======================================================================== */
  35.  
  36.         /**
  37.          * Creates a new instance of the ParameterOutOfRangeException class with the
  38.          * value that has caused the error
  39.          *
  40.          * @param paramName
  41.          *            The name of the parameter that has failed the validity check
  42.          * @param aValue
  43.          *            The value that has caused the error
  44.          */
  45.  
  46.         public ParameterOutOfRangeException(final String paramName, final Object aValue) {
  47.                 super ("The " + paramName + " parameter got an invalid value");
  48.                 parameterName = paramName;
  49.                 value = aValue;
  50.         }
  51.  
  52.         /* ======================================================================== */
  53.  
  54.         /**
  55.          * Creates a new instance of the ParameterOutOfRangeException class with an
  56.          * inner exception for exception chaining
  57.          *
  58.          * @param paramName
  59.          *            The name of the parameter that has failed the validity check
  60.          * @param innerException
  61.          *            The inner exception that has led to this one
  62.          */
  63.  
  64.         public ParameterOutOfRangeException(final String paramName,
  65.                         final Throwable innerException) {
  66.                 super(innerException);
  67.                 parameterName = paramName;
  68.         }
  69.  
  70.         /* ======================================================================== */
  71.  
  72.         /**
  73.          * Gets the name of the parameter that has failed the validity check
  74.          *
  75.          * @return The name of the parameter that has failed the validity check
  76.          */
  77.  
  78.         public String getParameterName() {
  79.                 return parameterName;
  80.         }
  81.  
  82.         /* ======================================================================== */
  83.  
  84.         /**
  85.          * Gets the value that has caused the error
  86.          *
  87.          * @return The value that has caused the error
  88.          */
  89.  
  90.         public Object getValue() {
  91.                 return value;
  92.         }
  93.  
  94.         /* ======================================================================== */
  95.  
  96. }
  97.  
  98. /* ============================================================================ */
  99.