ERXValidationException Class Reference

Inherits com::webobjects::foundation::NSKeyValueCoding.

Inherited by ERAttachmentProcessor< T extends ERAttachment >.ERXAttachmentExceedsLengthException.

Collaboration diagram for ERXValidationException:

Collaboration graph
[legend]

List of all members.

Public Member Functions

NSArray additionalExceptions ()
EOAttribute attribute ()
NSKeyValueCoding context ()
Object delegate ()
String displayNameForEntity ()
String displayNameForProperty ()
EOEnterpriseObject eoObject ()
boolean equals (Object anotherObject)
 ERXValidationException (String type, Object object, String key, Object value)
 ERXValidationException (String type, Object object, String key)
String getMessage ()
int hashCode ()
boolean isCustomMethodException ()
String method ()
Object object ()
String propertyKey ()
void setAdditionalExceptions (NSArray exceptions)
void setContext (NSKeyValueCoding context)
void setDelegate (Object obj)
void setMethod (String aMethod)
void setObject (Object aValue)
void setTargetLanguage (String aValue)
void setType (String aType)
void setValue (Object aValue)
void takeValueForKey (Object obj, String key)
String targetLanguage ()
String toString ()
String type ()
Object value ()
Object valueForKey (String key)

Static Public Attributes

static final String CustomMethodException = "CustomMethodException"
static final String ExceedsMaximumLengthException = "ExceedsMaximumLengthException"
static final String InvalidNumberException = "InvalidNumberException"
static final String InvalidValueException = "InvalidValueException"
static final Logger log = Logger.getLogger(ERXValidationException.class)
static final String MandatoryToManyRelationshipException = "MandatoryToManyRelationshipException"
static final String MandatoryToOneRelationshipException = "MandatoryToOneRelationshipException"
static final String NullPropertyException = "NullPropertyException"
static final String ObjectRemovalException = "ObjectRemovalException"
static final String ObjectsRemovalException = "ObjectsRemovalException"
static final String ValueConversionException = "ValueConversionException"

Protected Member Functions

String _getMessage ()
String localizedDisplayNameForKey (String key)

Protected Attributes

volatile NSKeyValueCoding _context
NSArray additionalExceptions
volatile Object delegate
String message
String method
Object object
String targetLanguage
String type
Object value


Detailed Description

ERXValidationExceptions extends the regular NSValidation.ValidationException to add template based resolution of the validation exception. See more information about resolving templates in the ERXValidationFactory.

Constructor & Destructor Documentation

ERXValidationException ( String  type,
Object  object,
String  key 
)

Default constructor that builds a validation exception without the failed value specified. If you want to have validation templates that refer to the value that didn't pass validation use the four argument constructor. Usually for creating custom validation exceptions the ERXValidationFactory should be used.

Parameters:
type of the exception, should be one of the constaints defined in this class.
object that is throwing the exception
key property key that failed validation

ERXValidationException ( String  type,
Object  object,
String  key,
Object  value 
)

Default constructor that builds a validation exception based on the type, object, key and failed value.Usually for creating custom validation exceptions the ERXValidationFactory should be used.

Parameters:
type of the exception, should be one of the constaints defined in this class.
object that is throwing the exception
key property key that failed validation
value that failed validation


Member Function Documentation

String _getMessage (  )  [protected]

NSArray additionalExceptions (  ) 

Cover method to return any additional exceptions that occurred. The reason this method is needed is because we wanted to have the ability to set the additional exceptions.

Returns:
array of additional exceptions

EOAttribute attribute (  ) 

Cover method for getting the attribute corresponding to the propertyKey and entity off of the objet.

Returns:
EOAttribute corresponding to the propertyKey and entity.

NSKeyValueCoding context (  ) 

The current context of the validation exception. Context objects are mainly used for resolving keys in validation templates. When validation exceptions are thrown in D2W pages the current D2WContext is set as the current context on the exceptions. If a context is not set then the contextForException is called off of the default ERXValidationFactory. When this also returns null, then the exception will be used as its context. This is needed because of some of the templates in ERDirectToWeb which use context.propertyKey and will display ? if none is given.

Returns:
current context for the validation exception.

Object delegate (  ) 

Gets the current delegate for this validation exception. If one is not set then the default delegate for the ERXValidationFactory is returned.

Returns:
delegate for this validation exception.

String displayNameForEntity (  ) 

Generates a displayable and localized version of the current object's entity name.

Returns:
localized displayable version of an object's entity name.

String displayNameForProperty (  ) 

Generates a displayable and localized version of the current propertyKey (also called key).

Returns:
localized displayable version of the current propertyKey.

EOEnterpriseObject eoObject (  ) 

Cover method that casts the object of the validation exception to an EOEnterpriseObject.

Returns:
object cast as an enterprise object.

boolean equals ( Object  anotherObject  ) 

Compares this exception to anything else.

Returns:
description of the validation exception

String getMessage (  ) 

Gets the message for this exception.

