public class ERXValidationFactory extends 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 |
---|---|
protected Constructor |
regularConstructor
caches the constructor used to build validation exceptions
|
static 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.
|
com.webobjects.foundation.NSKeyValueCoding |
contextForException(ERXValidationException erv)
The context for a given validation exception can be used
to resolve keys in validation template.
|
protected NSArray<ERXValidationException> |
convertAdditionalExceptions(com.webobjects.foundation.NSValidation.ValidationException ex)
Converts the additional exceptions contained in an Exception to ERXValidationException subclasses.
|
ERXValidationException |
convertException(com.webobjects.foundation.NSValidation.ValidationException eov)
Converts a model thrown validation exception into
an
ERXValidationException . |
ERXValidationException |
convertException(com.webobjects.foundation.NSValidation.ValidationException eov,
Object value)
Converts a given model thrown validation exception into
an
ERXValidationException . |
ERXValidationException |
createCustomException(com.webobjects.eocontrol.EOEnterpriseObject eo,
String method)
Creates a custom validation exception for a given
enterprise object and method.
|
ERXValidationException |
createCustomException(com.webobjects.eocontrol.EOEnterpriseObject eo,
String property,
Object value,
String method)
Creates a custom validation exception.
|
ERXValidationException |
createException(com.webobjects.eocontrol.EOEnterpriseObject eo,
String property,
Object value,
String type)
Entry point for creating validation exceptions.
|
static Object |
defaultDelegate()
Returns the default validation delegate that will
be set on all validation exceptions created.
|
static ERXValidationFactory |
defaultFactory()
Returns the default factory.
|
String |
messageForException(ERXValidationException erv)
Entry point for generating an exception message
for a given message.
|
protected Constructor |
regularValidationExceptionConstructor()
Simple method used to lookup and cache the
constructor to build validation exceptions.
|
void |
resetTemplateCache(com.webobjects.foundation.NSNotification n)
Called when the Localizer is reset.
|
static void |
setDefaultDelegate(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 |
setTemplateDelimiter(String delimiter)
Sets the template delimiter to be used
when parsing templates for creating validation
exception messages.
|
void |
setValidationExceptionClass(Class class1)
Sets the validation class to be used when
creating validation exceptions.
|
boolean |
shouldRecreateException(ERXValidationException erv,
Object value)
Decides if an existing
ERXValidationException
should be re-created. |
String |
templateDelimiter()
Returns the template delimiter, the
default delimiter is "@@".
|
protected String |
templateForEntityPropertyType(String entityName,
String property,
String type,
String targetLanguage)
Finds a template for a given entity, property key, exception type and target
language.
|
String |
templateForException(ERXValidationException erv)
Entry point for finding a template for a given validation
exception.
|
String |
templateForKeyPath(String key,
String language)
Get the template for a given key in a given language.
|
Class |
validationExceptionClass()
Returns the validation exception class to use
when creating exceptions.
|
public static final String VALIDATION_TEMPLATE_PREFIX
protected Constructor regularConstructor
public static void setDefaultFactory(ERXValidationFactory aFactory)
aFactory
- new factorypublic static ERXValidationFactory defaultFactory()
public static Object defaultDelegate()
public static void setDefaultDelegate(Object obj)
obj
- default validation delegatepublic void setValidationExceptionClass(Class class1)
class1
- validation exception classpublic Class validationExceptionClass()
ERXValidationException
is used.protected Constructor regularValidationExceptionConstructor()
public ERXValidationException createException(com.webobjects.eocontrol.EOEnterpriseObject eo, String property, Object value, 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, 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(com.webobjects.eocontrol.EOEnterpriseObject eo, 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(com.webobjects.eocontrol.EOEnterpriseObject eo, String property, Object value, 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(com.webobjects.foundation.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(com.webobjects.foundation.NSValidation.ValidationException eov, 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(com.webobjects.foundation.NSValidation.ValidationException ex)
ex
- validation exceptionpublic String messageForException(ERXValidationException erv)
getMessage
off of ERXValidationException
calls this method passing in itself as the parameter.erv
- validation exceptionpublic String templateForException(ERXValidationException erv)
erv
- validation exceptionpublic void resetTemplateCache(com.webobjects.foundation.NSNotification n)
n
- notification posted when the localizer
is reset.public com.webobjects.foundation.NSKeyValueCoding contextForException(ERXValidationException erv)
erv
- a given validation exceptionpublic String templateDelimiter()
public void setTemplateDelimiter(String delimiter)
delimiter
- to be setpublic void configureFactory()
protected String templateForEntityPropertyType(String entityName, String property, String type, String targetLanguage)
entityName
- name of the entityproperty
- key nametype
- validation exception typetargetLanguage
- target language namepublic String templateForKeyPath(String key, String language)
ERXLocalizer
to handle the actual lookup.key
- the key to lookuplanguage
- use localizer for this languagenull
if none is foundCopyright © 2002 – 2020 Project Wonder.