public class ERXValidationException
extends com.webobjects.foundation.NSValidation.ValidationException
implements com.webobjects.foundation.NSKeyValueCoding
NSValidation.ValidationException
to add template based resolution of the validation exception. See more
information about resolving templates in the ERXValidationFactory
.com.webobjects.foundation.NSKeyValueCoding._BooleanFieldBinding, com.webobjects.foundation.NSKeyValueCoding._BooleanMethodBinding, com.webobjects.foundation.NSKeyValueCoding._FieldBinding, com.webobjects.foundation.NSKeyValueCoding._ForwardingBinding, com.webobjects.foundation.NSKeyValueCoding._KeyBinding, com.webobjects.foundation.NSKeyValueCoding._KeyBindingCreation, com.webobjects.foundation.NSKeyValueCoding._MethodBinding, com.webobjects.foundation.NSKeyValueCoding._NumberFieldBinding, com.webobjects.foundation.NSKeyValueCoding._NumberMethodBinding, com.webobjects.foundation.NSKeyValueCoding._ReflectionKeyBindingCreation, com.webobjects.foundation.NSKeyValueCoding.DefaultImplementation, com.webobjects.foundation.NSKeyValueCoding.ErrorHandling, com.webobjects.foundation.NSKeyValueCoding.MapImplementation, com.webobjects.foundation.NSKeyValueCoding.Null<T>, com.webobjects.foundation.NSKeyValueCoding.UnknownKeyException, com.webobjects.foundation.NSKeyValueCoding.Utility, com.webobjects.foundation.NSKeyValueCoding.ValueAccessor
Modifier and Type | Field and Description |
---|---|
protected com.webobjects.foundation.NSKeyValueCoding |
_context
holds a reference to the context of the exception
|
protected NSArray<com.webobjects.foundation.NSValidation.ValidationException> |
additionalExceptions
caches any set additionalExceptions
|
static String |
CustomMethodException
corresponds to a custom method exception
|
protected Object |
delegate
holds a reference to the exception delegate
|
static String |
ExceedsMaximumLengthException
corresponds to a model thrown 'maximum length of attribute exceeded' exception
|
static String |
InvalidNumberException
corresponds to a number formatter exception
|
static String |
InvalidValueException
corresponds to a generic 'invalid value' exception
|
static String |
MandatoryToManyRelationshipException
corresponds to a model thrown 'mandatory toMany relationship' exception
|
static String |
MandatoryToOneRelationshipException
corresponds to a model thrown 'mandatory toOne relationship' exception
|
protected String |
message
caches the validation message
|
protected String |
method
holds the method if one is provided
|
static String |
NullPropertyException
corresponds to a model thrown 'null property' exception
|
protected Object |
object
holds the object that failed validation
|
static String |
ObjectRemovalException
corresponds to a model thrown 'object removal' exception
|
static String |
ObjectsRemovalException
corresponds to a model thrown 'objects removal' exception
|
protected String |
targetLanguage
holds the target language if provided
|
protected String |
type
holds the type of the exception
|
protected Object |
value
holds the value that failed validation
|
static String |
ValueConversionException
corresponds to a model thrown 'Error converting value of class' exception
|
Constructor and Description |
---|
ERXValidationException(String type,
Object object,
String key)
Default constructor that builds a validation exception
without the failed value specified.
|
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. |
Modifier and Type | Method and Description |
---|---|
protected String |
_getMessage() |
NSArray<com.webobjects.foundation.NSValidation.ValidationException> |
additionalExceptions()
Cover method to return any additional exceptions that
occurred.
|
EOAttribute |
attribute()
Cover method for getting the attribute corresponding
to the propertyKey and entity off of
the object.
|
com.webobjects.foundation.NSKeyValueCoding |
context()
The current context of the validation exception.
|
Object |
delegate()
Gets the current delegate for this validation exception.
|
String |
displayNameForEntity()
Generates a displayable and localized version of the
current object's entity name.
|
String |
displayNameForProperty()
Generates a displayable and localized version of the
current propertyKey (also called key).
|
com.webobjects.eocontrol.EOEnterpriseObject |
eoObject()
Cover method that casts the
object of
the validation exception to an EOEnterpriseObject. |
boolean |
equals(Object anotherObject)
Compares this exception to anything else.
|
String |
escapedValue()
Provides an escaped value to use in validation template string.
|
String |
getMessage()
Gets the message for this exception.
|
int |
hashCode() |
boolean |
isCustomMethodException()
Convenience method to determine if this exception
was a custom thrown exception instead of a model
thrown exception.
|
protected String |
localizedDisplayNameForKey(String key)
Creates a localized display name for a given key
trying to localize it with the current "targetLanguage" or the
current localizer.
|
String |
method()
Returns method name.
|
Object |
object()
Overrides super implementation to allow for settable object value.
|
String |
propertyKey()
Cover method for returning the
key of
the validation exception under the name propertyKey. |
void |
setAdditionalExceptions(NSArray<com.webobjects.foundation.NSValidation.ValidationException> exceptions)
Sets the array of additional exceptions.
|
void |
setContext(com.webobjects.foundation.NSKeyValueCoding context)
Sets the context that can be used to resolve key bindings
in validation templates.
|
void |
setDelegate(Object obj)
Sets the delegate for the current validation exception.
|
void |
setMethod(String aMethod)
Sets the custom method name that threw the
validation exception.
|
void |
setObject(Object aValue)
Sets the object that failed validation.
|
void |
setTargetLanguage(String aValue)
Sets the target language to use when rendering the validation
message.
|
void |
setType(String aType)
Sets the validation type of this exception.
|
void |
setValue(Object aValue)
Sets the value that failed validation.
|
void |
takeValueForKey(Object obj,
String key)
Implementation of the key value coding.
|
String |
targetLanguage()
Returns the target language to display the validation message in.
|
String |
toString()
Returns the formatted description of the validation exception
without calling
getMessage . |
String |
type()
Cover method to return the type of the validation
exception.
|
Object |
value()
Returns the value that failed validation.
|
Object |
valueForKey(String key)
Implementation of key value coding.
|
aggregateExceptionWithExceptions, exceptionAddingEntriesToUserInfo, exceptionWithObjectAndKey, key, userInfo
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
public static final String NullPropertyException
public static final String InvalidNumberException
public static final String InvalidValueException
public static final String MandatoryToOneRelationshipException
public static final String MandatoryToManyRelationshipException
public static final String ObjectRemovalException
public static final String ObjectsRemovalException
public static final String ExceedsMaximumLengthException
public static final String ValueConversionException
public static final String CustomMethodException
protected String message
protected String method
protected String type
protected Object value
protected Object object
protected String targetLanguage
protected NSArray<com.webobjects.foundation.NSValidation.ValidationException> additionalExceptions
protected volatile com.webobjects.foundation.NSKeyValueCoding _context
protected volatile Object delegate
public ERXValidationException(String type, Object object, String key)
ERXValidationFactory
should be used.type
- of the exception, should be one of the constraints
defined in this class.object
- that is throwing the exceptionkey
- property key that failed validationpublic ERXValidationException(String type, Object object, String key, Object value)
ERXValidationFactory
should be used.type
- of the exception, should be one of the constraints
defined in this class.object
- that is throwing the exceptionkey
- property key that failed validationvalue
- that failed validationpublic String getMessage()
getMessage
in class Throwable
protected String _getMessage()
public Object valueForKey(String key)
valueForKey
in interface com.webobjects.foundation.NSKeyValueCoding
key
- to look uppublic void takeValueForKey(Object obj, String key)
takeValueForKey
in interface com.webobjects.foundation.NSKeyValueCoding
obj
- value to be set on this exceptionkey
- to be setpublic boolean isCustomMethodException()
public String method()
public void setMethod(String aMethod)
aMethod
- name to be set.public com.webobjects.eocontrol.EOEnterpriseObject eoObject()
object
of
the validation exception to an EOEnterpriseObject.public Object object()
object
in class com.webobjects.foundation.NSValidation.ValidationException
public String propertyKey()
key
of
the validation exception under the name propertyKey.public EOAttribute attribute()
public String type()
public void setType(String aType)
aType
- name to set on this validation
exception.public Object value()
public String escapedValue()
value()
,
WOMessage.stringByEscapingHTMLString(String)
public void setValue(Object aValue)
aValue
- that failed validationpublic void setObject(Object aValue)
aValue
- object that failed validationpublic String targetLanguage()
public void setTargetLanguage(String aValue)
aValue
- name of the language to render the validation
exception in.public Object delegate()
ERXValidationFactory
is returned.public void setDelegate(Object obj)
obj
- delegate to be used for this validation exception.public com.webobjects.foundation.NSKeyValueCoding context()
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.
public void setContext(com.webobjects.foundation.NSKeyValueCoding context)
context
- of the current exceptionpublic void setAdditionalExceptions(NSArray<com.webobjects.foundation.NSValidation.ValidationException> exceptions)
exceptions
- array of additional exceptionspublic NSArray<com.webobjects.foundation.NSValidation.ValidationException> additionalExceptions()
additionalExceptions
in class com.webobjects.foundation.NSValidation.ValidationException
public String displayNameForProperty()
public String displayNameForEntity()
protected String localizedDisplayNameForKey(String key)
key
- to be translatedpublic boolean equals(Object anotherObject)
Copyright © 2002 – 2020 Project Wonder.