Returns:
the correctly formatted validation exception.

int hashCode (  ) 

boolean isCustomMethodException (  ) 

Convience method to determine if this exception was a custom thrown exception instead of a model thrown exception. A custom exception would be an exception that you throw in your validateFoo method if a particular constraint is not valid.

Returns:
if this exception is a custom thrown exception.

String localizedDisplayNameForKey ( String  key  )  [protected]

Creates a localized display name for a given key trying to localize it with the current "targetLanguage" or the current localizer. If there is an eoObject first try to localize "entityName.key" then "key" if nothing found.

Parameters:
key to be translated
Returns:
localized display version of the given key.

String method (  ) 

Returns method name. The method name is only set if the validation exception is a custom validation exception.

Returns:
custom method name.

Object object (  ) 

Overrides super implementation to allow for setable object value.

Returns:
object object for this exception.

String propertyKey (  ) 

Cover method for returning the key of the validation exception under the name propertyKey.

Returns:
the key of the validation exception

void setAdditionalExceptions ( NSArray  exceptions  ) 

Sets the array of additional exceptions that has occurried.

Parameters:
exceptions array of additional exceptions

void setContext ( NSKeyValueCoding  context  ) 

Sets the context that can be used to resolve key bindings in validation templates.

Parameters:
context of the current exception

void setDelegate ( Object  obj  ) 

Sets the delegate for the current validation exception. The delegate can intervine to provide a different template for the validation exception or resolve the template in a different manner.

Parameters:
obj delegate to be used for this validation exception.

void setMethod ( String  aMethod  ) 

Sets the custom method name that threw the validation exception.

Parameters:
aMethod name to be set.

void setObject ( Object  aValue  ) 

Sets the object that failed validation.

Parameters:
aValue object that failed validation

void setTargetLanguage ( String  aValue  ) 

Sets the target language to use when rendering the validation message. Only set a target language if you want to override the current language of the thread.

Parameters:
aValue name fo the language to render the validation exception in.

void setType ( String  aType  ) 

Sets the validation type of this exception. Should correspond to one of the type constants defined in this class. All of the model thrown validation exceptions should have the correct type already set.

Parameters:
aType name to set on this validation exception.

void setValue ( Object  aValue  ) 

Sets the value that failed validation.

Parameters:
aValue that failed validation

void takeValueForKey ( Object  obj,
String  key 
)

Implementation of the key value coding. Uses the default implementation.

Parameters:
obj value to be set on this exception
key to be set

Returns the target language to display the validation message in. If a target language is not set then the current default language for the current thread is used.

Returns:
target language if one is set.

String toString (  ) 

Returns the formatted description of the validation exception without calling getMessage.

Returns:
description of the validation exception

String type (  ) 

Cover method to return the type of the validation exception. The corresponds to one of the constant strings defined in this class.

Returns:
the type of this validation exception.

Object value (  ) 

Returns the value that failed validation.

Returns:
failed validation value.

Object valueForKey ( String  key  ) 

Implementation of key value coding. Uses the default implementation.

Parameters:
key to look up
Returns:
result of the lookup on the object


Member Data Documentation

volatile NSKeyValueCoding _context [protected]

holds a reference to the context of the exception

NSArray additionalExceptions [protected]

caches any set additionalExceptions

final String CustomMethodException = "CustomMethodException" [static]

corresponds to a custom method exception

volatile Object delegate [protected]

holds a reference to the exception delegate

final String ExceedsMaximumLengthException = "ExceedsMaximumLengthException" [static]

corresponds to a model thrown 'maximum length of attribute exceeded' exception

final String InvalidNumberException = "InvalidNumberException" [static]

corresponds to a number formatter exception

final String InvalidValueException = "InvalidValueException" [static]

corresponds to a generic 'invalid value' exception

final Logger log = Logger.getLogger(ERXValidationException.class) [static]

logging support

final String MandatoryToManyRelationshipException = "MandatoryToManyRelationshipException" [static]

corresponds to a model thrown 'manditory toMany relationship' exception

final String MandatoryToOneRelationshipException = "MandatoryToOneRelationshipException" [static]

corresponds to a model thrown 'mandatory toOne relationship' exception

String message [protected]

caches the validation message

String method [protected]

holds the method if one is provided

final String NullPropertyException = "NullPropertyException" [static]

corresponds to a model thrown 'null property' exception

Object object [protected]

holds the object that failed validation

final String ObjectRemovalException = "ObjectRemovalException" [static]

corresponds to a model thrown 'object removal' exception

final String ObjectsRemovalException = "ObjectsRemovalException" [static]

corresponds to a model thrown 'objects removal' exception

String targetLanguage [protected]

holds the target language if provided

String type [protected]

holds the type of the exception

Object value [protected]

holds the value that failed validation

final String ValueConversionException = "ValueConversionException" [static]

corresponds to a model thrown 'Error converting value of class' exception


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:43:17 2012 for Project Wonder by  doxygen 1.5.8