ERXValidationFactory Class Reference
List of all members.
|
Classes |
| interface | ExceptionDelegateInterface |
| interface | FactoryInterface |
Public Member Functions |
| void | configureFactory () |
| NSKeyValueCoding | contextForException (ERXValidationException erv) |
| ERXValidationException | convertException (NSValidation.ValidationException eov, Object value) |
| ERXValidationException | convertException (NSValidation.ValidationException eov) |
| ERXValidationException | createCustomException (EOEnterpriseObject eo, String property, Object value, String method) |
| ERXValidationException | createCustomException (EOEnterpriseObject eo, String method) |
| ERXValidationException | createException (EOEnterpriseObject eo, String property, Object value, String type) |
| String | messageForException (ERXValidationException erv) |
| void | resetTemplateCache (NSNotification n) |
| void | setDelimiter (String delimiter) |
| void | setValidationExceptionClass (Class class1) |
| boolean | shouldRecreateException (ERXValidationException erv, Object value) |
| String | templateDelimiter () |
| String | templateForException (ERXValidationException erv) |
| String | templateForKeyPath (String key, String language) |
| Class | validationExceptionClass () |
Static Public Member Functions |
| static Object | defaultDelegate () |
| static ERXValidationFactory | defaultFactory () |
| static void | setDefaultDelegate (Object obj) |
| static void | setDefaultFactory (ERXValidationFactory aFactory) |
Static Public Attributes |
| static final Logger | log = Logger.getLogger(ERXValidationFactory.class) |
| static final String | VALIDATION_TEMPLATE_PREFIX = "ValidationTemplate." |
Protected Member Functions |
| NSArray | convertAdditionalExceptions (NSValidation.ValidationException ex) |
| Constructor | regularValidationExceptionConstructor () |
| String | templateForEntityPropertyType (String entityName, String property, String type, String targetLanguage) |
Protected Attributes |
| Constructor | regularConstructor |
Static Package Functions |
| | [static initializer] |
Private Attributes |
| Hashtable | _cache = new Hashtable(1000) |
| String | _delimiter = "@@" |
| Class | _validationExceptionClass |
Static Private Attributes |
| static ERXValidationFactory | _defaultFactory |
| static Object | _defaultValidationDelegate = null |
| static NSDictionary | _mappings |
| static Class[] | _regularConstructor = new Class[] { String.class, Object.class, String.class, Object.class } |
| static final Class[] | EDI_FE_ARGS = new Class[] { ERXValidationException.class } |
| static final String | EDI_MFE_METHOD_NAME = "messageForException" |
| static final String | EDI_TFE_METHOD_NAME = "templateForException" |
| static final String | UNDEFINED_VALIDATION_TEMPLATE = "Undefined Validation Template" |
Detailed Description
The
validation factory controls creating
validation exceptions, both from model thrown exceptions and custom
validation exceptions. The factory is responsible for resolving
validation templates for
validation exceptions and generating
validation messages.
Member Function Documentation
| [static initializer] |
( |
|
) |
[static, package] |
In the static initializer the mapping dictionary is created.
| void configureFactory |
( |
|
) |
|
Method used to configure the validation factory for operation. This method is called on the default factory from an observer when the application is finished launching.
The context for a given validation exception can be used to resolve keys in validation template. If a context is not provided for a validation exception then this method will be called if a context is needed for a validation exception. Override this method if you want to provide your own default contexts to validation exception template parsing.
- Parameters:
-
- Returns:
- context to be used for this validation exception
| NSArray convertAdditionalExceptions |
( |
NSValidation.ValidationException |
ex |
) |
[protected] |
Converts the additional exceptions contained in an Exception to ERXValidationException subclasses.
- Parameters:
-
- Returns:
- NSArray of converted exceptions
Creates a custom validation exception. This is the preferred way of creating custom validation exceptions.
- Parameters:
-
| eo | enterprise object failing validation |
| property | attribute that failed validation |
| value | that failed validation |
| method | unique identified usually corresponding to a method name to pick up the validation template |
- Returns:
- custom validation exception
Creates a custom validation exception for a given enterprise object and method. This method is just a cover method for calling the four argument method specifying null for property and value.
- Parameters:
-
| eo | enterprise object failing validation |
| method | name of the method to use to look up the validation exception template, for instance "FirstNameCanNotMatchLastNameValidationException" |
- Returns:
- a custom validation exception for the given criteria
Entry point for creating validation exceptions. This method is used by all of the other methods to create validation exceptions for an enterprise object, a property key, a value and a type. The type should correspond to one of the validation exception types defined in ERXValidationException.
- Parameters:
-
| eo | enterprise object that is failing validation |
| property | attribute that failed validation |
| value | that failed validating |
| type | of the validation exception |
- Returns:
- validation exception for the given information
| static Object defaultDelegate |
( |
|
) |
[static] |
Entry point for generating an exception message for a given message. The method getMessage off of ERXValidationException calls this method passing in itself as the parameter.
- Parameters:
-
- Returns:
- a localized validation message for the given exception
| Constructor regularValidationExceptionConstructor |
( |
|
) |
[protected] |
Simple method used to lookup and cache the constructor to build validation exceptions.
- Returns:
- constructor used to build validation exceptions
| void resetTemplateCache |
( |
NSNotification |
n |
) |
|
Called when the Localizer is reset. This will reset the template cache.
- Parameters:
-
| n | notification posted when the localizer is reset. |
| static void setDefaultDelegate |
( |
Object |
obj |
) |
[static] |
Sets the default factory to be used for converting model thrown exceptions.
- Parameters:
-
| void setDelimiter |
( |
String |
delimiter |
) |
|
sets the template delimiter to be used when parsing templates for creating validation exception messages.
- Parameters:
-
| void setValidationExceptionClass |
( |
Class |
class1 |
) |
|
Decides if an existing 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.
- Parameters:
-
| erv | previous validation exception |
| value | value that failed validating |
- Returns:
- yes if the exception should be recreated
Returns the template delimiter, the default delimiter is "@".
- Returns:
- template delimiter
Finds a template for a given entity, property key, exception type and target language. This method provides the defaulting behaviour needed to handle model thrown validation exceptions.
- Parameters:
-
| entityName | name of the entity |
| property | key name |
| type | validation exception type |
| targetLanguage | target language name |
- Returns:
- a templaet for the given set of parameters
Entry point for finding a template for a given validation exception. Override this method to provide your own template resolution scheme.
- Parameters:
-
- Returns:
- validation template for the given exception
Get the template for a given key in a given language. Uses ERXLocalizer to handle the actual lookup.
- Returns:
- template for key or null if none is found
| Class validationExceptionClass |
( |
|
) |
|
Member Data Documentation
Hashtable _cache = new Hashtable(1000) [private] |
holds the template cache for a given set of keys
holds a reference to the default validation factory
holds a reference to the default validation delegate
holds the default template delimiter, "@@"
holds the default mappings that map model thrown validation strings to exception types
Class [] _regularConstructor = new Class[] { String.class, Object.class, String.class, Object.class } [static, private] |
final Class [] EDI_FE_ARGS = new Class[] { ERXValidationException.class } [static, private] |
holds the class argument array for delegate validation exception messages
holds the method name 'messageForException'
holds the method name 'templateForException'
final Logger log = Logger.getLogger(ERXValidationFactory.class) [static] |
caches the constructor used to build validation exceptions
holds the marker for an un defined validation template
holds the value 'ValidationTemplate.'
The documentation for this class was generated from the following file: