au.gov.tas.dpiwe.mr.bean
Class ValidateException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by javax.ejb.EJBException
                  extended by au.gov.tas.dpiwe.mr.bean.ValidateException
All Implemented Interfaces:
Serializable

public class ValidateException
extends EJBException

Validate exception is thrown when a bean fails a validation test.

When a storeWithRelated() method throws this exception, it is customary for the ValidateException to contain the chain of ValidateExceptions (including beans and field names) needed to uniquely specify the field or bean which could not be validated.

Since:
Mr Architecture 1.9
Version:
1.0.0.6
Author:
Kade Hansson
See Also:
Serialized Form

Field Summary
protected  EntityBean bean
          The bean for which the validation test failed.
protected  Throwable cause
          The direct cause of this exception, usually another ValidateException or null.
static int Failure_Architecture
          The identifier marking the start of the architecture-defined range.
static int Failure_Client
          The identifier marking the start of the client-defined range.
static int Failure_NumberTooBig
          The identifier indicating that the number for a field is too large according to the metadata available.
static int Failure_RequiredField
          The identifier indicating that a required field (according to the metadata available) was null.
static int Failure_TextTooLong
          The identifier indicating that the text for a field is too long according to the metadata available.
static int Failure_TypeMismatch
          The identifier indicating that a value could not be parsed according to the required type.
static int Failure_Undefined
          The identifier which does not indicate any particular failure.
protected  int failureReason
          An identifier indicating what validation test failed.
protected  String fieldName
          The name of field which could not be validated, or null if no specific field was invalid.
 
Constructor Summary
ValidateException(EntityBean bean, int failureReason)
          Constructs a new validation exception for an entity bean or bean object.
ValidateException(EntityBean bean, int failureReason, String message)
          Constructs a new validation exception for an entity bean or bean object.
ValidateException(EntityBean bean, int failureReason, String message, Throwable cause)
          Constructs a new validation exception for an entity bean or bean object.
ValidateException(EntityBean bean, int failureReason, Throwable cause)
          Constructs a new validation exception for an entity bean or bean object.
ValidateException(EntityBean bean, String fieldName, int failureReason)
          Constructs a new validation exception for an entity bean or bean object where a particular field is the cause of the validation failure.
ValidateException(EntityBean bean, String fieldName, int failureReason, String message)
          Constructs a new validation exception for an entity bean or bean object where a particular field is the cause of the validation failure.
ValidateException(EntityBean bean, String fieldName, int failureReason, String message, Throwable cause)
          Constructs a new validation exception for an entity bean or bean object where a particular field is the cause of the validation failure.
ValidateException(EntityBean bean, String fieldName, int failureReason, Throwable cause)
          Constructs a new validation exception for an entity bean or bean object where a particular field is the cause of the validation failure.
ValidateException(int failureReason)
          Constructs a new validation exception for an object which is not an EJB.
ValidateException(int failureReason, String message)
          Constructs a new validation exceptionfor an object which is not an EJB.
ValidateException(int failureReason, Throwable cause)
          Constructs a new validation exception for an object which is not an EJB.
ValidateException(String fieldName, int failureReason, String message)
          Constructs a new validation exception for an object which is not an EJB where a particular field is the cause of the validation failure.
ValidateException(String fieldName, int failureReason, String message, Throwable cause)
          Constructs a new validation exception for an object which is not an EJB where a particular field is the cause of the validation failure.
ValidateException(String fieldName, int failureReason, Throwable cause)
          Constructs a new validation exception for an object which is not an EJB where a particular field is the cause of the validation failure.
 
Method Summary
 EJBLocalObject getBeanObject(Container container)
          Returns a reference to the bean which caused this exception.
 Throwable getCause()
          Returns the cause of this exception, usually another ValidateException.
 int getFailureReason()
          Returns an identifier indicating what validation test failed.
 String getFieldName()
          Returns the name of field which could not be validated.
 Throwable initCause(Throwable cause)
          Sets the cause of this exception, usually another ValidateException.
protected static String makeMessage(String fieldName, int failureReason)
          Internal method to construct an appropriate message based on a field name and failure reason.
 
Methods inherited from class javax.ejb.EJBException
getCausedByException, getMessage, printStackTrace, printStackTrace, printStackTrace
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getLocalizedMessage, getStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fieldName

protected String fieldName
The name of field which could not be validated, or null if no specific field was invalid.


failureReason

protected int failureReason
An identifier indicating what validation test failed.


bean

protected EntityBean bean
The bean for which the validation test failed.


cause

protected Throwable cause
The direct cause of this exception, usually another ValidateException or null.


Failure_Architecture

public static final int Failure_Architecture
The identifier marking the start of the architecture-defined range.

See Also:
Constant Field Values

Failure_Undefined

public static final int Failure_Undefined
The identifier which does not indicate any particular failure.

See Also:
Constant Field Values

Failure_TextTooLong

public static final int Failure_TextTooLong
The identifier indicating that the text for a field is too long according to the metadata available.

See Also:
Constant Field Values

Failure_NumberTooBig

public static final int Failure_NumberTooBig
The identifier indicating that the number for a field is too large according to the metadata available.

See Also:
Constant Field Values

Failure_RequiredField

public static final int Failure_RequiredField
The identifier indicating that a required field (according to the metadata available) was null.

See Also:
Constant Field Values

Failure_TypeMismatch

public static final int Failure_TypeMismatch
The identifier indicating that a value could not be parsed according to the required type.

See Also:
Constant Field Values

Failure_Client

public static final int Failure_Client
The identifier marking the start of the client-defined range.

See Also:
Constant Field Values
Constructor Detail

ValidateException

public ValidateException(EntityBean bean,
                         String fieldName,
                         int failureReason,
                         String message,
                         Throwable cause)
Constructs a new validation exception for an entity bean or bean object where a particular field is the cause of the validation failure.

Parameters:
bean - the bean for which a validation test failed.
fieldName - the name of field which could not be validated.
failureReason - an identifier indicating what validation test failed.
message - a message to describe the validation failure.
cause - the exception (usually a ValidateException) which caused this validation failure.

ValidateException

public ValidateException(EntityBean bean,
                         String fieldName,
                         int failureReason,
                         String message)
Constructs a new validation exception for an entity bean or bean object where a particular field is the cause of the validation failure.

No further exception is chained.

Parameters:
bean - the bean for which a validation test failed.
fieldName - the name of field which could not be validated.
failureReason - an identifier indicating what validation test failed.
message - a message to describe the validation failure.

ValidateException

public ValidateException(EntityBean bean,
                         String fieldName,
                         int failureReason,
                         Throwable cause)
Constructs a new validation exception for an entity bean or bean object where a particular field is the cause of the validation failure.

This constructor is commonly used to construct validation failures in beans related to beans which caused validation failures. The message is automatically generated based on the reason code.

Parameters:
bean - the bean for which a validation test failed.
fieldName - the name of field which could not be validated.
failureReason - an identifier indicating what validation test failed.
cause - the exception (usually a ValidateException) which caused this validation failure.

ValidateException

public ValidateException(EntityBean bean,
                         String fieldName,
                         int failureReason)
Constructs a new validation exception for an entity bean or bean object where a particular field is the cause of the validation failure.

The message is automatically generated based on the reason code, and no further exception is chained.

Parameters:
bean - the bean for which a validation test failed.
fieldName - the name of field which could not be validated.
failureReason - an identifier indicating what validation test failed.

ValidateException

public ValidateException(EntityBean bean,
                         int failureReason,
                         String message,
                         Throwable cause)
Constructs a new validation exception for an entity bean or bean object.

This constructor is used when no particular field of the bean could be identified as the reason for validation failure. It is commonly used to construct validation failures in beans related to beans which caused validation failures.

Parameters:
bean - the bean for which a validation test failed.
failureReason - an identifier indicating what validation test failed.
message - a message to describe the validation failure.
cause - the exception (usually a ValidateException) which caused this validation failure.

ValidateException

public ValidateException(EntityBean bean,
                         int failureReason,
                         String message)
Constructs a new validation exception for an entity bean or bean object.

This constructor is used when no particular field of the bean could be identified as the reason for validation failure. It is commonly used to construct validation failures in beans related to beans which caused validation failures. No further exception is chained.

