public class ERXValidationFactory
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
ERXValidationFactory.ExceptionDelegateInterface
Exception delegates can be used to provide hooks to customize
how messages are generated for validation exceptions and how
templates are looked up.
|
static interface |
ERXValidationFactory.FactoryInterface
The validation factory interface.
|
| Modifier and Type | Field and Description |
|---|---|
static org.apache.log4j.Logger |
log
logging support
|
protected java.lang.reflect.Constructor |
regularConstructor
caches the constructor used to build validation exceptions
|
static java.lang.String |
VALIDATION_TEMPLATE_PREFIX
holds the value 'ValidationTemplate.'
|
| Constructor and Description |
|---|
ERXValidationFactory() |
| Modifier and Type | Method and Description |
|---|---|
void |
configureFactory()
Method used to configure the validation factory
for operation.
|
NSKeyValueCoding |
contextForException(ERXValidationException erv)
The context for a given validation exception can be used
to resolve keys in validation template.
|
protected NSArray<ERXValidationException> |
convertAdditionalExceptions(NSValidation.ValidationException ex)
Converts the additional exceptions contained in an Exception to ERXValidationException subclasses.
|
ERXValidationException |
convertException(NSValidation.ValidationException eov)
Converts a model thrown validation exception into
an
ERXValidationException. |
ERXValidationException |
convertException(NSValidation.ValidationException eov,
java.lang.Object value)
Converts a given model thrown validation exception into
an
ERXValidationException. |
ERXValidationException |
createCustomException(EOEnterpriseObject eo,
java.lang.String method)
Creates a custom validation exception for a given
enterprise object and method.
|
ERXValidationException |
createCustomException(EOEnterpriseObject eo,
java.lang.String property,
java.lang.Object value,
java.lang.String method)
Creates a custom validation exception.
|
ERXValidationException |
createException(EOEnterpriseObject eo,
java.lang.String property,
java.lang.Object value,
java.lang.String type)
Entry point for creating validation exceptions.
|
static java.lang.Object |
defaultDelegate()
Returns the default validation delegate that will
be set on all validation exceptions created.
|
static ERXValidationFactory |
defaultFactory()
Returns the default factory.
|
java.lang.String |
messageForException(ERXValidationException erv)
Entry point for generating an exception message
for a given message.
|
protected java.lang.reflect.Constructor |
regularValidationExceptionConstructor()
Simple method used to lookup and cache the
constructor to build validation exceptions.
|
void |
resetTemplateCache(NSNotification n)
Called when the Localizer is reset.
|
static void |
setDefaultDelegate(java.lang.Object obj)
Sets the default validation delegate that
will be set on all validation exceptions that
are created by the factory.
|
static void |
setDefaultFactory(ERXValidationFactory aFactory)
Sets the default factory to be used for converting
model thrown exceptions.
|
void |
setDelimiter(java.lang.String delimiter)
Deprecated.
use
setTemplateDelimiter(String) instead |
void |
setTemplateDelimiter(java.lang.String delimiter)
Sets the template delimiter to be used
when parsing templates for creating validation
exception messages.
|
void |
setValidationExceptionClass(java.lang.Class class1)
Sets the validation class to be used when
creating validation exceptions.
|
boolean |
shouldRecreateException(ERXValidationException erv,
java.lang.Object value)
Decides if an existing
ERXValidationException
should be re-created. |
java.lang.String |
templateDelimiter()
Returns the template delimiter, the
default delimiter is "@@".
|
protected java.lang.String |
templateForEntityPropertyType(java.lang.String entityName,
java.lang.String property,
java.lang.String type,
java.lang.String targetLanguage)
Finds a template for a given entity, property key, exception type and target
language.
|
java.lang.String |
templateForException(ERXValidationException erv)
Entry point for finding a template for a given validation
exception.
|
java.lang.String |
templateForKeyPath(java.lang.String key,
java.lang.String language)
Get the template for a given key in a given language.
|
java.lang.Class |
validationExceptionClass()
Returns the validation exception class to use
when creating exceptions.
|
public static final org.apache.log4j.Logger log
public static final java.lang.String VALIDATION_TEMPLATE_PREFIX
protected java.lang.reflect.Constructor regularConstructor
public static void setDefaultFactory(ERXValidationFactory aFactory)
aFactory - new factorypublic static ERXValidationFactory defaultFactory()
public static java.lang.Object defaultDelegate()
public static void setDefaultDelegate(java.lang.Object obj)
obj - default validation delegatepublic void setValidationExceptionClass(java.lang.Class class1)
class1 - validation exception classpublic java.lang.Class validationExceptionClass()
ERXValidationException is used.protected java.lang.reflect.Constructor regularValidationExceptionConstructor()
public ERXValidationException createException(EOEnterpriseObject eo, java.lang.String property, java.lang.Object value, java.lang.String type)
ERXValidationException.eo - enterprise object that is failing validationproperty - attribute that failed validationvalue - that failed validatingtype - of the validation exceptionpublic boolean shouldRecreateException(ERXValidationException erv, java.lang.Object value)
ERXValidationException
should be re-created. This is useful if you have several subclasses of
exceptions for different types of objects or messages and the framework can
only convert to the base type given the information it has at that point.erv - previous validation exceptionvalue - value that failed validatingtrue if the exception should be recreatedpublic ERXValidationException createCustomException(EOEnterpriseObject eo, java.lang.String method)
null for property and value.eo - enterprise object failing validationmethod - name of the method to use to look up the validation
exception template, for instance "FirstNameCanNotMatchLastNameValidationException"public ERXValidationException createCustomException(EOEnterpriseObject eo, java.lang.String property, java.lang.Object value, java.lang.String method)
eo - enterprise object failing validationproperty - attribute that failed validationvalue - that failed validationmethod - unique identified usually corresponding to a
method name to pick up the validation templatepublic ERXValidationException convertException(NSValidation.ValidationException eov)
ERXValidationException.
This is a cover method for the two argument version
passing in null as the value.eov - validation exception to be convertedpublic ERXValidationException convertException(NSValidation.ValidationException eov, java.lang.Object value)
ERXValidationException.
This method is used by ERXEntityClassDescription
to convert model thrown validation exceptions. This isn't
a very elegant solution, but until we can register our
our validation exception class this is what we have to do.eov - validation exception to be convertedvalue - that failed validationprotected NSArray<ERXValidationException> convertAdditionalExceptions(NSValidation.ValidationException ex)
ex - validation exceptionpublic java.lang.String messageForException(ERXValidationException erv)
getMessage
off of ERXValidationException
calls this method passing in itself as the parameter.erv - validation exceptionpublic java.lang.String templateForException(ERXValidationException erv)
erv - validation exceptionpublic void resetTemplateCache(NSNotification n)
n - notification posted when the localizer
is reset.public NSKeyValueCoding contextForException(ERXValidationException erv)
erv - a given validation exceptionpublic java.lang.String templateDelimiter()
@Deprecated public void setDelimiter(java.lang.String delimiter)
setTemplateDelimiter(String) insteaddelimiter - to be setpublic void setTemplateDelimiter(java.lang.String delimiter)
delimiter - to be setpublic void configureFactory()
protected java.lang.String templateForEntityPropertyType(java.lang.String entityName,
java.lang.String property,
java.lang.String type,
java.lang.String targetLanguage)
entityName - name of the entityproperty - key nametype - validation exception typetargetLanguage - target language namepublic java.lang.String templateForKeyPath(java.lang.String key,
java.lang.String language)
ERXLocalizer to handle the actual lookup.key - the key to lookuplanguage - use localizer for this languagenull if none is foundCopyright © 2002 – 2022 Project Wonder.