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