Parameters:
bean - the bean for which a validation test failed.
failureReason - an identifier indicating what validation test failed.
message - a message to describe the validation failure.

ValidateException

public ValidateException(EntityBean bean,
                         int failureReason,
                         Throwable cause)
Constructs a new validation exception for an entity bean or bean object.

This constructor is used when no particular field of the bean could be identified as the reason for validation failure. It is commonly used to construct validation failures in beans related to beans which caused validation failures. The message is automatically generated based on the reason code.

Parameters:
bean - the bean for which a validation test failed.
failureReason - an identifier indicating what validation test failed.
cause - the exception (usually a ValidateException) which caused this validation failure.

ValidateException

public ValidateException(EntityBean bean,
                         int failureReason)
Constructs a new validation exception for an entity bean or bean object.

This constructor is used when no particular field of the bean could be identified as the reason for validation failure. The message is automatically generated based on the reason code, and no further exception is chained.

Parameters:
bean - the bean for which a validation test failed.
failureReason - an identifier indicating what validation test failed.

ValidateException

public ValidateException(String fieldName,
                         int failureReason,
                         String message,
                         Throwable cause)
Constructs a new validation exception for an object which is not an EJB where a particular field is the cause of the validation failure.

Parameters:
fieldName - the name of field which could not be validated.
failureReason - an identifier indicating what validation test failed.
message - a message to describe the validation failure.
cause - the exception (usually a ValidateException) which caused this validation failure.

ValidateException

public ValidateException(String fieldName,
                         int failureReason,
                         String message)
Constructs a new validation exception for an object which is not an EJB where a particular field is the cause of the validation failure.

No further exception is chained.

Parameters:
fieldName - the name of field which could not be validated.
failureReason - an identifier indicating what validation test failed.
message - a message to describe the validation failure.

ValidateException

public ValidateException(String fieldName,
                         int failureReason,
                         Throwable cause)
Constructs a new validation exception for an object which is not an EJB where a particular field is the cause of the validation failure.

The message is automatically generated based on the reason code.

Parameters:
fieldName - the name of field which could not be validated.
failureReason - an identifier indicating what validation test failed.
message - a message to describe the validation failure.

ValidateException

public ValidateException(int failureReason,
                         String message)
Constructs a new validation exceptionfor an object which is not an EJB.

Parameters:
bean - the bean for which a validation test failed.
failureReason - an identifier indicating what validation test failed.
message - a message to describe the validation failure.

ValidateException

public ValidateException(int failureReason,
                         Throwable cause)
Constructs a new validation exception for an object which is not an EJB.

The message is automatically generated based on the reason code.

Parameters:
failureReason - an identifier indicating what validation test failed.

ValidateException

public ValidateException(int failureReason)
Constructs a new validation exception for an object which is not an EJB.

The message is automatically generated based on the reason code, and no further exception is chained.

Parameters:
failureReason - an identifier indicating what validation test failed.
Method Detail

initCause

public Throwable initCause(Throwable cause)
Sets the cause of this exception, usually another ValidateException.

Overrides:
initCause in class Throwable
Parameters:
cause - the cause of this exception, or null if this exception has no cause.

getCause

public Throwable getCause()
Returns the cause of this exception, usually another ValidateException.

Overrides:
getCause in class Throwable
Returns:
the exception (usually a ValidateException) which caused this exception.

getBeanObject

public EJBLocalObject getBeanObject(Container container)
                             throws EJBException
Returns a reference to the bean which caused this exception.

Parameters:
container - the container to instatiate the bean with respect to.
Throws:
EJBException

makeMessage

protected static String makeMessage(String fieldName,
                                    int failureReason)
Internal method to construct an appropriate message based on a field name and failure reason.

Parameters:
fieldName - the text to insert into the message as the field name (where applicable.)
failureReason - an identifier indicating what validation test failed.

getFieldName

public String getFieldName()
Returns the name of field which could not be validated.

Returns:
the name of field which could not be validated, or null if no specific field was invalid.

getFailureReason

public int getFailureReason()
Returns an identifier indicating what validation test failed.

Returns:
an identifier indicating what validation test failed.